[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] Generate sources
From: Layus <layus.on () gmail ! com>
Date: 2015-12-18 19:53:19
Message-ID: 5674642F.4060107 () gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On 16/12/15 17:53, Mark Stijnman wrote:
> On Wed, Dec 16, 2015 at 2:29 PM, Layus <layus.on@gmail.com
> <mailto:layus.on@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 !
[Attachment #5 (text/html)]
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 16/12/15 17:53, Mark Stijnman wrote:<br>
</div>
<blockquote
cite="mid:CAOzitB+QBYk66iD3w0JgsEPu3pngDZQtnjZRuqFzEJc11hM_aw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Dec 16, 2015 at 2:29 PM,
Layus <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:layus.on@gmail.com" \
target="_blank">layus.on@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
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.<br>
<br>
I have a project that works in two steps.<br>
First a source generator is built (based on clang) and
generates some extra source files based on the existing
source files.<br>
Then the normal compilation process takes places, building
the application from both original and generated sources.<br>
<br>
</blockquote>
<div><snip></div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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 ?<br>
<br>
This would be useful because<br>
i) the project is tricky to configure and<br>
ii) the generated sources are not dependent on the user
config, so building the generator is just useless
computation time on the user.<br>
<br>
The ideal scheme would be something like<br>
<br>
[developper]<br>
$ cmake -DCLANG=config<br>
$ make generate<br>
$ make package_source<br>
<br>
[user]<br>
$ unpack<br>
$ cmake -DUSER=config<br>
$ make # builds only the application, reusing the
shipped generated sources.<br>
$ make install<br>
<br>
... but when the user runs cmake, he overwrites the
generated Makefiles and the extra sources are generated
again.<br>
<br>
Any idea ?<br>
<br>
layus.<br>
<br>
-- <br>
</blockquote>
<div><br>
</div>
<div>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: </div>
<div>1. Set a variable GENERATED_FOLDER to
${CMAKE_CURRENT_SOURCE_DIR}/generated</div>
<div>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. </div>
<div>3. Simply use the ${GENERATED_FOLDER} variable to add
the generated files to your application. </div>
<div>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. </div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Hope that helps,</div>
<div><br>
</div>
<div>Best regards Mark</div>
</div>
</div>
</div>
</blockquote>
<br>
Works like a charm.<br>
<br>
(See <a class="moz-txt-link-freetext" \
href="https://github.com/layus/mozart2/tree/cache_generated_code">https://github.com/layus/mozart2/tree/cache_generated_code</a>)<br>
<br>
Thanks !<br>
<br>
</body>
</html>
--
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic