[CMake] Executable depending on all source files

Kornel Benko kornel at lyx.org
Sat Aug 25 06:12:35 EDT 2012


Am Samstag, 25. August 2012 um 12:04:21, schrieb Alexander Neundorf <a.neundorf-work at gmx.net>
> On Saturday 25 August 2012, Russell Wallace wrote:
> > 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.
> 
> Yes, but here this is good IMO, since in general a file laying around in some 
> directory does not necessarily belong to the project.
> 
> > I'd rather use globbing (unless CMake has some other
> > method that doesn't involve trying to keep things in sync by hand)?
> 
> There is not much "trying" involved. You notice immediately if a file is 
> missing in your CMakeLists.tx or if you list a file which does not exist.

If a file is missing, you notice it in both cases.

If you add a file (without touching CMakeLists.txt of course) you will not notice in both cases.

> > Even plain Make can use globbing reliably.
> 
> You can use file(GLOB ...), but it is not recommended.
> When a new file is added to a target, cmake needs to rerun, to generate the 
> rules for building this file and to link the target.
> In the makefiles generated by cmake there is the dependency to rerun cmake 
> when any of its input files have changed (e.g. when you added or removed a 
> source file), but there is no rule to rerun cmake if anything in a directory 
> has changed. So simply adding a file to a directory will not cause cmake to 
> rerun automatically.
> By having to add that file explicitely to the CMakeLists.txt, cmake will rerun 
> and you will always have a consistent build system.
>
> Alex

	Kornel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120825/5160ac47/attachment-0001.htm>
-------------- 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/5160ac47/attachment-0001.pgp>


More information about the CMake mailing list