summaryrefslogtreecommitdiffstats
path: root/Tests/FindPython
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-06-05 11:08:52 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2019-06-24 10:00:21 (GMT)
commit9201908ca5c10a6142c0558401445320773f1f1e (patch)
tree8f1889628d8c87e50d259931b08a40596bbd92a0 /Tests/FindPython
parent512013e276e66551c19c12af01336f96c26965a5 (diff)
downloadCMake-9201908ca5c10a6142c0558401445320773f1f1e.zip
CMake-9201908ca5c10a6142c0558401445320773f1f1e.tar.gz
CMake-9201908ca5c10a6142c0558401445320773f1f1e.tar.bz2
FindPython: add Python_FIND_ABI hint.
This variable will enable to specify will ABIs will be searched.
Diffstat (limited to 'Tests/FindPython')
-rw-r--r--Tests/FindPython/FindPythonScript.cmake10
-rw-r--r--Tests/FindPython/Python2/CMakeLists.txt1
-rw-r--r--Tests/FindPython/Python3/CMakeLists.txt53
3 files changed, 63 insertions, 1 deletions
diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake
index 9450092..bc7e0d1 100644
--- a/Tests/FindPython/FindPythonScript.cmake
+++ b/Tests/FindPython/FindPythonScript.cmake
@@ -1 +1,9 @@
-find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET)
+
+if (PYTHON_MUST_NOT_BE_FOUND)
+ find_package(${PYTHON_PACKAGE_NAME} QUIET)
+ if (${PYTHON_PACKAGE_NAME}_FOUND)
+ message(FATAL_ERROR "${PYTHON_PACKAGE_NAME}: unexpectedly founded.")
+ endif()
+else()
+ find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET)
+endif()
diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt
index 274745a..cf77ca2 100644
--- a/Tests/FindPython/Python2/CMakeLists.txt
+++ b/Tests/FindPython/Python2/CMakeLists.txt
@@ -34,4 +34,5 @@ add_test (NAME python2_spam2
add_test(NAME findpython2_script
COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2
+ -DPython2_FIND_STRATEGY=${Python2_FIND_STRATEGY}
-P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt
index b21a15b..6691a48 100644
--- a/Tests/FindPython/Python3/CMakeLists.txt
+++ b/Tests/FindPython/Python3/CMakeLists.txt
@@ -34,4 +34,57 @@ add_test (NAME python3_spam3
add_test(NAME findpython3_script
COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+
+
+## Try a new search specifying only expected ABI
+# retrieve ABI of python interpreter
+execute_process (COMMAND "${Python3_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE abi
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if (result)
+ # assume ABI is not supported
+ set (abi "")
+endif()
+
+# define FIND_ABI variable
+if (abi MATCHES "d")
+ set (Python3_VALID_ABI "ON")
+else()
+ set (Python3_VALID_ABI "OFF")
+endif()
+if (abi MATCHES "m")
+ list (APPEND Python3_VALID_ABI "ON")
+else()
+ list (APPEND Python3_VALID_ABI "OFF")
+endif()
+if (abi MATCHES "u")
+ list (APPEND Python3_VALID_ABI "ON")
+else()
+ list (APPEND Python3_VALID_ABI "OFF")
+endif()
+# build an invalid pattern for ABI
+set (Python3_INVALID_ABI)
+foreach (abi IN LISTS Python3_VALID_ABI)
+ if (abi)
+ list (APPEND Python3_INVALID_ABI "OFF")
+ else()
+ list (APPEND Python3_INVALID_ABI "ON")
+ endif()
+endforeach()
+
+add_test(NAME python3_find_valid_abi
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ "-DPython3_FIND_ABI=${Python3_VALID_ABI}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+add_test(NAME python3_find_invalid_abi
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPYTHON_MUST_NOT_BE_FOUND=ON
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ "-DPython3_FIND_ABI=${Python3_INVALID_ABI}"
-P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")