[CMake] Executable depending on all source files

Kornel Benko kornel at lyx.org
Sat Aug 25 05:59:34 EDT 2012


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})

> On Sat, Aug 25, 2012 at 10:41 AM, Alexander Neundorf
> <a.neundorf-work at gmx.net> wrote:
> > On Saturday 25 August 2012, Russell Wallace wrote:
> >> How do you specify that an executable depends on all source files in a
> >> directory? I've tried doing it like:
> >>
> >> add_executable(foo src/*.cc)
> >>
> >> but that only seems to pick up the first source file?
> >
> >
> > Explicitely list all of them.
> > Globbing is not good, cmake can't notice then when it has to rerun, and it may
> > pick up stuff it shouldn't.
> >
> > Alex

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


More information about the CMake mailing list