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

Variables to manage default repositories URLs #528

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

Conversation

fregate
Copy link

@fregate fregate commented Dec 13, 2023

Add ability of changing default URLs to use with CPMAddPackage GITHUB_REPOSITORY, GITLAB_REPOSITORY, BITBUCKET_REPOSITORY parameters

For example your project depends on a library that use CPM to download self dependencies. And if your build server hasn't internet connection for security reasons, you have to clone and patch the library, and use custom hashes or tags.

But if you can organize your local sever repositories properly, you can just change default urls and it will work.

Local Gitlab example:
Create space(group) thirdparty, and add, for example, fmtlib/fmt there (import fmt project). So local path will like: https://git.localserver/thirdparty/fmtlib/fmt.git

Now you can use local or original repository:

cmake_minimum_required(VERSION 3.20)
project(CPMT)
set(PRJ_TARGET cpmt)

# use local server. comment to use original fmt repo
set(CPM_GITHUB_REPOSITORY_URL "git.localserver/thirdparty")
# or get_cpm.cmake, if it contains these changes
include(CPM.cmake)

CPMAddPackage(
    NAME fmt
    GIT_TAG 10.1.1
    GITHUB_REPOSITORY fmtlib/fmt
)

add_executable(${PRJ_TARGET}
	main.cpp
)

target_link_libraries(${PRJ_TARGET}
	fmt
)

or pass CPM_GITHUB_REPOSITORY_URL with cmake command args in build system

…Y, GITLAB_REPOSITORY, BITBUCKET_REPOSITORY parameters
@TheLartians
Copy link
Member

Hey, thanks for the PR, I can see how this can be useful in secure contexts!

However, I don't think this is the right place to add more customisation options, as IMO this can be handled more elegantly on the system level using Git URL rewriting as shown in the Readme. This will have the additional advantage that it applies system wide and not only to CPM.cmake projects using the shorthand syntax.

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