[CMake] How to make FILE() append to the list of files?

Michael Jackson mike.jackson at bluequartz.net
Fri Nov 28 06:23:43 EST 2008


On Nov 28, 2008, at 12:09 AM, Robert Dailey wrote:

> On Thu, Nov 27, 2008 at 2:31 PM, Alexander Neundorf <a.neundorf-work at gmx.net 
> > wrote:
> On Thursday 27 November 2008, Eric Noulard wrote:
> > 2008/11/27 Robert Dailey <rcdailey at gmail.com>:
> > >> find . -name "*.c" > source_files.txt
> > >> edit source_files.txt and put that list of files exiplicitly  
> into a
> > >> CMakeLists.txt file.
> > >>
> > >> file(GLOB is a bad way to get source lists for CMake.   CMake  
> has no way
> > >> of knowing when new files have been put in the directory.
> > >
> > > But unless I am missing a fundamental feature somewhere, GLOB  
> still seems
> > > to be the better alternative. While it may not intrinsically  
> know when
> > > new files have appeared on the filesystem, the programmer can  
> simply
> > > re-run the CMake command to get an updated project with the  
> newly added
> > > source files without editing the CMakeLists.txt file directly.
> >
> > Yes but when he add a source file, he won't necessarily remember he
> > MUST rerun CMake manually
> > so its next attempt to "build"  the project will trigger either a
> > compile error (added header missing)
> > or link error (added source file not compiled).
> >
> > Whereas with hard-written sources files in CMakeLists.txt, the user
> > will get accustomed to
> > "simple" CMakeList.txt editing thus CMake will relaunch itself
> > automatically when needed and
> > in particular when a CMakeLists.txt is changed.
>
> Additionally it can happen from time to time that there are files in  
> the
> directories which you just started to write, or forgot to delete, or  
> somebody
> else sent you, or... and which you don't want to build, but which  
> would be
> found by the glob.
> So, yes, put the files you want to have explicitely in your cmake  
> files.
>
> Okay, so if I hard-code the list of files to compile, I still need  
> to create 1 CMakeLists.txt file for each of the 20 directories  
> containing CPP files to compile. However, this is simply to  
> modularize the CMake script itself. I suppose I could use include()  
> instead of add_subdirectory()?
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake


Yes, Include would be the better command to use if the cmake file is  
just a list of files.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio





More information about the CMake mailing list