Replies: 2 comments
-
Note that this suggestion seems very similar to a suggestion in #213. I definitely see how the package repository can make maintaining a project's dependencies easier. One thing I don't like is that versions are now interdependent, so if you want to update a single package through the repository any dependencies are now updated as well - the repository essentially becomes a static package-lockfile for your project. Also, it will need constant updates from maintainers to support the newest versions. Personally I think an automated package registry like npm, pip or cargo might be a better solution here. This could be an online database where we could query the CPM.cmake command for each version of each package. It could take a bit more work to setup, but imo would pay off down the road in more flexibility and less maintenance effort. |
Beta Was this translation helpful? Give feedback.
-
this is my small (bad?) solution https://github.com/flagarde/CMakeMM / based on (rewritten) https://github.com/vector-of-bool/CMakeCM |
Beta Was this translation helpful? Give feedback.
-
Say we have a function
CPMAddPackageRepository
which takes a single string argument. If it looks like a local filesystem path, then it's interpreted as a directory. If it looks like a an url to an archive, then it's downloaded and extracted by FetchContent and the resulting directory is used.This directory is expected to have multiple
.cmake
files, say likecpmpack-name.cmake
. Where each is a recipe for a package (typically a single line likeCPMAddPackage(NAME foo GITHUB_REPOSITORY user/foo VERSION 1.2.3)
)Then calling
CPMAddPackage
with a string which is a single word (no spaces, no directory separators) would search forcpmpack-<that word>.cmake
in the provided repository directories and include it if found.The last step could be a bit unpleasant as it would lead to a recursive call to
CPMAddPackage
, but if we don't like it, we may introduce another functionCPMAddRepoPackage
, or perhaps something even shorter like justCPM
CPMAddPackageRepository(https://github.com/cpm-cmake/official-repo/releases/download/v2.12.4/cpm-official.zip) CPMAddPackageRepository(${CMAKE_CURRENT_SOURCE_DIR}/local-packages) cpm(boost) cpm(glfw) cpm(imgui) cpm(my-assets) cpm(my-toolchain)
Beta Was this translation helpful? Give feedback.
All reactions