I'm not sure about the best approach for larger cmake projects with submodules and an executable to use those modules.
Solution 1:
foo/ # project root directory
- CMakeLists.txt
- build/
- executable/
-- CMakeLists.txt # call to add_executable
-- include/
-- src/
-- test/
- modules/
-- core/
--- CMakeLists.txt # call to add_library
--- include/
---- core/ # interface of core module
--- src/
--- test/
-- utils/
--- CMakeLists.txt # call to add_library
--- include/
---- utils # interface of utils module
--- src/
--- test/
Creating different targets for each module allows for easy reuse of modules in other projects.
But now it is hard/uggly to associate a module with a project an allowing includes like #include "foo/core/..."
or even a whole project interface like #include "foo/foo.hpp"
Solution 2:
foo/ # project root directory
- CMakeLists.txt
- build/
- executable/
-- CMakeLists.txt # call to add_executable
-- include/
-- src/
-- test/
- modules/
-- CMakeLists.txt # call to add_library
-- include/ # interface of the whole module
--- core/ # interface of core module
--- utils/ # interface of utils module
-- src/
--- core/
--- utils/
-- test/
With this approach, the problems with the module interface are solved but the reuse of certain modules becomes picky copy-paste work.
Which structure do you prefer?
Do you use a completely different structure to manager larger projects?