Skip to content

Commit

Permalink
ver 3.4 allow override CPM location (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arniiiii authored Jan 19, 2025
1 parent 9572b5e commit 77e8607
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions cmake/getCPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,27 @@
# set(CPM_DOWNLOAD_VERSION 0.40.2) set(CPM_HASH_SUM
# "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if(NOT DEFINED CPM_DOWNLOAD_LOCATION AND NOT DEFINED ENV{CPM_DOWNLOAD_LOCATION})
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION
"${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION
"$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a
# tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION}
ABSOLUTE)

file(DOWNLOAD
https://raw.githubusercontent.com/Arniiiii/CPM.cmake/main/cmake/CPM.cmake
${CPM_DOWNLOAD_LOCATION} # EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD https://raw.githubusercontent.com/Arniiiii/CPM.cmake/main/cmake/CPM.cmake
${CPM_DOWNLOAD_LOCATION} # EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})

0 comments on commit 77e8607

Please sign in to comment.