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

if version=latest, use the last tagged version in repository #468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

d-e-e-p
Copy link

@d-e-e-p d-e-e-p commented Apr 15, 2023

eg:

CPMAddPackage(
  NAME fibonacci
  GIT_REPOSITORY https://github.com/cpm-cmake/testpack-fibonacci.git
  VERSION latest
)

motivation:

this is common case for our setup, where for modules like gh:TheLartians/PackageProject.cmake , we just want to pickup the latest version. so i asked chatGPT:
prompt: how to download the latest tag of a package with CPMAddPackage
answer:

include(cmake/CPM.cmake)

CPMAddPackage(
  NAME <package_name>
  VERSION *
)

bing AI had something similar to say, so anyway I think this would be a useful enhancement.

repository, eg:

CPMAddPackage(
  NAME fibonacci
  GIT_REPOSITORY https://github.com/cpm-cmake/testpack-fibonacci.git
  VERSION latest
)
@TheLartians
Copy link
Member

Hey, thanks for the PR! I agree that being able to specify the latest version or even better, a version range (see #99), would be awesome and this PR could be setting some of the groundwork for that.

However we need to be careful with such a feature as it can result in broken projects if not implemented properly. E.g. if at some point breaking changes are introduced to PackageProject.cmake, all projects depending on the "latest" version would break. Therefore any implicit versioning feature would also need to use a package locking mechanism where the resolved version would be automatically placed and updated in the package lock file.

Let me know if you want to take on the locking mechanism as well, and need any pointers for that. Otherwise I'd hold off with merging this PR until a suitable mechanism is implemented.

@d-e-e-p
Copy link
Author

d-e-e-p commented Apr 18, 2023

version ranges would be very useful for any project following semantic versioning:

CPMAddPackage("gh:google/[email protected].*")

or

CPMAddPackage("gh:google/benchmark@1.*")

anyway it might be useful to fetch available versions of a tool anyway for diagnostic messages on version mismatch.

by locking do you mean something like this?
https://docs.gradle.org/current/userguide/dependency_locking.html

@TheLartians
Copy link
Member

by locking do you mean something like this?

Yes that or similar to the package-lock.json used by npm. In fact we already have a rudimentary package lock setup, however there is currently no automation to keep it in sync with changing dependency versions in the CMakeLists, which would be needed for this feature.

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

Successfully merging this pull request may close these issues.

2 participants