[CMake] Technique for generating projects that depend on generated sources
Alexander Neundorf
a.neundorf-work at gmx.net
Sun Mar 1 16:40:26 EST 2009
On Sunday 01 March 2009, you wrote:
> 2009/3/1 Alexander Neundorf <a.neundorf-work at gmx.net>:
> > On Friday 27 February 2009, Steve Huston wrote:
...
> > Can you run the source generator at cmake time ?
>
> Yes you are right and I miss that,
> if the generator is launched at CMake time it may help a lot.
> Moreover I would say that the "source file list" generated by the generator
> may be some kind of CMake file, let's say
>
> generated_source.cmake
>
> then one may
>
> INCLUDE(generated_source.cmake OPTIONAL) in the CMakeLists.txt
>
> then I CMake is clever enough:
>
> 0) during the first CMake run the optionnally included file is created
> 1) when launching the build after that the
> cmake_check_build_system rule will notice that
> "generated_source.cmake" appeared and will automatically
> relaunch CMake and then
> the build.
> Thus you would have the usual CMake + build step with an extra
> CMake run triggered by the build step itself.
>
> I've not tried so I may be wrong concerning the cleverness of a
> INCLUDE(generated_source.cmake OPTIONAL) statement.
Just tried this, doesn't work. If the to-be-included file does not exist, no
dependency to it is generated (wouldn't this actually result in a "no rule to
make target foo" error ?).
> > This would help against the problem. You can guard the generation e.g.
> > with if(file1 NEWER_THAN file2)
>
> I don't understand that point?
This way it wouldn't be run at every cmake invocation but only if necessary.
Alex
More information about the CMake
mailing list