[CMake] Technique for generating projects that depend on generated sources

Alexander Neundorf a.neundorf-work at gmx.net
Sun Mar 1 15:52:43 EST 2009


On Friday 27 February 2009, Steve Huston wrote:
> Thanks for the advice, Bill.
>
> My situation is somewhat different, though. The output source files
> are not known ahead of time. Thus, the general scheme is:
>
> - build runs the source generator; one of the outputs is a file
> containing the names of the generated sources.
> - rerun cmake to regenerate the build now that the complete list of
> sources is known.
> - rerun the build with the complete set of sources

Oh, this is ugly.
The purpose of cmake is to generate project files which contain information 
about which files need to be compiled and how. This happens at cmake time. 
Then these project files are read at build time and the files are built.
Now if the names of the files which should be built are not known at cmake 
time, cmake can't generate rules for them in the project files.

Can you run the source generator at cmake time ?
This would help against the problem. You can guard the generation e.g. with 
if(file1 NEWER_THAN file2)

Alex


More information about the CMake mailing list