Skip to content

Commit 18b6cbf

Browse files
authored
perform policy changes only in top-level CPM.cmake script (#386)
1 parent 698741f commit 18b6cbf

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

cmake/CPM.cmake

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,6 @@
2828

2929
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
3030

31-
# the policy allows us to change options without caching
32-
cmake_policy(SET CMP0077 NEW)
33-
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
34-
35-
# the policy allows us to change set(CACHE) without caching
36-
if(POLICY CMP0126)
37-
cmake_policy(SET CMP0126 NEW)
38-
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
39-
endif()
40-
41-
# The policy uses the download time for timestamp, instead of the timestamp in the archive. This
42-
# allows for proper rebuilds when a projects url changes
43-
if(POLICY CMP0135)
44-
cmake_policy(SET CMP0135 NEW)
45-
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
46-
endif()
47-
4831
set(CURRENT_CPM_VERSION 1.0.0-development-version)
4932

5033
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
@@ -84,6 +67,23 @@ endif()
8467

8568
set_property(GLOBAL PROPERTY CPM_INITIALIZED true)
8669

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()
79+
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()
86+
8787
option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies"
8888
$ENV{CPM_USE_LOCAL_PACKAGES}
8989
)

0 commit comments

Comments
 (0)