I'm quite new to CMake, and me and my colleagues decided on using it in some project we're developing. In this work, everybody is responsible for some module of the project. The layout is as follows:
ROOT
-> Module1
...
-> Module2 (depends on Module 1)
...
-> Module3 (depends on Module 2 and 1)
Each ModuleN
has its own CMakeLists.txt
file and must be able to be compiled, tested, and finished before they can be put together into the whole project. Now, I'm quite confused about what approach to use to make those dependencies work.
My research showed me some ways (like adding add_directory
directives, etc.), but some of them complained that this way the projects can be compiled many times unnecessarily (like Module1
in this example); or requires a full path to be given.
The project won't be installed to the target machine, so I cannot use system library folders, includers, etc. either. Every developer has this repository in different folders, so I cannot give "exact" folders either. Can I use a syntax like "../Module1" for the add_directory
command? Would this cause "unnecessary builds" as told?
Also, people usually recommend putting a CMakeLists.txt
file in the root of the project as well, but I think this way we always have to build from the root directory - so modules cannot be built and tested separately.
What is the "noob way" to make this possible? As I said, I'm quite new to CMake, and honestly I don't even know the "keyword" to search for such a thing (searching "adding dependency" brings some results that I am simply drowned in :) )