Commit 5222400d authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'FindPython-find_strategy'

8517b549 FindPython: Add policy to manage lookup stratgey default.
9f205ace FindPython: Implement lookup strategies.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3354
parents cbd1c5b4 8517b549
......@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.15
.. toctree::
:maxdepth: 1
CMP0094: FindPython3, FindPython2 and FindPython use LOCATION for lookup strategy. </policy/CMP0094>
CMP0093: FindBoost reports Boost_VERSION in x.y.z format. </policy/CMP0093>
CMP0092: MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. </policy/CMP0092>
CMP0091: MSVC runtime library flags are selected by an abstraction. </policy/CMP0091>
......
CMP0094
-------
Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
use ``LOCATION`` for lookup strategy.
Starting with CMake 3.15, Modules :module:`FindPython3`, :module:`FindPython2`
and :module:`FindPython` set value ``LOCATION`` for, respectively, variables
``Python3_FIND_STRATEGY``, ``Python2_FIND_STRATEGY`` and
``Python_FIND_STRATEGY``. This policy provides compatibility with projects that
expect the legacy behavior.
The ``OLD`` behavior for this policy set value ``VERSION`` for variables
``Python3_FIND_STRATEGY``, ``Python2_FIND_STRATEGY`` and
``Python_FIND_STRATEGY``.
This policy was introduced in CMake version 3.15. Use the
:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
Unlike many policies, CMake version |release| does *not* warn
when this policy is not set and simply uses the ``OLD`` behavior.
.. include:: DEPRECATED.txt
FindPython-CMP0094
------------------
* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
have changed default strategy for lookup. See policy :policy:`CMP0094`.
FindPython-FIND_STRATEGY
------------------------
* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
gain a new way to control lookup strategy.
......@@ -137,6 +137,19 @@ Hints
* If set to TRUE, search **only** for static libraries.
* If set to FALSE, search **only** for shared libraries.
``Python_FIND_STRATEGY``
This variable defines how lookup will be done.
The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the
following:
* ``VERSION``: Try to find the most recent version in all specified
locations.
This is the default if policy :policy:`CMP0094` is undefined or set to
``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python_FIND_REGISTRY``
On Windows the ``Python_FIND_REGISTRY`` variable determine the order
of preference between registry and environment variables.
......
This diff is collapsed.
......@@ -138,6 +138,19 @@ Hints
* If set to TRUE, search **only** for static libraries.
* If set to FALSE, search **only** for shared libraries.
``Python2_FIND_STRATEGY``
This variable defines how lookup will be done.
The ``Python2_FIND_STRATEGY`` variable can be set to empty or one of the
following:
* ``VERSION``: Try to find the most recent version in all specified
locations.
This is the default if policy :policy:`CMP0094` is undefined or set to
``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python2_FIND_REGISTRY``
On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
of preference between registry and environment variables.
......
......@@ -138,6 +138,19 @@ Hints
* If set to TRUE, search **only** for static libraries.
* If set to FALSE, search **only** for shared libraries.
``Python3_FIND_STRATEGY``
This variable defines how lookup will be done.
The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the
following:
* ``VERSION``: Try to find the most recent version in all specified
locations.
This is the default if policy :policy:`CMP0094` is undefined or set to
``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python3_FIND_REGISTRY``
On Windows the ``Python3_FIND_REGISTRY`` variable determine the order
of preference between registry and environment variables.
......
......@@ -275,6 +275,10 @@ class cmMakefile;
"MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.", 3, \
15, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0093, "FindBoost reports Boost_VERSION in x.y.z format.", \
3, 15, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0094, \
"FindPython3, FindPython2 and FindPyton use " \
"LOCATION for lookup strategy.", \
3, 15, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
......
if(CMake_TEST_FindPython)
add_test(NAME FindPython.Python2 COMMAND
add_test(NAME FindPython.Python2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
"${CMake_BINARY_DIR}/Tests/FindPython/Python2"
"${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION"
${build_generator_args}
--build-project TestPython2
--build-options ${build_options}
--build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
add_test(NAME FindPython.Python2.VERSION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
"${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION"
${build_generator_args}
--build-project TestPython2
--build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
......@@ -23,14 +33,24 @@ if(CMake_TEST_FindPython)
set_tests_properties(FindPython.Python2Fail PROPERTIES
PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)")
add_test(NAME FindPython.Python3 COMMAND
add_test(NAME FindPython.Python3.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
"${CMake_BINARY_DIR}/Tests/FindPython/Python3"
"${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION"
${build_generator_args}
--build-project TestPython3
--build-options ${build_options}
--build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
add_test(NAME FindPython.Python3.VERSION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
"${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION"
${build_generator_args}
--build-project TestPython3
--build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment