[CMake] Executable depending on all source files
Rolf Eike Beer
eike at sf-mail.de
Sat Aug 25 07:44:31 EDT 2012
Kornel Benko wrote:
> Am Samstag, 25. August 2012 um 10:53:48, schrieb Russell Wallace
> <russell.wallace at gmail.com>
> > I don't understand what you mean, but explicit listing violates DRY in
> > a big way with the usual consequence, the two lists will inevitably
> > get out of sync. I'd rather use globbing (unless CMake has some other
> > method that doesn't involve trying to keep things in sync by hand)?
> > Even plain Make can use globbing reliably.
>
> The you may want to try
> file(GLOB foo_sources . src/*.cc)
> add_executable(foo ${foo_sources})
No, you surely don't want to do that. From the documentation of it (cmake --
help-command file):
We do not recommend using GLOB to
collect a list of source files from your source tree. If no
CMakeLists.txt file changes when a source is added or removed then the
generated build system cannot know when to ask CMake to regenerate.
Simple solution: do something like find . -type f -name \*.cc | sed 's,^\./,,'
>> CMakeLists.txt and move the result at the correct place in that file.
Eike
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120825/4a078e6f/attachment.pgp>
More information about the CMake
mailing list