Hi Jan, Thank you for your reply, I am in the similar situation, have a very similar implementation using *target_*** *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;
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? 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? 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? Thank you! On Tue, Mar 8, 2016 at 2:02 AM, 🐋 Jan Hegewald <jan.hegew...@awi.de> wrote: > Hi Muhammad, > > > On 08.03.2016, at 06:17, Muhammad Osama <osam...@gmail.com> wrote: > > > > 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; > > > > 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. > > > > 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; > > > > CMakeLists.txt (root project) > > | __ sub_dir-1 > > | __ | __ CMakeLists.txt (sub-project) > > | __ sub_dir-2 > > | __ | __ CMakeLists.txt (sub-project) > > | __ sub_dir-3 > > | __ | __ CMakeLists.txt (sub-project) > > 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: > 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. > This way I can build each CMakeLists.txt individually if needed but still > have everything DRYish. > > HTH, > Jan > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake > -- *Muhammad Osama* Graduate Student Department of Electrical and Computer Engineering University of California, Davis
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake