summaryrefslogtreecommitdiffstats
path: root/Tests/FindPython
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-12 14:09:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-12 14:10:53 (GMT)
commitccd87d89d8c231ea81357305316574c2e8f72935 (patch)
tree4dbaa654fdeada38635a129259134957f4e0d628 /Tests/FindPython
parent04881b20fa28ffa65c8c1933b767be68414bf7d7 (diff)
parenta00603af0b61ae93c96bc77b576315134ee36f22 (diff)
downloadCMake-ccd87d89d8c231ea81357305316574c2e8f72935.zip
CMake-ccd87d89d8c231ea81357305316574c2e8f72935.tar.gz
CMake-ccd87d89d8c231ea81357305316574c2e8f72935.tar.bz2
Merge topic 'FindPython-version-range-fix-tests'
a00603af0b FindPython: Fix version range tests Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5497
Diffstat (limited to 'Tests/FindPython')
-rw-r--r--Tests/FindPython/VersionRange/CMakeLists.txt41
1 files changed, 25 insertions, 16 deletions
diff --git a/Tests/FindPython/VersionRange/CMakeLists.txt b/Tests/FindPython/VersionRange/CMakeLists.txt
index e8873cb..957941d 100644
--- a/Tests/FindPython/VersionRange/CMakeLists.txt
+++ b/Tests/FindPython/VersionRange/CMakeLists.txt
@@ -16,40 +16,49 @@ else()
set (OUT_VERSION_RANGE 3.0...<${${Python}_VERSION})
endif()
-function (FIND_PYTHON EXPECTED_VERSION)
- unset (_${Python}_EXECUTABLE CACHE)
- unset (_${Python}_LIBRARY_RELEASE CACHE)
- unset (_${Python}_INCLUDE_DIR CACHE)
- unset (${Python}_FOUND)
+function (FIND_PYTHON EXPECTED_VERSION RANGE)
+ macro (FIND_PYTHON_PACKAGE)
+ unset (_${Python}_EXECUTABLE CACHE)
+ unset (_${Python}_LIBRARY_RELEASE CACHE)
+ unset (_${Python}_INCLUDE_DIR CACHE)
+ unset (${Python}_FOUND)
- find_package (${ARGN})
+ find_package (${Python} ${ARGV})
+ endmacro()
+
+ find_python_package(${RANGE} ${ARGN})
if (EXPECTED_VERSION STREQUAL "NONE")
+ while (${Python}_FOUND AND ${Python}_VERSION VERSION_GREATER ${Python_REQUESTED_VERSION})
+ # Possible if multiple versions are installed
+ # Try with a different range
+ find_python_package(${Python_REQUESTED_VERSION}.0...<${${Python}_VERSION} ${ARGN})
+ endwhile()
if (${Python}_FOUND)
- message (SEND_ERROR "Unexpectedly found version: ${${Python}_VERSION} for ${ARGN}")
+ message (SEND_ERROR "Unexpectedly found version: ${${Python}_VERSION} for '${Python} ${Python_REQUESTED_VERSION}.0...<${${Python}_VERSION} ${ARGN}'")
endif()
return()
endif()
if (NOT ${Python}_FOUND)
- message (SEND_ERROR "Not found: ${ARGN}")
+ message (SEND_ERROR "Not found: ${Python} ${RANGE} ${ARGN}")
elseif (NOT ${Python}_VERSION VERSION_EQUAL EXPECTED_VERSION)
- message (SEND_ERROR "Wrong version: ${${Python}_VERSION} for ${ARGN}")
+ message (SEND_ERROR "Wrong version: ${${Python}_VERSION} for '${Python} ${RANGE} ${ARGN}'")
endif()
endfunction()
-find_python (${${Python}_VERSION} ${Python} ${IN_VERSION_RANGE} COMPONENTS Interpreter)
+find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Interpreter)
if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython")
- find_python (${${Python}_VERSION} ${Python} ${IN_VERSION_RANGE} COMPONENTS Compiler)
+ find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Compiler)
else()
- find_python (${${Python}_VERSION} ${Python} ${IN_VERSION_RANGE} COMPONENTS Development)
+ find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Development)
endif()
-find_python ("NONE" ${Python} ${OUT_VERSION_RANGE} COMPONENTS Interpreter)
+find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Interpreter)
if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython")
- find_python ("NONE" ${Python} ${OUT_VERSION_RANGE} COMPONENTS Compiler)
+ find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Compiler)
else()
- find_python ("NONE" ${Python} ${OUT_VERSION_RANGE} COMPONENTS Development)
+ find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Development)
endif()
-find_python ("NONE" ${Python} 5...6 COMPONENTS Interpreter)
+find_python ("NONE" 5...6 COMPONENTS Interpreter)