Skip to content

Commit 84ed75c

Browse files
authored
Update CPM.cmake (#164)
1 parent ab5c08a commit 84ed75c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cmake/CPM.cmake

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
set(CPM_DOWNLOAD_VERSION 0.35.0)
1+
set(CPM_DOWNLOAD_VERSION 0.37.0)
22

33
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)
64
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
75
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
86
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
97
else()
108
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
119
endif()
1210

13-
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
1415
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
1516
file(DOWNLOAD
1617
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
1718
${CPM_DOWNLOAD_LOCATION}
1819
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
1930
endif()
2031

2132
include(${CPM_DOWNLOAD_LOCATION})

0 commit comments

Comments
 (0)