From 8b6a7f2777fa705a26545b96cf5ec8661717303f Mon Sep 17 00:00:00 2001 From: Anton Filippov Date: Wed, 13 Dec 2023 17:45:39 +0700 Subject: [PATCH] Way to change default URLs to use with CPMAddPackage GITHUB_REPOSITORY, GITLAB_REPOSITORY, BITBUCKET_REPOSITORY parameters --- cmake/CPM.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index f4d0eea4..9570d497 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -150,6 +150,18 @@ set(CPM_DRY_RUN OFF CACHE INTERNAL "Don't download or configure dependencies (for testing)" ) +set(CPM_GITHUB_REPOSITORY_URL + "github.com" + CACHE INTERNAL "" +) +set(CPM_GITLAB_REPOSITORY_URL + "gitlab.com" + CACHE INTERNAL "" +) +set(CPM_BITBUCKET_REPOSITORY_URL + "bitbucket.org" + CACHE INTERNAL "" +) if(DEFINED ENV{CPM_SOURCE_CACHE}) set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE}) @@ -561,11 +573,11 @@ function(CPMAddPackage) endif() if(DEFINED CPM_ARGS_GITHUB_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git") + set(CPM_ARGS_GIT_REPOSITORY "https://${CPM_GITHUB_REPOSITORY_URL}/${CPM_ARGS_GITHUB_REPOSITORY}.git") elseif(DEFINED CPM_ARGS_GITLAB_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git") + set(CPM_ARGS_GIT_REPOSITORY "https://${CPM_GITLAB_REPOSITORY_URL}/${CPM_ARGS_GITLAB_REPOSITORY}.git") elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY) - set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git") + set(CPM_ARGS_GIT_REPOSITORY "https://${CPM_BITBUCKET_REPOSITORY_URL}/${CPM_ARGS_BITBUCKET_REPOSITORY}.git") endif() if(DEFINED CPM_ARGS_GIT_REPOSITORY)