In your top level CMakeLists.txt:<div><br></div><div>add_subdirectory(B)</div><div>add_subdirectory(A)</div><div>add_subdirectory(C)<br><br></div><div>A &amp; C must come after B since they both depend on B.</div><div><br>
</div><div>Does that help?</div><div><br></div><div><br></div><div>Hope so,</div><div>David</div><div><br></div><div><br><div class="gmail_quote">2011/6/26 Klaim - Joël Lamotte <span dir="ltr">&lt;<a href="mailto:mjklaim@gmail.com">mjklaim@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<div><br></div><div>I&#39;m having trouble understanding how I should solve this case correctly in CMake :</div><div>
<br></div><div>I want my project A to include+link my project B. I already made it with project C but it don&#39;t work with A.</div>
<div>I think the problems comes from the directory structure :</div><div><br></div><div>/myrepo/tools/A (exe/Qt)</div><div>/myrepo/tools/B (shared library) </div><div>/myrepo/tools/B/C (exe)</div><div><br></div><div>Each of those folders have a CMakeFiles.txt file that add_subdirectory( the_sub_directories ).</div>

<div><br></div><div>B uses include_directories() and C use target_link_libraries( C B )</div><div>So C does include and compile+link with code using B code.</div><div><br></div><div>A code runs fine alone, but now I need it to use B.</div>

<div>I&#39;ve added </div><div><br></div><div>target_link_libraries( A ${QT_LIBRARIES} B )</div><div><br></div><div>to make sure it does uses B but the generated projects don&#39;t have the B include  directory.</div><div>

<br></div><div>I know that I could use an advanced variable to get the include file, but I don&#39;t find it consistent with the fact that</div><div>C executable does implicitely use the include file from B. A being configured the same, it should work too... no?</div>

<div><br></div><div>I think it&#39;s related to the projects CMakeFiles.txt positions in the directory hierarchy but I&#39;m still often wrestling with CMake so I&#39;m not sure.</div><div><br></div><div>What would be the idiomatic CMake way of making A include+link B?</div>

<div><br></div><div>The real code is open source so I can show you exactly what is my current setup if it helps (but I guess it&#39;s a noob question...)</div><div><br></div><font color="#888888"><div><br></div><div>Klaim - Joël Lamotte</div>

</font><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>