<div dir="ltr"><div class="gmail_default" style="font-family:"courier new",monospace"><font face="tahoma, sans-serif">H</font><span style="font-family:tahoma,sans-serif">i, I'm trying to understand what's the recommended way of</span></div><div class="gmail_default"><font face="tahoma, sans-serif">implementing CMake build system in the following repository:</font></div><div class="gmail_default" style="font-family:"courier new",monospace"><br></div><div class="gmail_default" style="font-family:"courier new",monospace">repo</div><div class="gmail_default" style="font-family:"courier new",monospace">|</div><div class="gmail_default" style="font-family:"courier new",monospace">|___ util<br></div><div class="gmail_default" style="font-family:"courier new",monospace">| |___ include</div><div class="gmail_default" style="font-family:"courier new",monospace">| | |___ util</div><div class="gmail_default" style="font-family:"courier new",monospace">| | |___ util.h</div><div class="gmail_default" style="font-family:"courier new",monospace">| |</div><div class="gmail_default" style="font-family:"courier new",monospace">| |___ source</div><div class="gmail_default" style="font-family:"courier new",monospace">| | |___ util.cpp</div><div class="gmail_default" style="font-family:"courier new",monospace">| |</div><div class="gmail_default" style="font-family:"courier new",monospace">| |___ CMakeLists.txt</div><div class="gmail_default" style="font-family:"courier new",monospace">|</div><div class="gmail_default" style="font-family:"courier new",monospace">|___ tool</div><div class="gmail_default" style="font-family:"courier new",monospace">
<div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| |___ include</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| | |___ tool</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| | |___ tool.h</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| |</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| |___ source</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| | |___ tool.cpp</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| |</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">| |___ CMakeLists.txt</div><div class="gmail_default" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">|</div>
</div><div class="gmail_default" style="font-family:"courier new",monospace">|___ app</div><div class="gmail_default" style="font-family:"courier new",monospace"> |___ app.cpp</div><div class="gmail_default" style="font-family:"courier new",monospace"> |</div><div class="gmail_default" style="font-family:"courier new",monospace"> |___ CMakeLists.txt</div><div class="gmail_default" style="font-family:"courier new",monospace"><br></div><div class="gmail_default"><font face="tahoma, sans-serif">Essentially this </font><span style="font-family:"courier new",monospace">repo</span><font face="tahoma, sans-serif"> contains static library </font><span style="font-family:"courier new",monospace">util</span><font face="tahoma, sans-serif">, shared library </font><span style="font-family:"courier new",monospace">tool</span><font face="tahoma, sans-serif"> and executable </font><span style="font-family:"courier new",monospace">app</span><font face="tahoma, sans-serif">.</font><br><br></div><div class="gmail_default"><font face="tahoma, sans-serif">Both executable </font><span style="font-family:"courier new",monospace">app</span><font face="tahoma, sans-serif"> and shared library </font><span style="font-family:"courier new",monospace">tool</span><font face="tahoma, sans-serif"> depend on static library </font><span style="font-family:"courier new",monospace">util</span><font face="tahoma, sans-serif">,</font></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif">but they don't depend on each other.</span></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif">This can be represented by dependency graph like so:</span></div><div class="gmail_default" style="font-family:"courier new",monospace"><br></div><div class="gmail_default"><div class="gmail_default" style="font-family:"courier new",monospace">app tool</div><div class="gmail_default" style="font-family:"courier new",monospace"> | |</div><div class="gmail_default" style="font-family:"courier new",monospace"> | |</div><div class="gmail_default" style="font-family:"courier new",monospace"> V V</div><div class="gmail_default" style="font-family:"courier new",monospace"> util</div><div style="font-family:"courier new",monospace"><br></div><div><font face="tahoma, sans-serif">The reason why static library <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span> is
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">placed </span><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">i</span><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">n the root of </span><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace">repo</span>,</font></div><div><font face="tahoma, sans-serif">is the fact that it's shared by both <font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">executable<span> </span></font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace">app</span><font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span> </span>and shared library<span> </span></font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace">tool</span><font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">.</font></font></div><div><font face="tahoma, sans-serif"><font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></font></font></div><div><font face="tahoma, sans-serif">Writing
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/util/CMakeLists.txt</span>
is very easy:</font></div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><div><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"><b>project(util)</b></font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace">add_library(util STATIC)</font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace">target_sources(util PRIVATE include/util/util.h</font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"> source/util.cpp)</font></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_include_directories(<wbr>util PUBLIC include)</span><br></div></div></div></blockquote><div class="gmail_default"><div><font face="tahoma, sans-serif"><br></font></div><div><font face="tahoma, sans-serif">However, implementing <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/tool/<wbr>CMakeLists.txt</span></font></div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><div><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"><br></font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><font face="monospace, monospace"><b># no project definition</b></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><font face="monospace, monospace"><br></font></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">add_library(tool SHARED)</span><br></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_sources(tool PRIVATE include/tool/tool.h</span><br></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"> source/tool.cpp)</font></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_include_directories(<wbr>tool PUBLIC include)</span><br></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_link_libraries(tool PRIVATE util)</span><br></div></div></div></blockquote><div class="gmail_default"><div><div style="font-family:tahoma,sans-serif"><br></div></div><div><font face="tahoma, sans-serif">and <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/app/CMakeLists.txt</span>
</font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="tahoma, sans-serif">is more challenging.</font></span></div><div style="font-family:tahoma,sans-serif"><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><div><font face="monospace, monospace">cmake_minimum_required (VERSION 3.11)</font></div></div></div><div class="gmail_default"><div><div><font face="monospace, monospace"><br></font></div></div><div><font face="monospace, monospace">
<b style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"># no project definition</b><br></font></div><div><font face="monospace, monospace"><br></font></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">add_executable(app)</span><br></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_sources(app PRIVATE app.cpp)</span><br></div></div></div><div class="gmail_default"><div><div><span style="font-family:monospace,monospace">target_link_libraries(app PRIVATE util)</span><br></div></div></div><div class="gmail_default"><div><div><br></div></div></div></blockquote><div class="gmail_default"><div><font face="tahoma, sans-serif">I understand CMake project as a set of targets, which are standalone (can be built by themselves).</font><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div><font face="tahoma, sans-serif">Source: <a href="https://stackoverflow.com/questions/26878379/in-cmake-what-is-a-project" target="_blank">https://stackoverflow.<wbr>com/questions/26878379/in-<wbr>cmake-what-is-a-project</a><br><br></font></div></div></blockquote><span style="font-family:tahoma,sans-serif">This meas that I can define project
</span><font face="courier new, monospace">util</font><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"> </font></div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">consisting </font></div><font face="tahoma, sans-serif">of one target (static library
</font><font face="courier new, monospace">util</font><span style="font-family:tahoma,sans-serif">)</span><span style="font-family:tahoma,sans-serif">,</span><div><span style="font-family:tahoma,sans-serif">because target </span><span style="font-family:"courier new",monospace">util</span><font face="tahoma, sans-serif"> doesn't have any dependencies</font><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">, meaning it's standalone.</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">Unfortunately defining project </font></div><div class="gmail_default" style="font-family:"courier new",monospace;display:inline">tool</div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"> and project <span style="font-family:"courier new",monospace">app</span>
is problematic,</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">because </font></div>
<font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">executable<span> </span></font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace"><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div>app</span><font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span> </span>and shared library<span> </span></font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace"><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div>tool</span><font face="tahoma, sans-serif" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span> </span><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div><div class="gmail_default" style="display:inline">do d</div><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div>epend on static library<span> </span></font><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace"><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div>util<div class="gmail_default" style="font-family:"courier new",monospace;display:inline"><span style="font-family:tahoma,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">.</span></div></span>
</div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace"><div class="gmail_default" style="font-family:"courier new",monospace;display:inline"><br></div></span></div><div><div class="gmail_default"><font face="tahoma, sans-serif">I found two solutions to this issue, but neither seems "correct" to me:</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif">1. Create </font>
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="courier new, monospace">//repo/CMakeLists.txt</font><font face="tahoma, sans-serif">
</font></span><font face="tahoma, sans-serif">and define project repo which will add <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span>, <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">tool</span>
and <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">app</span>
as sub-directories.</font></div></div></blockquote><div><div class="gmail_default" style="font-family:"courier new",monospace"><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">project(repo)</font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(util)</font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(tool)</font></div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(app)</font></div></div></div></blockquote></blockquote><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif">This is the cleanest solution, but it has a serious drawback of not defining project
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">app</span>
and project
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">tool</span>,<br>which could be built independently from each other.</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style="font-family:"courier new",monospace"><br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif">I thought that I will be able to mitigate this issue by<br>defining multiple projects in <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/CMakeLists.txt</span> each with its own separate set of targets.</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div></blockquote></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace">
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">cmake_minimum_required(VERSION 3.11)</span>
<br></font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace"><b>project(tool)</b></font></div></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>add_subdirectory(util)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>add_subdirectory(tool)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b><br></b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>project(app)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>add_subdirectory(util)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>add_subdirectory(app)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace">project(repo)</font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(util)</font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(tool)</font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace">add_subdirectory(app)</font><span style="font-family:"courier new",monospace"></span></div></blockquote></div></blockquote><div><font face="tahoma, sans-serif"><br></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="tahoma, sans-serif">T<div class="gmail_default" style="display:inline">his is not possible, since one CMakeLists.txt can define only single project and<br>calling add_subdirectory() twice on the same directory is an error.</div></font></div><div><font face="tahoma, sans-serif"><div class="gmail_default" style="display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">I believe these
<span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">constraints arise from the fact that</span><br><b style="font-size:small">CMake projects are not providing any scoping / grouping mechanism for targets.</b></span><br></div></font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">Source: <a href="https://cmake.org/pipermail/cmake/2009-June/030188.html" target="_blank">https://cmake.org/<wbr>pipermail/cmake/2009-June/<wbr>030188.html</a></font></div></div></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="tahoma, sans-serif">It is possible to create W/A mitigating this issue,</font></div><div class="gmail_default"><font face="tahoma, sans-serif">by using if(), elseif() and else() commands in
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/CMakeLists.txt</span>,</font></div><div class="gmail_default"><font face="tahoma, sans-serif">but this solution looks to me like an awful hack.</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><b>if(TOOL)</b></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">project(tool)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">add_subdirectory(util)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>add_subdirectory(tool)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace"><b>elseif(APP)</b></span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">project(app)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">add_subdirectory(util)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>add_subdirectory(app)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace"><b>else()</b></span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">project(repo)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace;white-space:pre-wrap"> </span><span style="font-family:monospace,monospace">add_subdirectory(util)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>add_subdirectory(tool)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>add_subdirectory(app)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><b>endif()</b></font></div></div></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="tahoma, sans-serif">Making matters worse this approach requires global handling of sub-directories in a project,<br>meaning that knowledge of the whole dependency graph is required to add sub-directories in correct order.</font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="tahoma, sans-serif">This breaks down the most desirable properties of modern CMake - modularity and isolation of targets.</font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><span style="font-family:tahoma,sans-serif"><br></span></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif">2. Define project as a self-containing set of targets by adding sub-directories were they are required.</span><br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></div><div class="gmail_default"><font face="tahoma, sans-serif"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">In this approach </span><span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">/</span><span style="font-family:"courier new",monospace;font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">/repo/tool/CMakeLists.txt</span><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline"> would add upper directory <span style="font-family:"courier new",monospace;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util<br></span>by defining not only source directory, but also binary directory.</span><br></font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace"><b>project(tool)</b></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><span style="font-family:monospace,monospace"><b>add_subdirectory(../util util)</b></span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace">add_library(tool SHARED)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><span style="font-family:monospace,monospace">target_sources(tool PRIVATE include/tool/tool.h</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace"> source/tool.cpp)</font></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><span style="font-family:monospace,monospace">target_include_directories(<wbr>tool PUBLIC include)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><span style="font-family:monospace,monospace">target_link_libraries(tool PRIVATE util)</span><br></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><br></div></blockquote></blockquote><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style=""><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="tahoma, sans-serif">Using the exact same technique </font><font face="courier new, monospace">/</font></span><span style="font-family:"courier new",monospace;font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">/repo/app/CMakeLists.txt</span><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline"><font face="tahoma, sans-serif"> would also add upper directory </font></span><span style="font-family:"courier new",monospace;font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">util</span><span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline"><font face="tahoma, sans-serif">.</font></span><br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="courier new, monospace"><br></font></div></div></blockquote></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><font face="monospace, monospace">cmake_minimum_required (VERSION 3.11)</font></div></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><b>project(app)</b></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><span style="font-family:monospace,monospace"><b>add_subdirectory(../util util)</b></span><br></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="monospace, monospace">add_executable(app)</font></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><span style="font-family:monospace,monospace">target_sources(app PRIVATE app.cpp)</span><br></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><span style="font-family:monospace,monospace">target_link_libraries(app PRIVATE util)</span><br></div></blockquote></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div></blockquote></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">This approach allows each project to be stand-alone,</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">because all sub-directories required by targets directly defined by that project are added directly in place.</font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><br>This is huge advantage compared to the first solution,<br></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">because project is responsible only for adding sub-directories,<br></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="tahoma, sans-serif"><div class="gmail_default" style="display:inline"></div>which are required by direct dependencies of <div class="gmail_default" style="font-family:"courier new",monospace;display:inline"></div>targets defined<div class="gmail_default" style="display:inline"> </div><div class="gmail_default" style="display:inline">directly </div>in that project.</font></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><br></font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">All sub-directories required for satisfying project's indirect dependencies<br>will be added automatically by projects defining targets,<br>which are direct dependencies of
<div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace;display:inline"></div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">targets defined</span><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline"> </div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline">directly </div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">in that project</span>.</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><br></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">For example, if target
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span>
would depend on target <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">foo</span>,<br>then in project <span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace;background-color:rgb(255,255,255);float:none;display:inline">util</span> sub-directory
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">foo</span>
would be added to satisfy that dependency.</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><br></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace"><br></font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace">project(util)</font></div></div></div></font></div></div></blockquote></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><font face="monospace, monospace"><b>add_subdirectory(../foo foo)</b></font></div></div></font></div></div></blockquote></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace"><br></font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace">add_library(util STATIC)</font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace">target_sources(util PRIVATE include/util/util.h</font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><font face="monospace, monospace"> source/util.cpp)</font></div></div></div></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><div><span style="font-family:monospace,monospace">target_include_directories(<wbr>util PUBLIC include)</span></div></div></div></font></div></div></blockquote></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><span style="font-family:monospace,monospace"><b>
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">target_link_libraries(util PRIVATE foo)</span></b>
</span></div></div></font></div></div></blockquote></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">
<br></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">So in case of <span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;font-family:"courier new",monospace;background-color:rgb(255,255,255);float:none;display:inline">app</span><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> </span>project <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span>
sub-directory would be added first,<br>then <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">foo</span> sub-directory would be added by the
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span>
project.<br>Effectively adding sub-directory will create a cascade of add_subdirectory() commands,</font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">meaning that sub-directories would be added transitively.<br><br></font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">This approach doesn't require knowledge of the whole dependency graph - just direct dependencies are needed to be known.</font></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_default" style=""><font face="tahoma, sans-serif">Now </font><span style="font-family:tahoma,sans-serif">targets can be modular and isolated, which is what modern CMake is all about.</span></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div><div><br></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_default" style=""><font face="tahoma, sans-serif">Unfortunately t</font><font face="tahoma, sans-serif">his approach has major flaw - it doesn't allow sharing libraries between targets.</font></div><div class="gmail_default" style=""><font face="tahoma, sans-serif">It's a trap giving false illusion, </font><span style="font-family:tahoma,sans-serif">that knowledge</span><span style="font-family:tahoma,sans-serif"> of whole dependency graph is not required.</span></div><div class="gmail_default" style=""><span style="font-family:tahoma,sans-serif"><br></span></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_default" style=""><font face="tahoma, sans-serif">Consider adding </font>
<span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">repo</span><font face="tahoma, sans-serif">
project in </font><span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">//repo/CMakeLists.txt</span><span style="font-family:tahoma,sans-serif">.</span></div><div class="gmail_default" style=""><span style="font-family:tahoma,sans-serif"><br></span></div><div class="gmail_default" style=""><span style="font-family:tahoma,sans-serif">
<blockquote style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">cmake_minimum_required(VERSION 3.11)</font></div></div></div></blockquote><blockquote style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><br></font></div></div></div></blockquote><blockquote style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><b>project(repo)</b></font></div></div></div></blockquote><blockquote style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><b><span style="font-family:monospace,monospace">add_subdirectory(tool)</span><br></b></div></div></blockquote><blockquote style="font-family:arial,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;margin:0px 0px 0px 40px;border:none;padding:0px"><div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"><b>add_subdirectory(app)</b></font></div></div></div></blockquote>
</span></div><div class="gmail_default" style=""><span style="font-family:tahoma,sans-serif"><br></span></div><div class="gmail_default" style="">
<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="tahoma, sans-serif">This will immediately fail,<br>because directory <span style="font-family:"courier new",monospace;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">util</span>
will be added twice
<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">- first time by project <span style="font-family:"courier new",monospace;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">tool</span>
and second time by project
<span style="font-family:"courier new",monospace;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">app</span>.</span></font></span><br>Essentially in this approach projects cannot share libraries,<br>because it is required to
<span style="font-family:tahoma,sans-serif;font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">control globally how sub-directories are added</span>
to make sure that they are added exactly once.</div></blockquote><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"><br></font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">Considering that both solutions feels like complete failures,</font></div></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif">what is recommended way of implementing CMake build system in described repository?</font></div></div><div><span style="font-family:tahoma,sans-serif"><br></span></div><div><span style="font-family:tahoma,sans-serif">Am I missing something or CMake legitimately lacks mechanisms</span><span style="font-family:tahoma,sans-serif"> for handling this case properly?</span><br></div><div><div class="gmail_default" style="display:inline"><font face="tahoma, sans-serif"></font></div></div><div><div class="gmail_default"><font face="tahoma, sans-serif">Honestly it's hard to believe that CMake would lack support for this case,<br>considering this is such a widely used and flexible build system.</font></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif"><br></span></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif">I would really appreciate</span><span style="font-family:tahoma,sans-serif"> help with solving this issue. :-)</span></div><div class="gmail_default"><font face="tahoma, sans-serif">Thank you, Mateusz Zych</font></div></div></div>