On 16/12/15 17:53, Mark Stijnman wrote:
On Wed, Dec 16, 2015 at 2:29 PM, Layus <layus...@gmail.com
<mailto:layus...@gmail.com>> wrote:
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.
<snip>
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.
--
I'd probably just make it such that the CMake script automatically
detects the presence of the generated files, and if they don't exist,
generate them. For example:
1. Set a variable GENERATED_FOLDER to
${CMAKE_CURRENT_SOURCE_DIR}/generated
2. If ${GENERATED_FOLDER} doesn't exist, set it to
${CMAKE_CURRENT_BINARY_DIR}/generated instead, and set up the targets
that will generate the files in that folder.
3. Simply use the ${GENERATED_FOLDER} variable to add the generated
files to your application.
4. Set up the package_source target so that it packages the files from
${GENERATED_FOLDER} to a folder called "generated" (such that if a
user unpacks from there, they will end up in
${CMAKE_CURRENT_SOURCE_DIR}/generated), and you're done.
5. Recommended: add a check for the existence of target "generate",
and if so, set it as a dependency for your application and package_source.
This way, you don't need to remember what switches to use, or when to
use "make generate". If you need to make it possible for a user to
force generation, you can alter step 2 to also run when a command line
option is supplied.
Hope that helps,
Best regards Mark
Works like a charm.
(See https://github.com/layus/mozart2/tree/cache_generated_code)
Thanks !
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake