diff options
| author | Brad King <brad.king@kitware.com> | 2019-06-25 11:06:14 (GMT) |
|---|---|---|
| committer | Kitware Robot <kwrobot@kitware.com> | 2019-06-25 11:06:35 (GMT) |
| commit | b4a882cf10874fbd04bda81d9dfeeea29dcf3f8b (patch) | |
| tree | b315b6dbd25904ab19cd6c984b6cb93466cdb4be /Tests/FindPython/Python3 | |
| parent | 2e8b8eb857037a4c0f08a1c7c0ce5a778ebfbc54 (diff) | |
| parent | 9201908ca5c10a6142c0558401445320773f1f1e (diff) | |
| download | CMake-b4a882cf10874fbd04bda81d9dfeeea29dcf3f8b.zip CMake-b4a882cf10874fbd04bda81d9dfeeea29dcf3f8b.tar.gz CMake-b4a882cf10874fbd04bda81d9dfeeea29dcf3f8b.tar.bz2 | |
Merge topic 'FindPython-FIND_ABI'
9201908ca5 FindPython: add Python_FIND_ABI hint.
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3463
Diffstat (limited to 'Tests/FindPython/Python3')
| -rw-r--r-- | Tests/FindPython/Python3/CMakeLists.txt | 53 |
1 files changed, 53 insertions, 0 deletions
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") |
