Skip to content

Commit b643fde

Browse files
committed
make CPM_DOWNLOAD_LOCATION overridable
1 parent d5ae6e1 commit b643fde

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

test/transitive_dependency/cmake/CPM.cmake

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
set(CPM_DOWNLOAD_VERSION 0.35.0)
2-
3-
if(CPM_SOURCE_CACHE)
4-
# Expand relative path. This is important if the provided path contains a tilde (~)
5-
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
6-
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7-
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
8-
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9-
else()
10-
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
11-
endif()
12-
131
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
2+
3+
set(CPM_DOWNLOAD_VERSION 0.35.0)
4+
5+
if(CPM_SOURCE_CACHE)
6+
# Expand relative path. This is important if the provided path contains a tilde (~)
7+
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
8+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
10+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
11+
else()
12+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
13+
endif()
14+
1415
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
1516
file(DOWNLOAD
1617
https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake

0 commit comments

Comments
 (0)