From 27c05edc8ef6f4b37dc5f0b38f8baff9364117d6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 17 Aug 2023 10:23:45 +0800 Subject: [PATCH] cmake: update FindPython3 module * use the one shiped by the latest CMake (ab379e5054aa792df9572078dcf95bddd75f7661) * use the new policy to use the new find strategy. * accomodate the vanilla FindPython3 module to Ceph by: - dropping the `cmake_policy()` calls which set the policy not supported by 3.16. - `include (FindPackageHandleStandardArgs)` without specifying the relative path. - dropping the `HANDLE_VERSION_RANGE` from `FindPackageHandleStandardArgs()` call. this option was introduced by CMake v3.19, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html but Ubuntu focal comes with CMake 3.16, which is our minimal required CMake version. the new FindPython3 module from CMake: * enables us to find the recent Python intepreter and development files up to CPython 3.13. * finds Python intepreter with the new `Python_FIND_STRATEGY`. the old and default strategy always finds the most recent version with all specified name and in all locations. so, if /usr/bin/python exists, it would accept, even if it is a symlink to python3.9 and what we want is python3.6. the new policy stops at the one which satisfies the constraints. this helps us to address the problem of issue we have when recreating the building system after the CMakeLists.txt is updated. Fixes: https://tracker.ceph.com/issues/62428 Signed-off-by: Kefu Chai --- cmake/modules/FindPython/Support.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/modules/FindPython/Support.cmake b/cmake/modules/FindPython/Support.cmake index 5e1d6f62ecc64..141c261dff65b 100644 --- a/cmake/modules/FindPython/Support.cmake +++ b/cmake/modules/FindPython/Support.cmake @@ -24,7 +24,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3") - set(_${_PYTHON_PREFIX}_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + set(_${_PYTHON_PREFIX}_VERSIONS 3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2") set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) else() @@ -3863,7 +3863,6 @@ endforeach() find_package_handle_standard_args (${_PYTHON_PREFIX} REQUIRED_VARS ${_${_PYTHON_PREFIX}_REQUIRED_VARS} VERSION_VAR ${_PYTHON_PREFIX}_VERSION - HANDLE_VERSION_RANGE HANDLE_COMPONENTS REASON_FAILURE_MESSAGE "${_${_PYTHON_PREFIX}_REASON_FAILURE}") -- 2.39.5