<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>