[CMake] Fwd: Create main and sub-projects; be able to compile them together and individually.
Muhammad Osama
osama94 at gmail.com
Tue Mar 8 00:17:39 EST 2016
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)
...
Essentially, I want to be able to:
1.
cmake root/CMakeLists.txt, which creates an entire project that includes
the sub-projects (I already have this implemented using individual
CMakeLists.txts inside sub-directories.
2.
cmake root/sub-dir/CMakeLists.txt and only compile the sub-project, which
essentially also finds the necessary dependencies and includes them from
maybe .cmake includes or root/CMakeLists.txt. What is the best way to
approach this structure;
while retaining the first bullet point of having the ability to compile it
as an entire project.
And also not crowding the sub-dir/CMakeLists.txt too much with redundant
code?
Appreciate any suggestions! Thank you.
--
Muhammad Osama
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160307/9ef13acf/attachment.html>
More information about the CMake
mailing list