[Cmake] Automatic Source Gathering

Brad King brad.king at kitware.com
Thu Aug 5 11:40:48 EDT 2004


Andrew Dupont wrote:
> 	I'm having trouble trusting the automatic search and store
> algorithms from Cmake. I do a FILE(GLOB_RECURSE var
> [/path/to/srcs/*.cpp]) and get an empty variable. If I individually
> enumerate them in a set command like SET(var /path/to/srcs/file.cpp) it
> works just fine. Am I misusing this command?

I suspect your globbing expression is wrong.  It should be specified as 
a relative path from the directory containing the FILE(GLOB_RECURSE ...) 
command.

However, it is much safer to list the files explicitly because then when 
you add a source file you have to change the CMakeLists.txt file to list 
it.  This modification will trigger dependencies that cause CMake to run 
and automatically regenerate your build system with the new source file.

-Brad


More information about the Cmake mailing list