From ece3bedbf2cdc4857f19e2fceafa98a3f8002b4a Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sat, 25 Jun 2022 14:45:29 +0200 Subject: FindPython: fix error on multiple queries with different COMPONENTS Ensure that multiple queries with different COMPONENTS specified in different sub-directories are fully supported. --- Modules/FindPython/Support.cmake | 6 ++++-- Tests/FindPython/CMakeLists.txt | 13 +++++++++++++ Tests/FindPython/DifferentComponents/CMakeLists.txt | 7 +++++++ Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Tests/FindPython/DifferentComponents/CMakeLists.txt create mode 100644 Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 8e98500..c4fae6b 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -2861,7 +2861,8 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) - if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS + AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE) # Use the library's install prefix as a hint if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)") list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") @@ -2945,7 +2946,8 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (_${_PYTHON_PREFIX}_INCLUDE_DIR) # retrieve version from header file _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_) - if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS + AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE) if ("${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL _${_PYTHON_PREFIX}_VERSION) # update versioning diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 520ba9e..d4cf36b 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -423,6 +423,19 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) + add_test(NAME FindPython.DifferentComponents COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/DifferentComponents" + "${CMake_BINARY_DIR}/Tests/FindPython/DifferentComponents" + ${build_generator_args} + --build-project DifferentComponents + --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" + "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" + "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") add_test(NAME FindPython.Interpreter.SOABI COMMAND ${CMAKE_CTEST_COMMAND} -C $ diff --git a/Tests/FindPython/DifferentComponents/CMakeLists.txt b/Tests/FindPython/DifferentComponents/CMakeLists.txt new file mode 100644 index 0000000..7476632 --- /dev/null +++ b/Tests/FindPython/DifferentComponents/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestDifferentComponents LANGUAGES C) + +add_subdirectory(subdir) + +find_package(Python3 REQUIRED COMPONENTS Development.Module) diff --git a/Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt b/Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt new file mode 100644 index 0000000..98fcd5f --- /dev/null +++ b/Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt @@ -0,0 +1,2 @@ + +find_package(Python3 REQUIRED COMPONENTS Development) -- cgit v0.12