[CMake] Making cmake automatically pick up changes to directory contents.
Matthew Woehlke
matthew.woehlke at kitware.com
Mon Dec 2 15:27:55 EST 2013
On 2013-12-02 12:58,
billw at billw.mail1.co.uk wrote:
> I just finished converting a large project from VC project files to Cmake
> generated ones and am using file GLOBing to generate the file lists for
> builds. This is working fine and I don't see the benefit to explicitly
> specifying every file.
>
> I know the docs recommend not using GLOB, but the only reason given is
> that cmake won't do a rebuild when new files are added. This seems like a
> limitation of the build system not a good reason.
More like a design choice made for various reasons; a major one (as Bill
alludes to) being performance.
> So is there any good way to cause a CMake rebuild of a project when the
> contents of the directory change? I am thinking something like outputting
> the directory listing to a file (i.e. dir /b/s > filelist.txt) and adding
> that file as some sort of dependency to the project. But I don't know
> exactly how this would be done in practice.
>
> Any ideas or canonical methods?
Idea: don't do that :-).
Besides what Bill mentioned, if you're working on a project with more
than one instance of the source tree (i.e. you are using VCS¹ and/or
have more than one developer), explicitly listing files helps with
'forgot to add' errors since other builds will explicitly try to build a
file that doesn't exist, thus making such mistakes obvious, rather than
failing at some other point because a source file is missing.
(¹ I recommend to - and do - use VCS even for personal projects. With
most DVCS's e.g. git, it's really easy to do so, and having a history is
invaluable, especially if the project later grows. Plus it's ever so
much easier to work on a project from multiple machines :-).)
--
Matthew
More information about the CMake
mailing list