-
Notifications
You must be signed in to change notification settings - Fork 189
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
Allow defining custom prefixes #445
base: master
Are you sure you want to change the base?
Conversation
Hey thanks for the PR! Changes look good to me though I'd like an additional opinion from @iboB as he authored the original feature. Could you also format the code using according to the styleguides? |
30aae82
to
f584566
Compare
In addition to the predefined prefixes 'gh', 'gl' and 'bb', allow defining your own prefixes for, e.g. internal hosts.
f584566
to
4f59373
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have several problem with this as it seems kinda incomplete. I'm not sure whether we want to pursue a more "complete" feature with this.
- I'm not sure I like the name "prefix" in this case. Maybe schemes?
- As I said, I don't like the addition of
CUSTOM_REPOSITORY
. The entire uri is contained in the long-form anyway. AddingCUSTOM_REPOSITORY
to split in in parts seems redundant and unneeded. CPM_CUSTOM_PREFIXES
seems to imply git. This is easily fixable as we have tools to detect the type of the repo based on the uri. Alternatively it should beCPM_CUSTOM_GIT_REPO_PREFIXES
- These are prefixes only. So if I wanted to add my custom GitLab instance I would have to manually add .git at the end of the uris, like:
CPMAddPackage(my:foo/[email protected]) # :(
CPMAddPackage(gh:foo/[email protected]) # :)
I can't think of a good way to fix this. Something like CPM_CUSTOM_SUFFIXES
perhaps?...
foreach(prefix ${CPM_CUSTOM_PREFIXES}) | ||
if("${prefix}" MATCHES "([^:]+):(.+)") | ||
if(scheme STREQUAL "${CMAKE_MATCH_1}") | ||
set(out "GIT_REPOSITORY;${uri};CUSTOM_REPOSITORY;${CMAKE_MATCH_2}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why introduce CUSTOM_REPOSITORY
at all? It seems somewhat redundant to me
Why not concat the string here: "GIT_REPOSITORY;${CMAKE_MATCH_2}/${uri}"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I didn't knew it better. This was the first time I fiddled with CMake functions.
Here's how I would do it: CPMAddCustomScheme(
c1 # scheme name
PREFIX https://c1.example.com/ # optional
SUFFIX .git # optional
TYPE GIT_REPOSITORY # optional. if not specified, tries to infer the type from the composed uri
)
# ...
CPMAddPackage(c1:foo/[email protected]) # :) If this is implemented, the existing default schemes can be added to the same underlying lists that this is using. It can even allow overriding of existing schemes and some of the functionality requested in #333 |
This looks definitely better than my attempt. I already had the feeling that a generic way of implementing this should somehow be possible. Time for diving deeper into the CMake documentation ... Shall I close the PR and start anew, or just keep it open and work on it (will definitely take its time)? |
Awesome! It's great that you want to invest more in this
I have no special opinion on the matter. However you prefer |
I think this change has really useful potential, something I had considered as would simplify setup with enterprise servers. Ideally all the existing prefix/schema types should be migrated to use this mechanism imho. Partly as a basis of solid testing to harden the design but also as it may be desirable to modify existing behavior on the pre-existing schemas! For example, I was considering allowing to provision alternative server addresses or fallbacks when the primary are not accessible e.g. EDIT: I should note I haven't thought much on the example as I think it falls more into ExternalProject functionality to have alternatives for GIT as it does for URL downloads:
|
Would this MR #528 be a the simpler solution for your problem? |
I just implemented a similar thing to this... and then checked the open PRs only to find this one! This feature would really help me out. I'm happy to help get this PR completed if that'a any use to you guys :) |
In addition to the predefined prefixes 'gh', 'gl' and 'bb', allow defining your own prefixes for, e.g. internal hosts.