cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

k-channon-PA opened this issue · comments

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  "git@company.internal.gitserver"
)

# 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.