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

Convey Christian J NPRI ConveyCJ at Npt.NUWC.Navy.Mil
Wed Mar 19 11:48:56 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?

We're transitioning non-software-engineers from using an old Makefile system (which did use filename globbing every time it ran) to using CMake.  We're trying to demand as little of them as possible, because we need to keep them happy.  

Explicitly listing each .cpp file is an option.  It hadn't previously occurred to me that it would resolve this issue.  I guess that for the moment I have a tradeoff to consider.  Thanks for pointing it out.

- Christian


More information about the CMake mailing list