[CMake] dependency checking

Philip Lowman philip at yhbt.com
Thu Aug 9 13:40:34 EDT 2007


Juan Sanchez wrote:
> I just added a source file to the list of sources in my library and now
> it is recompiling every source file in that library.  I don't feel
> rebuilding the other source files is necessary and I'd like a way to
> tell cmake to trust me and that any object files I have are still good.

What version of CMake are you running?

Simply adding a source file to a library is not enough to trigger a
rebuild of that library although it will certainly cause the library to
relink.  Are you sure you didn't change a common header file or
something like that at the same time?

If you change the preprocessor definitions or include path the Makefile
generator will happily recompile all of the code that needs to be
recompiled.  This does not happen on Visual Studio however due to
limitations with Visual Studio.

On a related note:

There is a way to disable recompilation based on rule dependencies
buried in the useful variables section of the CMake wiki.  Simply
defining the variable CMAKE_SKIP_RULE_DEPENDENCY temporarily in your
CMakeLists.txt will cause CMake to stop the rebuilding of source files
that need to be rebuilt.  It's best to use this only temporarily and
only when you really don't want your development interrupted by a
rebuild of your entire source tree.  You should remove the variable as
soon as you have time to recompile.  Not doing so could be dangerous as
you might think things are working but not realize the addition of a
preprocessor definition or modification of the include path causes
things to break.

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list