Browse Source

Merge topic 'policy-cleanup'

b010a1fb1d Help: Update try_compile list of automatic policies
5e9b40b6a5 Help: Update cmake-buildsystem(7) TARGET_POLICY example to a newer policy
9ffbc0e628 Tests/RunCMake/cmake_minimum_required: Generalize deprecated version case name
0eca249ac7 Tests/RunCMake: Update more cmake_minimum_required versions to 3.10
a8cf033a74 Tests/RunCMake/return: Use newer cmake_minimum_required VERSION

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !10178
Brad King 9 months ago
parent
commit
1d5c1b0023

+ 15 - 2
Help/command/try_compile.rst

@@ -335,8 +335,21 @@ Other Behavior Settings
   :module:`CheckPIESupported` module must be called before using the
   ``try_compile`` command.
 
-The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated
-through to the generated test project.
+Some policies are set automatically in the generated test project
+as needed to honor the state of the calling project:
+
+* :policy:`CMP0065`
+* :policy:`CMP0083`
+* :policy:`CMP0091`
+* :policy:`CMP0104`
+* :policy:`CMP0123`
+* :policy:`CMP0126`
+* :policy:`CMP0128`
+* :policy:`CMP0136`
+* :policy:`CMP0141`
+* :policy:`CMP0155`
+* :policy:`CMP0157`
+* :policy:`CMP0181`
 
 .. versionadded:: 3.32
   The current setting of :policy:`CMP0181` policy is propagated through to the

+ 3 - 3
Help/manual/cmake-buildsystem.7.rst

@@ -960,20 +960,20 @@ on the consumer:
   target_compile_definitions(lib1 INTERFACE
     $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:LIB1_WITH_EXE>
     $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:LIB1_WITH_SHARED_LIB>
-    $<$<TARGET_POLICY:CMP0041>:CONSUMER_CMP0041_NEW>
+    $<$<TARGET_POLICY:CMP0182>:CONSUMER_CMP0182_NEW>
   )
 
   add_executable(exe1 exe1.cpp)
   target_link_libraries(exe1 lib1)
 
-  cmake_policy(SET CMP0041 NEW)
+  cmake_policy(SET CMP0182 NEW)
 
   add_library(shared_lib shared_lib.cpp)
   target_link_libraries(shared_lib lib1)
 
 The ``exe1`` executable will be compiled with ``-DLIB1_WITH_EXE``, while the
 ``shared_lib`` shared library will be compiled with ``-DLIB1_WITH_SHARED_LIB``
-and ``-DCONSUMER_CMP0041_NEW``, because policy :policy:`CMP0041` is
+and ``-DCONSUMER_CMP0182_NEW``, because policy :policy:`CMP0182` is
 ``NEW`` at the point where the ``shared_lib`` target is created.
 
 The ``BUILD_INTERFACE`` expression wraps requirements which are only used when

+ 1 - 1
Tests/RunCMake/Policy/CMakeLists.txt

@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.10)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)

+ 3 - 3
Tests/RunCMake/cmake_minimum_required/Before3_10-stderr.txt → Tests/RunCMake/cmake_minimum_required/BeforeVersionDeprecated-stderr.txt

@@ -1,4 +1,4 @@
-^CMake Deprecation Warning at Before3_10\.cmake:1 \(cmake_minimum_required\):
+^CMake Deprecation Warning at BeforeVersionDeprecated\.cmake:1 \(cmake_minimum_required\):
   Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
@@ -8,7 +8,7 @@
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
-CMake Deprecation Warning at Before3_10\.cmake:2 \(cmake_policy\):
+CMake Deprecation Warning at BeforeVersionDeprecated\.cmake:2 \(cmake_policy\):
   Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 
@@ -18,7 +18,7 @@ CMake Deprecation Warning at Before3_10\.cmake:2 \(cmake_policy\):
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
-CMake Deprecation Warning at Before3_10\.cmake:6 \(cmake_policy\):
+CMake Deprecation Warning at BeforeVersionDeprecated\.cmake:6 \(cmake_policy\):
   Compatibility with CMake < 3\.10 will be removed from a future version of
   CMake\.
 

+ 0 - 0
Tests/RunCMake/cmake_minimum_required/Before3_10.cmake → Tests/RunCMake/cmake_minimum_required/BeforeVersionDeprecated.cmake


+ 1 - 1
Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake

@@ -4,7 +4,7 @@ run_cmake(Before24)
 run_cmake(CompatBefore24)
 run_cmake(Future)
 run_cmake(PolicyBefore24)
-run_cmake(Before3_10)
+run_cmake(BeforeVersionDeprecated)
 run_cmake(Range)
 run_cmake(RangeBad)
 run_cmake(Unknown)

+ 0 - 3
Tests/RunCMake/return/CMP0140-WARN.cmake

@@ -1,6 +1,3 @@
-
-cmake_policy(VERSION 3.1)
-
 function(FUNC)
   return(PROPAGATE VAR)
 endfunction()

+ 4 - 1
Tests/RunCMake/return/CMakeLists.txt

@@ -1,3 +1,6 @@
-cmake_minimum_required(VERSION 3.1...3.25)
+cmake_minimum_required(VERSION 3.25)
+if(RunCMake_TEST MATCHES "^CMP0140")
+  cmake_minimum_required(VERSION 3.24)
+endif()
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)

+ 0 - 1
Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake

@@ -1,5 +1,4 @@
 include(RunCMake)
-set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
 
 if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
   set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)