[CMake] Autogenerating CMakeLists.txt

Sylvain Benner benner at virtools.com
Fri Nov 9 10:59:33 EST 2007


> The generator would glob for files within each project, so it would be 
> necessary to rebuild the CMakeList.txt files if meta-information is 
> changed, or if new files are added to a project.  Ideally, the 
> generated build system should issue a warning when the CMakeLists.txt 
> files are out of date.
I think you can achieve this with CMake scripts (invoked CMake command 
line tool with -P argument).
This script will call the FILE(GLOB...) or FILE(GLOB_RECURSE...) command 
and produce a file conaitning the list of all the source file.Then it 
compares it against the old listing. If there is any changes then it 
invokes CMake command line tool and regenerate the projects.

There is also some nice macro around this mailing list which can mimic 
the physical directory structure in your vcproj files.

CMake scripting is not as powerful or handy as other scripting languages 
but with a bit of work you can do a lot of things. Our framework relies 
heavily on CMake and this helps to keep it consistent (especially for 
variables accessing).

--Sylvain



More information about the CMake mailing list