0

I have the following project form (in Visual Studio terminology):

  • MainProject solution
    • MainProjectA Project
    • MainProjectB Project
  • Plugin1 solution
    • Plugin1A Project
    • Plugin1B Project
  • Plugin2 solution (and the projects...)

Now, if I try to "convert" this terminology to CMake it would be (I think):

  • MainProject project (using "project()")
    • MainProjectA target (set by add_library(), add_executable() or add_custom_target())
    • MainProjectB target
  • Plugin1 project
    • Plugin1A target
    • Plugin1B target
  • Plugin2 project... (and the targets...)

It is important to point out, each "project/solution" has its own installer (i.e. DEB, MSI, PKG) created by CPack.


Is it possible to create the above multi-level CMake project (i.e. Having another level "above" "CMake project"/"VS solution")?

If it is possible, what is the correct/standard way to define/structure it? Do notice, each "project/solution" has its own installer (created with CPack).

I prefer this kind of structure as the different projects/solutions share configurations, and I don't want to replicate the configurations across the different projects.

I would prefer to avoid "ExternalProject_Add", but having a multi-level "tree" - if it is possible.

starball
  • 20,030
  • 7
  • 43
  • 238
TCS
  • 5,790
  • 5
  • 54
  • 86
  • 1
    Question with some relevance: [How to specify CMake Preset for subdirectories?](/q/75165228/11107541) – starball Mar 08 '23 at 06:41

1 Answers1

0

If the problem you're trying to solve is that the two buildsystems tend to share buildsystem configuration variables, you can solve the problem by creating a presets file and sharing it between them. The include field can help with this sharing.

I don't know how this would work with CPack since I've never done this myself, but you can also create a CMakeLists.txt in the common parent directory and in that CMakeLists.txt, declare a project() and add_subdirectory() the two sub-projects.

starball
  • 20,030
  • 7
  • 43
  • 238