@@ -67,22 +67,25 @@ endif()
6767
6868set_property (GLOBAL PROPERTY CPM_INITIALIZED true )
6969
70- # the policy allows us to change options without caching
71- cmake_policy (SET CMP0077 NEW)
72- set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
73-
74- # the policy allows us to change set(CACHE) without caching
75- if (POLICY CMP0126)
76- cmake_policy (SET CMP0126 NEW)
77- set (CMAKE_POLICY_DEFAULT_CMP0126 NEW)
78- endif ()
70+ macro (cpm_set_policies)
71+ # the policy allows us to change options without caching
72+ cmake_policy (SET CMP0077 NEW)
73+ set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
74+
75+ # the policy allows us to change set(CACHE) without caching
76+ if (POLICY CMP0126)
77+ cmake_policy (SET CMP0126 NEW)
78+ set (CMAKE_POLICY_DEFAULT_CMP0126 NEW)
79+ endif ()
7980
80- # The policy uses the download time for timestamp, instead of the timestamp in the archive. This
81- # allows for proper rebuilds when a projects url changes
82- if (POLICY CMP0135)
83- cmake_policy (SET CMP0135 NEW)
84- set (CMAKE_POLICY_DEFAULT_CMP0135 NEW)
85- endif ()
81+ # The policy uses the download time for timestamp, instead of the timestamp in the archive. This
82+ # allows for proper rebuilds when a projects url changes
83+ if (POLICY CMP0135)
84+ cmake_policy (SET CMP0135 NEW)
85+ set (CMAKE_POLICY_DEFAULT_CMP0135 NEW)
86+ endif ()
87+ endmacro ()
88+ cpm_set_policies()
8689
8790option (CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies"
8891 $ENV{CPM_USE_LOCAL_PACKAGES}
@@ -494,6 +497,7 @@ endfunction()
494497
495498# Download and add a package from source
496499function (CPMAddPackage)
500+ cpm_set_policies()
497501
498502 list (LENGTH ARGN argnLength)
499503 if (argnLength EQUAL 1)
0 commit comments