mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-12-19 00:00:28 -05:00
Timestamps for URL downloads match the download time (#372)
* Timestamps for URL downloads match the download time By enabling CMake policy 135 we ensure that extracted files timestamp match that of the download time, instead of when the archive is created. This makes sure that if the URL changes to an older version we still rebuild everything as the timestamp stays newer. * Introduce CPM_SET_RECOMMENDED_CMAKE_POLICIES Enabling CPM_SET_RECOMMENDED_CMAKE_POLICIES will establish defaults for all CMake policies so that both CPM and added projects operate inline with CPM recommended best practices. * Fix style issues found by ci * Update README.md Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com> * Update cmake/CPM.cmake Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com> * Set policies when CPM.cmake is included * CPM_SET_RECOMMENDED_CMAKE_POLICIES default is ON * Correct failing CI tests * CPM.cmake always sets policies to on Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
This commit is contained in:
parent
49af958fb4
commit
b224ce280d
@ -28,6 +28,23 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||||
|
|
||||||
|
# the policy allows us to change options without caching
|
||||||
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||||
|
|
||||||
|
# the policy allows us to change set(CACHE) without caching
|
||||||
|
if(POLICY CMP0126)
|
||||||
|
cmake_policy(SET CMP0126 NEW)
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The policy uses the download time for timestamp, instead of the timestamp in the archive. This
|
||||||
|
# allows for proper rebuilds when a projects url changes
|
||||||
|
if(POLICY CMP0135)
|
||||||
|
cmake_policy(SET CMP0135 NEW)
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CURRENT_CPM_VERSION 1.0.0-development-version)
|
set(CURRENT_CPM_VERSION 1.0.0-development-version)
|
||||||
|
|
||||||
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||||
@ -477,6 +494,7 @@ endfunction()
|
|||||||
|
|
||||||
# Download and add a package from source
|
# Download and add a package from source
|
||||||
function(CPMAddPackage)
|
function(CPMAddPackage)
|
||||||
|
|
||||||
list(LENGTH ARGN argnLength)
|
list(LENGTH ARGN argnLength)
|
||||||
if(argnLength EQUAL 1)
|
if(argnLength EQUAL 1)
|
||||||
cpm_parse_add_package_single_arg("${ARGN}" ARGN)
|
cpm_parse_add_package_single_arg("${ARGN}" ARGN)
|
||||||
@ -906,16 +924,6 @@ function(
|
|||||||
set(addSubdirectoryExtraArgs "")
|
set(addSubdirectoryExtraArgs "")
|
||||||
endif()
|
endif()
|
||||||
if(OPTIONS)
|
if(OPTIONS)
|
||||||
# the policy allows us to change options without caching
|
|
||||||
cmake_policy(SET CMP0077 NEW)
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
|
||||||
|
|
||||||
# the policy allows us to change set(CACHE) without caching
|
|
||||||
if(POLICY CMP0126)
|
|
||||||
cmake_policy(SET CMP0126 NEW)
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(OPTION ${OPTIONS})
|
foreach(OPTION ${OPTIONS})
|
||||||
cpm_parse_option("${OPTION}")
|
cpm_parse_option("${OPTION}")
|
||||||
set(${OPTION_KEY} "${OPTION_VALUE}")
|
set(${OPTION_KEY} "${OPTION_VALUE}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user