[CMake] Getting Makefiles sensitive to new/deleted files/directories?

Bill Hoffman bill.hoffman at kitware.com
Wed Mar 19 10:13:08 EDT 2008


Convey Christian J NPRI wrote:
> Many of my CMakeLists.txt files has code like this:
> 
> FILE(GLOB SRC *.cpp *.c)
> ADD_LIBRARY(my_lib ${SRC})
> 
> My users occasionally get tripped up because after someone adds a new .cpp file, the other users forget to rerun "cmake" before running "make".
> 
> Has anyone considered enhancing CMake so that when the set of source files picked up by a FILE(GLOB ...) command changes, cmake is automatically re-run?
> 
> Even if a new command had to be added, or a new option to the FILE(...) command, that would be fine.  But this is probably the main problem I'm seeing my users encounter with our CMake-based build system.  I'd be very happy if we could eliminate it.
> 

Really this is not a recommended way of setting up a cmake project. I 
suppose this could be done when cmake check build system is done. It 
would slow down the cmake check because it would have to do the glob 
each time the build system is run.  It would not be trivial to 
implement.  Also, this kind of thing can cause trouble if you put temp 
files in your source directory that happen to match.  Is it really that 
hard to list all the files you want to build?

-Bill


More information about the CMake mailing list