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

Users in enterprise environments require the ability to add custom URI schemes and override standard URI schemes #564

Open
k-channon-PA opened this issue Jun 9, 2024 · 0 comments

Comments

@k-channon-PA
Copy link

k-channon-PA commented Jun 9, 2024

TL;DR

As a user of CPM in a corporate environment
I would like to be able to override the URIs and extensions used for single- and multi-argument versions of CPMAddPackage
So that I can use CPM behind my company firewall and use our internal repos, mirrors and binary stores

Here's a CPM fork that has an implementation of this proposal in it: https://github.com/k-channon-PA/CPM.cmake

(Disclaimer: this is my first complicatd CMake thing, so it might not conform to the CPM best practices entirely. I did use the formatter thing though :) )

Proposed syntax

The syntax for adding/overriding a URI scheme would look like:

# An internal git repo
CPMDefineUriScheme(
  ALIAS  "ir"
  LONG_NAME  "INTERNAL_REPO"
  URI_TYPE  "GIT_REPOSITORY"
  URI_ROOT  "[email protected]"
)

# An Artifactory repo, where we might store binary things of some sort
# For example, zipped archives of package sources for release
cpmdefineurischeme(
  ALIAS  "af"
  LONG_NAME  "ARTIFACTORY_PKG"
  URI_TYPE  "URL"
  URI_ROOT  "https://my.company.artifatory/pkgs"
)

Then packages could be added via a single argument call to CPMAddPackage like:

CPMAddPackage("af:somegroup/someitem#SHA256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")

Or, a multi-arg call like:

CPMAddPackage(
NAME  "someName"
INTERNAL_REPO  "somegroup/somerepo
VERSION  "0.20.3"
GIT_TAG  "asdf"
)

If a scheme with the same alias is already defined, then it should be overwritten with the new value. In this way, I can redirect all "gl" packages to our internal repository mirror, instead of the one on the public internet.

I added some tests for the single-argument case that exercise a bunch of dummy use-cases. I heven't yet added anything to the "examples" directory, because that looked like a bit more work and I wanted to get some feedback on the implementation and idea before taking some more time on it.

Why not just use Git config to redirect URLs from the public to our internal repos?

Doing this interferes with other things using Git that are not CPM. I would like the flexibility to control the behaviour of CPM in isolation.

In an enterprise environment, everything requires credentials to access it. I think the proposed mechanism could be extended allow us to provide custom HTTP_HEADER arguments when defining URI schemes. This means that I can provide use creds/tokens for accessing internal Bitbucket, or Artifactory servers, etc.

k-channon-PA added a commit to k-channon-PA/CPM.cmake that referenced this issue Jun 10, 2024
…some logic; Make updated cpm_parse_add_package_single_arg have behaviour more consistent with the pre-user-definable-uri-schemes version (cpm-cmake#564)
k-channon-PA added a commit to k-channon-PA/CPM.cmake that referenced this issue Jun 10, 2024
k-channon-PA added a commit to k-channon-PA/CPM.cmake that referenced this issue Jun 17, 2024
…some logic; Make updated cpm_parse_add_package_single_arg have behaviour more consistent with the pre-user-definable-uri-schemes version (cpm-cmake#564)
k-channon-PA added a commit to k-channon-PA/CPM.cmake that referenced this issue Jun 17, 2024
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

1 participant