From d532d93d9522178ad7518c3b73d4b77de3ea1bbb Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 11 Aug 2022 11:50:44 -0400 Subject: [PATCH 1/2] Restore policy changes in CPMAddPackage Fixes #387 --- cmake/CPM.cmake | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 4c03d967..369ad407 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -67,22 +67,25 @@ endif() set_property(GLOBAL PROPERTY CPM_INITIALIZED true) -# 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() +macro(cpm_set_policies ) + # 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() + # 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() +endmacro() +cpm_set_policies() option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies" $ENV{CPM_USE_LOCAL_PACKAGES} @@ -494,6 +497,7 @@ endfunction() # Download and add a package from source function(CPMAddPackage) + cpm_set_policies() list(LENGTH ARGN argnLength) if(argnLength EQUAL 1) From 179c151ebd4ebabca45fbc76ff39c7a43c6ffcbf Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 11 Aug 2022 15:02:21 -0400 Subject: [PATCH 2/2] Correct style issues found by CI --- cmake/CPM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 369ad407..7aa8b665 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -67,7 +67,7 @@ endif() set_property(GLOBAL PROPERTY CPM_INITIALIZED true) -macro(cpm_set_policies ) +macro(cpm_set_policies) # the policy allows us to change options without caching cmake_policy(SET CMP0077 NEW) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)