Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPM on monorepos #535

Open
gshanemiller opened this issue Jan 25, 2024 · 1 comment
Open

CPM on monorepos #535

gshanemiller opened this issue Jan 25, 2024 · 1 comment

Comments

@gshanemiller
Copy link

gshanemiller commented Jan 25, 2024

CPM's ability to fetch dependencies from Github is cool, and something I will eventually get to. I also like there's no need for 61 million helper files like conan or vpkg.

However, in the present case I have a large mono repository ~25 million lines of C/C+ code. This repository has ~250 libraries all inside the repo. As such there is no need to fetch from Github. The libraries are organized with a canonical layout that makes it easy to scan and discover.

Here's what I want to do:

  • run a script (that I will provide) to scan the libraries
  • from each library create CPM cmake code for that library and its dependencies. Dependencies, say lib_network depends on lib_network_async will come from meta data I provide
  • use the output of the previous bullet to autogenerate a Cmakefile with CPM CPMAddPackage commands
  • logically extend dependencies in CMakeLists.txt for all the tasks, unit tests, integration tests
  • cmake to build

Desired impact:

  • Other than manually specifying the dependencies between libraries in a meta-file, the full CMakeLists.txt file is auto-built
  • Later I can move individual libraries to Github while keeping the overall process and structure unchanged

Now this will require a CPMAddPackage to understand a dependency is not in github, but rather it's in a directory tree.

Once I have that I can move individual libraries into their own Git repo and revert to CPMAddPackage with Githib urls.

Feasible? My guess: this is not a good use-case since CMake does this out of the box.
Rather once libraries are migrated to standalone Git repos then CPM is well suited.

Meanwhile I'll read your https://gitlab.com/external-packages/cpm.cmake carefully.

Regards!

@TheLartians
Copy link
Member

If I understand correctly, your plan is to replace add_subdirectory with CPM calls to treat the subdirectories as individual projects and be able to migrate easier in the future? In that case, yes this is common and a very much supported use-case with CPM, using the SOURCE_DIR option. See here for an example how to include a directory relative to the current CMakeLists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants