Skip to content

Commit 77e8607

Browse files
authored
ver 3.4 allow override CPM location (#6)
1 parent 9572b5e commit 77e8607

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

cmake/getCPM.cmake

+21-13
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,27 @@
3535
# set(CPM_DOWNLOAD_VERSION 0.40.2) set(CPM_HASH_SUM
3636
# "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")
3737

38-
if(CPM_SOURCE_CACHE)
39-
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
40-
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
41-
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
42-
else()
43-
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
38+
if(NOT DEFINED CPM_DOWNLOAD_LOCATION AND NOT DEFINED ENV{CPM_DOWNLOAD_LOCATION})
39+
if(CPM_SOURCE_CACHE)
40+
set(CPM_DOWNLOAD_LOCATION
41+
"${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
42+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
43+
set(CPM_DOWNLOAD_LOCATION
44+
"$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
45+
else()
46+
set(CPM_DOWNLOAD_LOCATION
47+
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
48+
endif()
49+
50+
# Expand relative path. This is important if the provided path contains a
51+
# tilde (~)
52+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION}
53+
ABSOLUTE)
54+
55+
file(DOWNLOAD
56+
https://raw.githubusercontent.com/Arniiiii/CPM.cmake/main/cmake/CPM.cmake
57+
${CPM_DOWNLOAD_LOCATION} # EXPECTED_HASH SHA256=${CPM_HASH_SUM}
58+
)
4459
endif()
4560

46-
# Expand relative path. This is important if the provided path contains a tilde (~)
47-
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
48-
49-
file(DOWNLOAD https://raw.githubusercontent.com/Arniiiii/CPM.cmake/main/cmake/CPM.cmake
50-
${CPM_DOWNLOAD_LOCATION} # EXPECTED_HASH SHA256=${CPM_HASH_SUM}
51-
)
52-
5361
include(${CPM_DOWNLOAD_LOCATION})

0 commit comments

Comments
 (0)