<div class="gmail_quote"><div>I&#39;ve run into this issue before and posted a question about this on Programmers.StackExchange[1].  While the exact workflow I present is for Git &amp; CMake, the question is really similar.  The idea is to have a certain library B that depends on library A, as well as a program C that depends on B and A.  I want to be able to build each library by itself for library development and testing, as well building them as part of a program.</div>
<div><br></div><div>I&#39;ve come up with a simple workflow where each library project exports a &quot;library-config.cmake&quot; file and any project that includes it defines the &quot;library_DIR&quot; variable to the folder containing this &quot;library-config.cmake&quot; file so that it can be resolved from anywhere in the CMake scripts using only &quot;find_package()&quot;.  This way, when the library can either set the &quot;library_DIR&quot; variable or inherit it from the parent project.  This solves the problem of using either its own Git submodule or a parent project&#39;s Git submodule, ensuring you build the library only once for the entire project and that all sub-projects use the same version.</div>
<div><br></div><div>Note that you don&#39;t necessarily need to list all of each project&#39;s dependencies in the root CMake lists.  I do so out of convention (to explicitly document what library versions I&#39;m using) and convenience (to avoid recursive Git submodule checkouts).  You only typically need to do so for libraries referenced by multiple shared libraries, unless, of course, you really want to build the same library multiple times, possibly in multiple versions.</div>
<div><br></div><div>I&#39;m slowly converting all my projects to CMake using this pattern.  You can find some of those on my GitHub profile[2].  One example is cfcgi[3].  Note that I&#39;m learning a lot along the way and I don&#39;t guarantee that all of this conforms to CMake best practices.  I&#39;m only referring to this for the project structure and CMake concept to clarify my explanation with an example.  That being said, if anyone has comments about the CMake scripts in there, your input is welcome :-)</div>
<div><br></div><div>André</div><div><br></div><div>[1]: <a href="http://programmers.stackexchange.com/questions/114719">http://programmers.stackexchange.com/questions/114719</a></div><div>[2] : <a href="https://github.com/AndreLouisCaron">https://github.com/AndreLouisCaron</a></div>
<div>[3]: <a href="https://github.com/AndreLouisCaron/cfcgi">https://github.com/AndreLouisCaron/cfcgi</a></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">Le 29/04/2012 21:43, Alexander Broekhuis a écrit :
    <blockquote type="cite">Hi all,
      <div><br>
      </div>
      <div>I am looking for a way to have dependencies between
        independent projects. For examplehave been <br>
      </div><div>
      <div><br>
      </div>
      <div>ProjectA</div>
      <div>ProjectB depends on A</div>
      <div>ProjectC depends on B and A</div>
      <div><br>
      </div>
      <div>What I like to do is that when project B or C is build, the
        dependencies are also build. But I also want the project to be
        independent, to be more specific, if the project files for A are
        being generated I don&#39;t want the files for B and C generated. </div>
      <div><br>
      </div>
      <div>Basically my problem is, that I don&#39;t want all Makefile to be
        generated all at once. But only those needed for a certain
        project (and its dependencies). This helps with not having
        installed every library needed by all (sub)projects.</div>
      <div><br>
      </div>
      <div>Has anyone any experience with this, or perhaps some hints
        how I can solve this problem?</div>
      <div><br>
      </div>
      <div>TiA!<div class="im"><br clear="all">
        <div><br>
        </div>
        -- <br>
        Met vriendelijke groet,<br>
        <br>
        Alexander Broekhuis</div></div></div></blockquote></div></blockquote></div></div></blockquote></div>