<div dir="ltr">Have you looked into ExternalProject_Add? It allows just using a local path instead of downloading a remote repository:<div><br></div><div><a href="https://cmake.org/cmake/help/latest/module/ExternalProject.html">https://cmake.org/cmake/help/latest/module/ExternalProject.html</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 8, 2016 at 12:12 PM, Muhammad Osama <span dir="ltr"><<a href="mailto:osama94@gmail.com" target="_blank">osama94@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">Hi Jan,</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">Thank you for your reply, I am in the similar situation, have a very similar implementation using <b>target_*** </b>but since I don't do that for ALL the dependencies, I am unable to cmake or compile individual projects in the sub directories. So, few questions;</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">1. This still requires me to run cmake on the root CMakeLists.txt to set the flags and what not before I run the sub project to make it correct?</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">1a. If so, how can I make the CMakeLists.txts in the sub directories independent of the root one if I want to just compile the sub-project and not cmake the whole thing?</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">2. Another question is that your implementation, does it not include a config file? In theory you're copy pasting most of the dependencies in the CMakeLists.txt of root into the sub-dir ones? Is there a better way to do this?</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;font-size:small;color:#000000">Thank you!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 8, 2016 at 2:02 AM, šŸ‹ Jan Hegewald <span dir="ltr"><<a href="mailto:jan.hegewald@awi.de" target="_blank">jan.hegewald@awi.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Muhammad,<br>
<span><br>
> On 08.03.2016, at 06:17, Muhammad Osama <<a href="mailto:osama94@gmail.com" target="_blank">osama94@gmail.com</a>> wrote:<br>
><br>
> Hi, I am new to cmake and really hope am doing this correctly. I asked stackoverflow but didn't get a good enough answer for my specific problem here;<br>
><br>
> If I want root/sub-directories/ as separate sub-projects that can be compiled using the individualCMakeLists.txts in their folders I find myself literally copy pasting almost the entire root file CMakeLists.txt per sub-directory.<br>
><br>
> I was wondering if there is a better way to have a main project and then sub-projects that get the shared dependencies from main project and can be compiled without cmake-ing the root CMakeLists.txt. My directory structure is;<br>
><br>
> CMakeLists.txt (root project)<br>
> | __ sub_dir-1<br>
> | __ | __ CMakeLists.txt (sub-project)<br>
> | __ sub_dir-2<br>
> | __ | __ CMakeLists.txt (sub-project)<br>
> | __ sub_dir-3<br>
> | __ | __ CMakeLists.txt (sub-project)<br>
<br>
</span>I basically have the same project structure as you describe. I am also not sure what the best practice is here, but this is what I currently do:<br>
I set all dependencies where they are required: right in the local CMakeLists.txt, i.e. sub_dir-1/CMakeLists.txt. Then "export" all required include/define/compiler flags dependencies via INTERFACE or PUBLIC flags of the various target_*** cmake functions, as appropriate. The sub-projects are added via add_subdirectory in cmake.<br>
This way I can build each CMakeLists.txt individually if needed but still have everything DRYish.<br>
<br>
HTH,<br>
Jan<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div style="text-align:center"><div style="text-align:start"><font face="trebuchet ms, sans-serif"><i>Muhammad Osama</i></font><div><font face="trebuchet ms, sans-serif">Graduate Student</font></div><div><font face="trebuchet ms, sans-serif">Department of Electrical and Computer EngineeringĀ </font></div><div><font face="trebuchet ms, sans-serif">University of California, Davis</font><br></div></div></div></div></div></div></div></div>
</font></span></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>