0

In both Visual Studio and Xcode, in a custom build step, I run cmake to generate a makefile, then I call NMake (or make). Now, it is unnecessary for cmake to generate every time the build step is invoked, and once generated, only NMake/make are enough.

However sometimes it IS necessary to rerun cmake, for example after cleaning. For build optimization, I'd like to detect the right thing to run (cmake/make). What criteria should I be looking for in my custom build script?

You may argue that I should always run a full cmake cycle, however:

  1. I have a few hundreds of those, and there is an overhead on sanity-checking the compilers etc by cmake.
  2. In projects where there are nested cmake directories, cmake falsely leaves a dependency folder "dirty", so that when another project with the same dependency builds, it rebuilds the dependency. With only Nmake/make that doesn't happen.
gil_mo
  • 575
  • 1
  • 6
  • 27
  • 1
    Err... the build file(s) generated by CMake *include* logic to re-run the CMake configuration, e.g. when the configuration files themselves have changed...?!? It's a bit difficult to figure out what your problem is, exactly. Generally speaking, there should be nothing "running CMake" after the initial configuration, other than CMake itself...?!? – DevSolar Dec 09 '18 at 18:03
  • As @DevSolar pointed out the files generated by CMake will re-run CMake if you update a CMakeLists.txt file and that sort of thing. I agree that just running `cmake .` to just update everything every time you build is a time waster and I don't think anyone does that or would suggest that. Why would you have to run CMake after cleaning? Unless your clean deletes something configured by CMake it is unnecessary. – fdk1342 Dec 09 '18 at 20:48
  • The "Clean" I was referring to was Xcode clean, meaning a wipeout of the temporary build folder, including cmake. In that case I DO want cmake to rebuild everything again. – gil_mo Dec 10 '18 at 08:22
  • 1
    Not using the Xcode clean? Both `make` and `nmake` generated by CMake provide a "clean" target that clears all temporary build files that are *not* part of the CMake configuration. You need to decide who's calling the shots. You're using CMake to get a platform-independent build. Let it control things platform-independently. – DevSolar Dec 10 '18 at 10:41
  • Unless the build directory is removed, running `make` will automatically detect whether need to rerun `cmake`. Of course, there are situations when some changes are not detected automatically. But such situations are **fully depend on the project**. I can imagin the only *universal* situation in which it could be useful for rerun `cmake` manually - when software(libraries, programs) has been changed(installed/uninstalled/upgraded). – Tsyvarev Dec 10 '18 at 12:14

0 Answers0