[CMake] Generate sources
Layus
layus.on at gmail.com
Wed Dec 16 08:29:08 EST 2015
Hi,
I am looking for a way to share an archive of a partially compiled
project to speedup compilation time and configuration hassle for the users.
I have a project that works in two steps.
First a source generator is built (based on clang) and generates some
extra source files based on the existing source files.
Then the normal compilation process takes places, building the
application from both original and generated sources.
Here is a pseudo-Makefile.
application: $GENERATED_SOURCES $SOURCES
cc $^ -o $@
$GENERATED_SOURCES: generator $SOURCES
# generate more sources
generator $SOURCES
generate: $GENERATED_SOURCES
generator: generator.cc clang(external) llvm(external)
cc $< -o $@ -lclang -lllvm
Of course, all the project is using CMake.
Now, is it possible to distribute a source archive with the generated
sources, in such a way that any user unpacking the archive and running
cmake would not have to generate the extra sources ?
This would be useful because
i) the project is tricky to configure and
ii) the generated sources are not dependent on the user config, so
building the generator is just useless computation time on the user.
The ideal scheme would be something like
[developper]
$ cmake -DCLANG=config
$ make generate
$ make package_source
[user]
$ unpack
$ cmake -DUSER=config
$ make # builds only the application, reusing the shipped generated
sources.
$ make install
... but when the user runs cmake, he overwrites the generated Makefiles
and the extra sources are generated again.
Any idea ?
layus.
More information about the CMake
mailing list