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 <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10178
This commit is contained in:
Brad King
2025-01-16 14:01:35 +00:00
committed by Kitware Robot
9 changed files with 27 additions and 15 deletions
+15 -2
View File
@@ -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
View File
@@ -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