Skip to content

Commit ece3bed

Browse files
MarkaPolabradking
authored andcommitted
FindPython: fix error on multiple queries with different COMPONENTS
Ensure that multiple queries with different COMPONENTS specified in different sub-directories are fully supported.
1 parent 8c562ec commit ece3bed

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Modules/FindPython/Support.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,8 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
28612861
endif()
28622862
unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS)
28632863

2864-
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
2864+
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS
2865+
AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
28652866
# Use the library's install prefix as a hint
28662867
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
28672868
list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
@@ -2945,7 +2946,8 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
29452946
if (_${_PYTHON_PREFIX}_INCLUDE_DIR)
29462947
# retrieve version from header file
29472948
_python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_)
2948-
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
2949+
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS
2950+
AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
29492951
if ("${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}"
29502952
VERSION_EQUAL _${_PYTHON_PREFIX}_VERSION)
29512953
# update versioning

Tests/FindPython/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,19 @@ if(CMake_TEST_FindPython)
423423
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
424424
)
425425

426+
add_test(NAME FindPython.DifferentComponents COMMAND
427+
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
428+
--build-and-test
429+
"${CMake_SOURCE_DIR}/Tests/FindPython/DifferentComponents"
430+
"${CMake_BINARY_DIR}/Tests/FindPython/DifferentComponents"
431+
${build_generator_args}
432+
--build-project DifferentComponents
433+
--build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}"
434+
"-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}"
435+
"-DCMake_BINARY_DIR=${CMake_BINARY_DIR}"
436+
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
437+
)
438+
426439
if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
427440
add_test(NAME FindPython.Interpreter.SOABI COMMAND
428441
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
3+
project(TestDifferentComponents LANGUAGES C)
4+
5+
add_subdirectory(subdir)
6+
7+
find_package(Python3 REQUIRED COMPONENTS Development.Module)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
find_package(Python3 REQUIRED COMPONENTS Development)

0 commit comments

Comments
 (0)