Reputation: 539
I'm new to CMake and re-learning C++, so I hope these are appropriate questions. I have a project in directory /projects/A and some .h files in /projects/include/open-source-project-1 that the A project depends on.
Sample Hierarchy: /projects /CMakeLists.txt /A /CMakeLists.txt /a.cpp /B /CMakeLists.txt /include /open-source-project-1 /includeMe.h /open-source-project-2
Upvotes: 2
Views: 1555
Reputation: 25677
Your top-level CMakeLists.txt
file is not needed unless all of the projects are directly inter-related somehow or have otherwise unresolvable dependencies. Unrelated projects should not include each other, nor do they need a parent list file.
If A and B are separate projects, ./A/CMakeLists.txt
and ./B/CMakeLists.txt
should contain at least this line:
include_directories(../include)
Otherwise, if A and B are parts of a larger single project, then it is appropriate to put these lines in the top-level CMakeLists.txt
files:
include_directories(include)
add_subdirectory(A)
add_subdirectory(B)
Only for separate projects. One invocation of cmake
will create one build tree. One project to a build tree is all you need.
add_subdirectory
directive will it affect the other list files.Upvotes: 3