Debian Codegraph @

examples/example_project/cmake/CPM.cmake

raw
1 set(CPM_DOWNLOAD_VERSION 0.38.1)
2
3 if(CPM_SOURCE_CACHE)
4 set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5 elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6 set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7 else()
8 set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9 endif()
10
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)
15 message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16 file(DOWNLOAD
17 https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18 ${CPM_DOWNLOAD_LOCATION}
19 )
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()
30 unset(check)
31 endif()
32
33 include(${CPM_DOWNLOAD_LOCATION})