[CMake] Getting Makefiles sensitive tonew/deleted files/directories?

Ken Martin ken.martin at kitware.com
Wed Mar 19 16:50:27 EDT 2008


Can you do the glob, configure the result out to a file, then INCLUDE that
file. I believe that will solve the problem. Something like

file(GLOB SRC *.cpp)
configure_file(somefile.in somefile)
include(somefile)

where somefile.in looks like

# list of files as a comment -- ${SRC}

This works because CMake does check (at make time) to see if any included
file in CMake has changed but is smart in that configure_file only writes
the file if it has changed. I'm pretty sure something like that will work.

Ken

Ken Martin PhD 
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 

> -----Original Message-----
> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
> Of Bill Hoffman
> Sent: Wednesday, March 19, 2008 10:13 AM
> To: Convey Christian J NPRI
> Cc: cmake at cmake.org
> Subject: Re: [CMake] Getting Makefiles sensitive tonew/deleted
> files/directories?
> 
> 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
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list