From aed9dffdc97afeb20c060d2d5c958f5ad6b0dbc1 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 16 Feb 2025 18:27:23 +0100 Subject: FindPython: migrate tests to RunCMake framework --- Modules/FindPython/Support.cmake | 4 +- Tests/CMakeLists.txt | 68 +- .../FindPython/ArtifactsInteractive/CMakeLists.txt | 24 - Tests/FindPython/ArtifactsPrefix/CMakeLists.txt | 24 - Tests/FindPython/CMakeLists.txt | 955 --------------------- .../FindPython/CustomFailureMessage/CMakeLists.txt | 79 -- .../CustomFailureMessage/Check/CMakeLists.txt | 5 - .../FindPython/DifferentComponents/CMakeLists.txt | 7 - .../DifferentComponents/subdir/CMakeLists.txt | 2 - Tests/FindPython/ExactVersion/CMakeLists.txt | 56 -- Tests/FindPython/FindPythonScript.cmake | 9 - Tests/FindPython/Implementation/CMakeLists.txt | 37 - Tests/FindPython/IronPython/CMakeLists.txt | 31 - Tests/FindPython/IronPython2/CMakeLists.txt | 31 - Tests/FindPython/IronPython3/CMakeLists.txt | 31 - Tests/FindPython/MultiplePackages/CMakeLists.txt | 45 - Tests/FindPython/NumPy/CMakeLists.txt | 31 - Tests/FindPython/NumPy/arraytest.c | 58 -- Tests/FindPython/NumPyOnly/CMakeLists.txt | 24 - Tests/FindPython/PyPy/CMakeLists.txt | 37 - Tests/FindPython/PyPy2/CMakeLists.txt | 37 - Tests/FindPython/PyPy3/CMakeLists.txt | 37 - Tests/FindPython/Python/CMakeLists.txt | 80 -- Tests/FindPython/Python2/CMakeLists.txt | 88 -- Tests/FindPython/Python2Embedded/CMakeLists.txt | 42 - Tests/FindPython/Python2Fail/CMakeLists.txt | 14 - Tests/FindPython/Python2Module/CMakeLists.txt | 37 - Tests/FindPython/Python2SABIModule/CMakeLists.txt | 5 - Tests/FindPython/Python3/CMakeLists.txt | 145 ---- Tests/FindPython/Python3Embedded/CMakeLists.txt | 42 - Tests/FindPython/Python3Fail/CMakeLists.txt | 14 - Tests/FindPython/Python3Module/CMakeLists.txt | 46 - Tests/FindPython/Python3SABIModule/CMakeLists.txt | 55 -- Tests/FindPython/RequiredArtifacts/CMakeLists.txt | 196 ----- .../RequiredArtifacts/Check/CMakeLists.txt | 49 -- Tests/FindPython/SOABI/CMakeLists.txt | 41 - Tests/FindPython/TEST_spam.c | 41 - Tests/FindPython/UnversionedNames/CMakeLists.txt | 66 -- Tests/FindPython/VersionRange/CMakeLists.txt | 64 -- Tests/FindPython/VirtualEnv/CMakeLists.txt | 49 -- .../FindPython/VirtualEnv/VirtualEnvDefault.cmake | 7 - Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake | 17 - .../FindPython/VirtualEnv/VirtualEnvStandard.cmake | 8 - Tests/FindPython/VirtualEnvConda/CMakeLists.txt | 48 -- .../VirtualEnvConda/VirtualEnvDefault.cmake | 7 - .../VirtualEnvConda/VirtualEnvOnly.cmake | 17 - .../VirtualEnvConda/VirtualEnvStandard.cmake | 8 - Tests/FindPython/display_time.c | 41 - Tests/FindPython/display_time.h | 2 - Tests/FindPython/main.c | 7 - Tests/FindPython/spam.c | 41 - Tests/RunCMake/CMakeLists.txt | 65 ++ .../RunCMake/FindPython/ArtifactsInteractive.cmake | 22 + Tests/RunCMake/FindPython/ArtifactsPrefix.cmake | 22 + Tests/RunCMake/FindPython/CMakeLists.txt | 3 + .../CustomFailureMessage.Include-stderr.txt | 4 + .../CustomFailureMessage.Interpreter-stderr.txt | 4 + .../CustomFailureMessage.Library-stderr.txt | 4 + .../CustomFailureMessage.Multiple-stderr.txt | 6 + .../CustomFailureMessage.NumPy-stderr.txt | 4 + .../RunCMake/FindPython/CustomFailureMessage.cmake | 4 + .../RunCMake/FindPython/DifferentComponents.cmake | 5 + Tests/RunCMake/FindPython/ExactVersion.cmake | 54 ++ Tests/RunCMake/FindPython/FindPythonScript.cmake | 9 + Tests/RunCMake/FindPython/Implementation.cmake | 33 + Tests/RunCMake/FindPython/IronPython.cmake | 36 + Tests/RunCMake/FindPython/MultiplePackages.cmake | 45 + Tests/RunCMake/FindPython/NumPy.cmake | 31 + Tests/RunCMake/FindPython/NumPyOnly.cmake | 31 + Tests/RunCMake/FindPython/PyPy.cmake | 43 + Tests/RunCMake/FindPython/Python.cmake | 78 ++ .../FindPython/Python2-BadComponent-result.txt | 1 + .../FindPython/Python2-BadComponent-stderr.txt | 2 + .../RunCMake/FindPython/Python2-BadComponent.cmake | 3 + Tests/RunCMake/FindPython/Python2.cmake | 86 ++ Tests/RunCMake/FindPython/Python2Embedded.cmake | 40 + Tests/RunCMake/FindPython/Python2Module.cmake | 35 + .../FindPython/Python2SABIModule-result.txt | 1 + .../FindPython/Python2SABIModule-stderr.txt | 2 + Tests/RunCMake/FindPython/Python2SABIModule.cmake | 3 + .../FindPython/Python3-BadComponent-result.txt | 1 + .../FindPython/Python3-BadComponent-stderr.txt | 2 + .../RunCMake/FindPython/Python3-BadComponent.cmake | 3 + Tests/RunCMake/FindPython/Python3.cmake | 86 ++ Tests/RunCMake/FindPython/Python3Embedded.cmake | 40 + Tests/RunCMake/FindPython/Python3Module.cmake | 44 + Tests/RunCMake/FindPython/Python3SABIModule.cmake | 53 ++ Tests/RunCMake/FindPython/PythonArtifacts.cmake.in | 32 + Tests/RunCMake/FindPython/RequiredArtifacts.cmake | 84 ++ .../FindPython/RequiredArtifactsCheck.cmake | 49 ++ Tests/RunCMake/FindPython/RunCMakeTest.cmake | 329 +++++++ Tests/RunCMake/FindPython/SOABI.cmake | 39 + Tests/RunCMake/FindPython/TEST_spam.c | 45 + Tests/RunCMake/FindPython/UnversionedNames.cmake | 65 ++ Tests/RunCMake/FindPython/VersionRange.cmake | 62 ++ Tests/RunCMake/FindPython/VirtualEnv.cmake | 15 + Tests/RunCMake/FindPython/VirtualEnvConda.cmake | 17 + Tests/RunCMake/FindPython/VirtualEnvDefault.cmake | 7 + Tests/RunCMake/FindPython/VirtualEnvOnly.cmake | 17 + Tests/RunCMake/FindPython/VirtualEnvStandard.cmake | 8 + Tests/RunCMake/FindPython/arraytest.c | 58 ++ Tests/RunCMake/FindPython/display_time.c | 41 + Tests/RunCMake/FindPython/display_time.h | 2 + Tests/RunCMake/FindPython/main.c | 7 + Tests/RunCMake/FindPython/spam.c | 45 + Tests/RunCMake/FindPython/subdir/CMakeLists.txt | 2 + 106 files changed, 1861 insertions(+), 2877 deletions(-) delete mode 100644 Tests/FindPython/ArtifactsInteractive/CMakeLists.txt delete mode 100644 Tests/FindPython/ArtifactsPrefix/CMakeLists.txt delete mode 100644 Tests/FindPython/CMakeLists.txt delete mode 100644 Tests/FindPython/CustomFailureMessage/CMakeLists.txt delete mode 100644 Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt delete mode 100644 Tests/FindPython/DifferentComponents/CMakeLists.txt delete mode 100644 Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt delete mode 100644 Tests/FindPython/ExactVersion/CMakeLists.txt delete mode 100644 Tests/FindPython/FindPythonScript.cmake delete mode 100644 Tests/FindPython/Implementation/CMakeLists.txt delete mode 100644 Tests/FindPython/IronPython/CMakeLists.txt delete mode 100644 Tests/FindPython/IronPython2/CMakeLists.txt delete mode 100644 Tests/FindPython/IronPython3/CMakeLists.txt delete mode 100644 Tests/FindPython/MultiplePackages/CMakeLists.txt delete mode 100644 Tests/FindPython/NumPy/CMakeLists.txt delete mode 100644 Tests/FindPython/NumPy/arraytest.c delete mode 100644 Tests/FindPython/NumPyOnly/CMakeLists.txt delete mode 100644 Tests/FindPython/PyPy/CMakeLists.txt delete mode 100644 Tests/FindPython/PyPy2/CMakeLists.txt delete mode 100644 Tests/FindPython/PyPy3/CMakeLists.txt delete mode 100644 Tests/FindPython/Python/CMakeLists.txt delete mode 100644 Tests/FindPython/Python2/CMakeLists.txt delete mode 100644 Tests/FindPython/Python2Embedded/CMakeLists.txt delete mode 100644 Tests/FindPython/Python2Fail/CMakeLists.txt delete mode 100644 Tests/FindPython/Python2Module/CMakeLists.txt delete mode 100644 Tests/FindPython/Python2SABIModule/CMakeLists.txt delete mode 100644 Tests/FindPython/Python3/CMakeLists.txt delete mode 100644 Tests/FindPython/Python3Embedded/CMakeLists.txt delete mode 100644 Tests/FindPython/Python3Fail/CMakeLists.txt delete mode 100644 Tests/FindPython/Python3Module/CMakeLists.txt delete mode 100644 Tests/FindPython/Python3SABIModule/CMakeLists.txt delete mode 100644 Tests/FindPython/RequiredArtifacts/CMakeLists.txt delete mode 100644 Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt delete mode 100644 Tests/FindPython/SOABI/CMakeLists.txt delete mode 100644 Tests/FindPython/TEST_spam.c delete mode 100644 Tests/FindPython/UnversionedNames/CMakeLists.txt delete mode 100644 Tests/FindPython/VersionRange/CMakeLists.txt delete mode 100644 Tests/FindPython/VirtualEnv/CMakeLists.txt delete mode 100644 Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake delete mode 100644 Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake delete mode 100644 Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake delete mode 100644 Tests/FindPython/VirtualEnvConda/CMakeLists.txt delete mode 100644 Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake delete mode 100644 Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake delete mode 100644 Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake delete mode 100644 Tests/FindPython/display_time.c delete mode 100644 Tests/FindPython/display_time.h delete mode 100644 Tests/FindPython/main.c delete mode 100644 Tests/FindPython/spam.c create mode 100644 Tests/RunCMake/FindPython/ArtifactsInteractive.cmake create mode 100644 Tests/RunCMake/FindPython/ArtifactsPrefix.cmake create mode 100644 Tests/RunCMake/FindPython/CMakeLists.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.Include-stderr.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.Interpreter-stderr.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.Library-stderr.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.Multiple-stderr.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.NumPy-stderr.txt create mode 100644 Tests/RunCMake/FindPython/CustomFailureMessage.cmake create mode 100644 Tests/RunCMake/FindPython/DifferentComponents.cmake create mode 100644 Tests/RunCMake/FindPython/ExactVersion.cmake create mode 100644 Tests/RunCMake/FindPython/FindPythonScript.cmake create mode 100644 Tests/RunCMake/FindPython/Implementation.cmake create mode 100644 Tests/RunCMake/FindPython/IronPython.cmake create mode 100644 Tests/RunCMake/FindPython/MultiplePackages.cmake create mode 100644 Tests/RunCMake/FindPython/NumPy.cmake create mode 100644 Tests/RunCMake/FindPython/NumPyOnly.cmake create mode 100644 Tests/RunCMake/FindPython/PyPy.cmake create mode 100644 Tests/RunCMake/FindPython/Python.cmake create mode 100644 Tests/RunCMake/FindPython/Python2-BadComponent-result.txt create mode 100644 Tests/RunCMake/FindPython/Python2-BadComponent-stderr.txt create mode 100644 Tests/RunCMake/FindPython/Python2-BadComponent.cmake create mode 100644 Tests/RunCMake/FindPython/Python2.cmake create mode 100644 Tests/RunCMake/FindPython/Python2Embedded.cmake create mode 100644 Tests/RunCMake/FindPython/Python2Module.cmake create mode 100644 Tests/RunCMake/FindPython/Python2SABIModule-result.txt create mode 100644 Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt create mode 100644 Tests/RunCMake/FindPython/Python2SABIModule.cmake create mode 100644 Tests/RunCMake/FindPython/Python3-BadComponent-result.txt create mode 100644 Tests/RunCMake/FindPython/Python3-BadComponent-stderr.txt create mode 100644 Tests/RunCMake/FindPython/Python3-BadComponent.cmake create mode 100644 Tests/RunCMake/FindPython/Python3.cmake create mode 100644 Tests/RunCMake/FindPython/Python3Embedded.cmake create mode 100644 Tests/RunCMake/FindPython/Python3Module.cmake create mode 100644 Tests/RunCMake/FindPython/Python3SABIModule.cmake create mode 100644 Tests/RunCMake/FindPython/PythonArtifacts.cmake.in create mode 100644 Tests/RunCMake/FindPython/RequiredArtifacts.cmake create mode 100644 Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake create mode 100644 Tests/RunCMake/FindPython/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/FindPython/SOABI.cmake create mode 100644 Tests/RunCMake/FindPython/TEST_spam.c create mode 100644 Tests/RunCMake/FindPython/UnversionedNames.cmake create mode 100644 Tests/RunCMake/FindPython/VersionRange.cmake create mode 100644 Tests/RunCMake/FindPython/VirtualEnv.cmake create mode 100644 Tests/RunCMake/FindPython/VirtualEnvConda.cmake create mode 100644 Tests/RunCMake/FindPython/VirtualEnvDefault.cmake create mode 100644 Tests/RunCMake/FindPython/VirtualEnvOnly.cmake create mode 100644 Tests/RunCMake/FindPython/VirtualEnvStandard.cmake create mode 100644 Tests/RunCMake/FindPython/arraytest.c create mode 100644 Tests/RunCMake/FindPython/display_time.c create mode 100644 Tests/RunCMake/FindPython/display_time.h create mode 100644 Tests/RunCMake/FindPython/main.c create mode 100644 Tests/RunCMake/FindPython/spam.c create mode 100644 Tests/RunCMake/FindPython/subdir/CMakeLists.txt diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 1c5641e..112af84 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -1085,7 +1085,7 @@ function (_PYTHON_VALIDATE_COMPILER) file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]])); sys.stdout.flush()\n") execute_process (COMMAND ${launcher} "${_${_PYTHON_PREFIX}_COMPILER}" ${_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS} - /target:exe /embed "${working_dir}/version.py" + /target:exe /embed /standalone "${working_dir}/version.py" WORKING_DIRECTORY "${working_dir}" OUTPUT_QUIET ERROR_QUIET @@ -2664,7 +2664,7 @@ if ("Compiler" IN_LIST ${_PYTHON_BASE}_FIND_COMPONENTS) file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]])); sys.stdout.flush()\n") execute_process (COMMAND ${_${_PYTHON_PREFIX}_COMPILER_LAUNCHER} "${_${_PYTHON_PREFIX}_COMPILER}" ${_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS} - /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" + /target:exe /embed /standalone "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" WORKING_DIRECTORY "${_${_PYTHON_PREFIX}_VERSION_DIR}" OUTPUT_QUIET ERROR_QUIET) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6617455..c8c1810 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -328,6 +328,36 @@ if(BUILD_TESTING) endif() endif() + if(CMake_TEST_FindPython) + set(CMake_TEST_FindPython2 TRUE) + set(CMake_TEST_FindPython3 TRUE) + endif() + if(CMake_TEST_FindPython_SABIModule) + set(CMake_TEST_FindPython2_SABIModule TRUE) + set(CMake_TEST_FindPython3_SABIModule TRUE) + endif() + if(CMake_TEST_FindPython_NumPy) + set(CMake_TEST_FindPython2_NumPy TRUE) + set(CMake_TEST_FindPython3_NumPy TRUE) + endif() + if(CMake_TEST_FindPython_Conda) + set(CMake_TEST_FindPython3_Conda TRUE) + endif() + if(CMake_TEST_FindPython_IronPython) + set(CMake_TEST_FindPython2_IronPython TRUE) + set(CMake_TEST_FindPython3_IronPython TRUE) + endif() + if(CMake_TEST_FindPython_PyPy) + set(CMake_TEST_FindPython2_PyPy TRUE) + set(CMake_TEST_FindPython3_PyPy TRUE) + endif() + if (CMake_TEST_FindPython2 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + set(CMake_TEST_FindPython2_SABIModule TRUE) + endif() + if (CMake_TEST_FindPython3 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + set(CMake_TEST_FindPython3_SABIModule TRUE) + endif() + # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, # whichever is greater. set(CMAKE_LONG_TEST_TIMEOUT 1500) @@ -1522,44 +1552,6 @@ if(BUILD_TESTING) add_subdirectory(GoogleTest) endif() - if(CMake_TEST_FindPython) - set(CMake_TEST_FindPython2 TRUE) - set(CMake_TEST_FindPython3 TRUE) - endif() - if(CMake_TEST_FindPython_SABIModule) - set(CMake_TEST_FindPython2_SABIModule TRUE) - set(CMake_TEST_FindPython3_SABIModule TRUE) - endif() - if(CMake_TEST_FindPython_NumPy) - set(CMake_TEST_FindPython2_NumPyy TRUE) - set(CMake_TEST_FindPython3_NumPy TRUE) - endif() - if(CMake_TEST_FindPython_Conda) - set(CMake_TEST_FindPython3_Conda TRUE) - endif() - if(CMake_TEST_FindPython_IronPython) - set(CMake_TEST_FindPython2_IronPython TRUE) - set(CMake_TEST_FindPython3_IronPython TRUE) - endif() - if(CMake_TEST_FindPython_PyPy) - set(CMake_TEST_FindPython2_PyPy TRUE) - set(CMake_TEST_FindPython3_PyPy TRUE) - endif() - if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3 - OR CMake_TEST_FindPython2_SABIModule OR CMake_TEST_FindPython3_SABIModule - OR CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy - OR CMake_TEST_FindPython3_Conda - OR CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython - OR CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy) - if (CMake_TEST_FindPython2 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") - set(CMake_TEST_FindPython2_SABIModule TRUE) - endif() - if (CMake_TEST_FindPython3 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") - set(CMake_TEST_FindPython3_SABIModule TRUE) - endif() - add_subdirectory(FindPython) - endif() - if(CMake_TEST_UseSWIG) add_subdirectory(UseSWIG) endif() diff --git a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt deleted file mode 100644 index f92db5f..0000000 --- a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestArtifactsInteractive LANGUAGES C) - -set (components Interpreter Development) -if (CMake_TEST_FindPython3_NumPy) - list (APPEND components NumPy) -endif() - -find_package(Python3 REQUIRED COMPONENTS ${components}) - -if (Python3_ARTIFACTS_INTERACTIVE) - if (NOT DEFINED CACHE{Python3_EXECUTABLE} - OR NOT DEFINED CACHE{Python3_LIBRARY} OR NOT DEFINED CACHE{Python3_INCLUDE_DIR} - OR (CMake_TEST_FindPython3_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) - message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=ON Failed.") - endif() -else() - if (DEFINED CACHE{Python3_EXECUTABLE} - OR DEFINED CACHE{Python3_LIBRARY} OR DEFINED CACHE{Python3_INCLUDE_DIR} - OR (CMake_TEST_FindPython3_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) - message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=OFF Failed.") - endif() -endif() diff --git a/Tests/FindPython/ArtifactsPrefix/CMakeLists.txt b/Tests/FindPython/ArtifactsPrefix/CMakeLists.txt deleted file mode 100644 index d007017..0000000 --- a/Tests/FindPython/ArtifactsPrefix/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.31) - -project(TestArtifactsPrefix C) - -set(Python_ARTIFACTS_PREFIX "_V2") -find_package (Python 2 EXACT REQUIRED) - -if(NOT Python_V2_FOUND OR NOT Python_FOUND) - message(FATAL_ERROR "Python v2 interpreter not found.") -endif() -if(NOT Python_V2_VERSION_MAJOR VERSION_EQUAL 2) - message(FATAL_ERROR "Python v2 interpreter: wrong major version.") -endif() - - -set(Python_ARTIFACTS_PREFIX "_V3") -find_package (Python 3 EXACT REQUIRED) - -if(NOT Python_V3_FOUND OR NOT Python_FOUND) - message(FATAL_ERROR "Python v3 interpreter not found.") -endif() -if(NOT Python_V3_VERSION_MAJOR VERSION_EQUAL 3) - message(FATAL_ERROR "Python v3 interpreter: wrong major version.") -endif() diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt deleted file mode 100644 index f275013..0000000 --- a/Tests/FindPython/CMakeLists.txt +++ /dev/null @@ -1,955 +0,0 @@ -if(CMake_TEST_FindPython2) - add_test(NAME FindPython.Python2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION" - ${build_generator_args} - --build-project TestPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION" - ${build_generator_args} - --build-project TestPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python2.Development.Module COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Module" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Module" - ${build_generator_args} - --build-project TestPython2Module - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python2Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail" - ${build_generator_args} - --build-project TestPython2Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - set_tests_properties(FindPython.Python2Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") - - add_test(NAME FindPython.Python.V2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.LOCATION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.V2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VERSION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python2.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=2 - -DPython_REQUESTED_VERSION=2.1.2 - -DPython2_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python2.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=2 - -DPython_REQUESTED_VERSION=2.1.2 - -DPython2_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python.V2.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 - -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.V2.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=2.1.2 - -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python2.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 - -DPython2_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.Python2.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 - -DPython2_FIND_STRATEGY=VERSION - ) - add_test(NAME FindPython.Python.V2.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=2 - -DPython_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.Python.V2.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V2.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=2 - -DPython_FIND_STRATEGY=VERSION - ) - - add_test(NAME FindPython.Python2Embedded COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Embedded" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2Embedded" - ${build_generator_args} - --build-project TestPython2Embedded - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.Python2.LOCATION FindPython.Python2.VERSION - FindPython.Python2.Development.Module FindPython.Python2Fail - FindPython.Python.V2.LOCATION FindPython.Python.V2.VERSION - FindPython.Python2.ExactVersion.LOCATION FindPython.Python2.ExactVersion.VERSION - FindPython.Python.V2.ExactVersion.LOCATION FindPython.Python.V2.ExactVersion.VERSION - FindPython.Python2.VersionRange.LOCATION FindPython.Python2.VersionRange.VERSION - FindPython.Python.V2.VersionRange.LOCATION FindPython.Python.V2.VersionRange.VERSION - FindPython.Python2Embedded - APPEND PROPERTY LABELS Python2) -endif() - -if(CMake_TEST_FindPython3) - add_test(NAME FindPython.Python3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION" - ${build_generator_args} - --build-project TestPython3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION" - ${build_generator_args} - --build-project TestPython3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python3.Development.Module COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Module" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3Module" - ${build_generator_args} - --build-project TestPython3Module - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python3Fail COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail" - ${build_generator_args} - --build-project TestPython3Fail - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - set_tests_properties(FindPython.Python3Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)") - - add_test(NAME FindPython.Python.V3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.LOCATION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.V3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VERSION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python3.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=3 - -DPython_REQUESTED_VERSION=3.1.2 - -DPython3_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python3.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_MAJOR_VERSION=3 - -DPython_REQUESTED_VERSION=3.1.2 - -DPython3_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.V3.ExactVersion.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.ExactVersion.LOCATION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=3.1.2 - -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.V3.ExactVersion.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ExactVersion" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.ExactVersion.VERSION" - ${build_generator_args} - --build-project TestExactVersion - --build-options ${build_options} -DPython_REQUESTED_VERSION=3.1.2 - -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.Python3.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 - -DPython3_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.Python3.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 - -DPython3_FIND_STRATEGY=VERSION - ) - add_test(NAME FindPython.Python.V3.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=3 - -DPython_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.Python.V3.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.V3.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python -DPython_REQUESTED_VERSION=3 - -DPython_FIND_STRATEGY=VERSION - ) - - add_test(NAME FindPython.VirtualEnv COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VirtualEnv" - "${CMake_BINARY_DIR}/Tests/FindPython/VirtualEnv" - ${build_generator_args} - --build-project TestVirtualEnv - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "4.8") - add_test(NAME FindPython.Python3Embedded COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Embedded" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3Embedded" - ${build_generator_args} - --build-project TestPython3Embedded - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - endif() - - add_test(NAME FindPython.RequiredArtifacts COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts" - ${build_generator_args} - --build-project TestRequiredArtifacts - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython3_SABIModule=${CMake_TEST_FindPython3_SABIModule}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.ArtifactsInteractive.ON COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ArtifactsInteractive" - "${CMake_BINARY_DIR}/Tests/FindPython/ArtifactsInteractive.ON" - ${build_generator_args} - --build-project TestArtifactsScope - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" - "-DPython3_ARTIFACTS_INTERACTIVE=ON" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.ArtifactsInteractive.OFF COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ArtifactsInteractive" - "${CMake_BINARY_DIR}/Tests/FindPython/ArtifactsInteractive.OFF" - ${build_generator_args} - --build-project TestArtifactsScope - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" - "-DPython3_ARTIFACTS_INTERACTIVE=OFF" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.CustomFailureMessage COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage" - ${build_generator_args} - --build-project TestCustomFailureMessage - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}" - --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 $ - ) - - set_property(TEST FindPython.Python3.LOCATION FindPython.Python3.VERSION - FindPython.Python3.Development.Module FindPython.Python3Fail - FindPython.Python.V3.LOCATION FindPython.Python.V3.VERSION - FindPython.Python3.ExactVersion.LOCATION FindPython.Python3.ExactVersion.VERSION - FindPython.Python.V3.ExactVersion.LOCATION FindPython.Python.V3.ExactVersion.VERSION - FindPython.Python3.VersionRange.LOCATION FindPython.Python3.VersionRange.VERSION - FindPython.Python.V3.VersionRange.LOCATION FindPython.Python.V3.VersionRange.VERSION - FindPython.VirtualEnv FindPython.RequiredArtifacts - FindPython.ArtifactsInteractive.ON FindPython.ArtifactsInteractive.OFF - FindPython.CustomFailureMessage FindPython.DifferentComponents - APPEND PROPERTY LABELS Python3) - if(TEST FindPython.Python3Embedded) - set_property(TEST FindPython.Python3Embedded APPEND PROPERTY LABELS Python3) - endif() - - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_test(NAME FindPython.UnversionedNames COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/UnversionedNames" - "${CMake_BINARY_DIR}/Tests/FindPython/UnversionedNames" - ${build_generator_args} - --build-project UnversionedNames - --build-options ${build_options} - ) - set_property(TEST FindPython.UnversionedNames APPEND PROPERTY LABELS Python3) - endif() -endif() - -if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) - add_test(NAME FindPython.Python.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.LOCATION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Python.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python" - "${CMake_BINARY_DIR}/Tests/FindPython/Python.VERSION" - ${build_generator_args} - --build-project TestPython - --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION - --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 $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/SOABI" - "${CMake_BINARY_DIR}/Tests/FindPython/SOABI.Interpreter" - ${build_generator_args} - --build-project TestSOABI - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_COMPONENT=Interpreter" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Development.SOABI COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/SOABI" - "${CMake_BINARY_DIR}/Tests/FindPython/SOABI.Development" - ${build_generator_args} - --build-project TestSOABI - --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" - "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" - "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" - "-DCMake_TEST_FindPython_COMPONENT=Development" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.Interpreter.SOABI FindPython.Development.SOABI - APPEND PROPERTY LABELS Python2 Python3) - endif() - - add_test(NAME FindPython.MultiplePackages COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages" - "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages" - ${build_generator_args} - --build-project TestMultiplePackages - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.Python.LOCATION FindPython.Python.VERSION FindPython.MultiplePackages - APPEND PROPERTY LABELS Python2 Python3) -endif() - -if(CMake_TEST_FindPython2 AND CMake_TEST_FindPython3) - add_test(NAME FindPython.ArtifactsPrefix COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/ArtifactsPrefix" - "${CMake_BINARY_DIR}/Tests/FindPython/ArtifactsPrefix" - ${build_generator_args} - --build-project TestArtifactsPrefix - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.ArtifactsPrefix - APPEND PROPERTY LABELS Python2 Python3) -endif() - -if(CMake_TEST_FindPython2_SABIModule) - add_test(NAME FindPython.Python2.Development.SABIModule COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python2SABIModule" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2SABIModule" - ${build_generator_args} - --build-project TestPython2SABIModule - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - set_tests_properties(FindPython.Python2.Development.SABIModule PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: .*Development\\.SABIModule") - set_property(TEST FindPython.Python2.Development.SABIModule APPEND PROPERTY LABELS Python2) -endif() - -if(CMake_TEST_FindPython3_SABIModule) - # Use exclusively Release configuration because Debug is, on Windows with MSVC, - # unusable with SABI: Python force link with debug version of full versioned library rather than - # the stable ABI one. - add_test(NAME FindPython.Python3.Development.SABIModule COMMAND - ${CMAKE_CTEST_COMMAND} -C Release - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Python3SABIModule" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3SABIModule" - ${build_generator_args} - --build-project TestPython3SABIModule - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C Release - ) - set_property(TEST FindPython.Python3.Development.SABIModule APPEND PROPERTY LABELS Python3) -endif() - -if(CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy) - add_test(NAME FindPython.NumPy COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/NumPy" - "${CMake_BINARY_DIR}/Tests/FindPython/NumPy" - ${build_generator_args} - --build-project TestNumPy - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.NumPyOnly COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/NumPyOnly" - "${CMake_BINARY_DIR}/Tests/FindPython/NumPyOnly" - ${build_generator_args} - --build-project TestNumPyOnly - --build-options ${build_options} - ) - - set_property(TEST FindPython.NumPy FindPython.NumPyOnly APPEND PROPERTY LABELS Python2 Python3) -endif() - -if(CMake_TEST_FindPython3_Conda) - add_test(NAME FindPython.VirtualEnvConda COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VirtualEnvConda" - "${CMake_BINARY_DIR}/Tests/FindPython/VirtualEnvConda" - ${build_generator_args} - --build-project TestVirtualEnvConda - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - set_property(TEST FindPython.VirtualEnvConda APPEND PROPERTY LABELS Python3) -endif() - -if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython) - add_test(NAME FindPython.Implementation.CPython2 COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython2" - ${build_generator_args} - --build-project TestImplementationCPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATIONS=CPython - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Implementation.IronPython2 COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython2" - ${build_generator_args} - --build-project TestImplementationIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATION=IronPython - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.Implementation.CPython2 FindPython.Implementation.IronPython2 - APPEND PROPERTY LABELS Python2) -endif() - -if (CMake_TEST_FindPython3 AND CMake_TEST_FindPython3_IronPython) - add_test(NAME FindPython.Implementation.CPython3 COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython3" - ${build_generator_args} - --build-project TestImplementationCPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATIONS=CPython - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.Implementation.IronPython3 COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation" - "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython3" - ${build_generator_args} - --build-project TestImplementationIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATION=IronPython - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.Implementation.CPython3 FindPython.Implementation.IronPython3 - APPEND PROPERTY LABELS Python3) -endif() - -if(CMake_TEST_FindPython2_IronPython) - add_test(NAME FindPython.IronPython2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.LOCATION" - ${build_generator_args} - --build-project TestIronPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.IronPython2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython2" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VERSION" - ${build_generator_args} - --build-project TestIronPython2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.IronPython.V2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V2.LOCATION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.IronPython.V2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V2.VERSION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.IronPython2.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 - -DPython2_FIND_IMPLEMENTATIONS=IronPython - -DPython2_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.IronPython2.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython2.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python2 -DPython_REQUESTED_VERSION=2 - -DPython2_FIND_IMPLEMENTATIONS=IronPython - -DPython2_FIND_STRATEGY=VERSION - ) - - set_property(TEST FindPython.IronPython2.LOCATION FindPython.IronPython2.VERSION - FindPython.IronPython.V2.LOCATION FindPython.IronPython.V2.VERSION - FindPython.IronPython2.VersionRange.LOCATION FindPython.IronPython2.VersionRange.VERSION - APPEND PROPERTY LABELS Python2) -endif() - -if(CMake_TEST_FindPython3_IronPython) - add_test(NAME FindPython.IronPython3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.LOCATION" - ${build_generator_args} - --build-project TestIronPython3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.IronPython3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VERSION" - ${build_generator_args} - --build-project TestIronPython3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.IronPython.V3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.LOCATION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.IronPython.V3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.VERSION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.IronPython3.VersionRange.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.LOCATION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 - -DPython3_FIND_IMPLEMENTATIONS=IronPython - -DPython3_FIND_STRATEGY=LOCATION - ) - add_test(NAME FindPython.IronPython3.VersionRange.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.VERSION" - ${build_generator_args} - --build-project TestVersionRange - --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3 - -DPython3_FIND_IMPLEMENTATIONS=IronPython - -DPython3_FIND_STRATEGY=VERSION - ) - - set_property(TEST FindPython.IronPython3.LOCATION FindPython.IronPython3.VERSION - FindPython.IronPython.V3.LOCATION FindPython.IronPython.V3.VERSION - FindPython.IronPython3.VersionRange.LOCATION FindPython.IronPython3.VersionRange.VERSION - APPEND PROPERTY LABELS Python3) -endif() - -if(CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython) - add_test(NAME FindPython.IronPython.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.IronPython.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython" - "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION" - ${build_generator_args} - --build-project TestIronPython - --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.IronPython.LOCATION FindPython.IronPython.VERSION - APPEND PROPERTY LABELS Python2 Python3) -endif() - -if(CMake_TEST_FindPython2_PyPy) - add_test(NAME FindPython.PyPy2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.LOCATION" - ${build_generator_args} - --build-project TestPyPy2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.PyPy2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy2" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy2.VERSION" - ${build_generator_args} - --build-project TestPyPy2 - --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.PyPy.V2.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V2.LOCATION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.PyPy.V2.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V2.VERSION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.PyPy2.LOCATION FindPython.PyPy2.VERSION - FindPython.PyPy.V2.LOCATION FindPython.PyPy.V2.VERSION - APPEND PROPERTY LABELS Python2) -endif() - -if(CMake_TEST_FindPython3_PyPy) - add_test(NAME FindPython.PyPy3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.LOCATION" - ${build_generator_args} - --build-project TestPyPy3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.PyPy3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.VERSION" - ${build_generator_args} - --build-project TestPyPy3 - --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - add_test(NAME FindPython.PyPy.V3.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V3.LOCATION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.PyPy.V3.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V3.VERSION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.PyPy3.LOCATION FindPython.PyPy3.VERSION - FindPython.PyPy.V3.LOCATION FindPython.PyPy.V3.VERSION - APPEND PROPERTY LABELS Python3) -endif() - -if(CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy) - add_test(NAME FindPython.PyPy.LOCATION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.LOCATION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.PyPy.VERSION COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy" - "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.VERSION" - ${build_generator_args} - --build-project TestPyPy - --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - - set_property(TEST FindPython.PyPy.LOCATION FindPython.PyPy.VERSION - APPEND PROPERTY LABELS Python2 Python3) -endif() diff --git a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt deleted file mode 100644 index e9d14f5..0000000 --- a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestCustomFailureMessage LANGUAGES NONE) - -include(CTest) - -add_test(NAME FindPython.CustomFailureMessage.Interpreter COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Interpreter" - ${build_generator_args} - --build-project TestCustomFailureMessage.Check - --build-options "-DCHECK_COMPONENTS=Interpreter" - "-DPython3_EXECUTABLE=/not/found/interpreter" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -set_tests_properties(FindPython.CustomFailureMessage.Interpreter PROPERTIES - PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter") - -add_test(NAME FindPython.CustomFailureMessage.Library COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Library" - ${build_generator_args} - --build-project TestCustomFailureMessage.Check - --build-options "-DCHECK_COMPONENTS=Development" - "-DPython3_LIBRARY=/not/found/library" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -set_tests_properties(FindPython.CustomFailureMessage.Library PROPERTIES - PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the library") - -add_test(NAME FindPython.CustomFailureMessage.Include COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Include" - ${build_generator_args} - --build-project TestCustomFailureMessage.Check - --build-options "-DCHECK_COMPONENTS=Development" - "-DPython3_INCLUDE_DIR=/not/found/include" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -set_tests_properties(FindPython.CustomFailureMessage.Include PROPERTIES - PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the directory") - -add_test(NAME FindPython.CustomFailureMessage.Multiple COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Multiple" - ${build_generator_args} - --build-project TestCustomFailureMessage.Check - --build-options "-DCHECK_COMPONENTS=Interpreter;Development" - "-DPython3_EXECUTABLE=/not/found/interpreter" - "-DPython3_LIBRARY=/not/found/library" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -set_tests_properties(FindPython.CustomFailureMessage.Multiple PROPERTIES - PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter.+Development: Cannot find the library") - - -if (CMake_TEST_FindPython3_NumPy) - add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/NumPy" - ${build_generator_args} - --build-project TestCustomFailureMessage.Check - --build-options "-DCHECK_COMPONENTS=Interpreter;Development;NumPy" - "-DPython3_NumPy_INCLUDE_DIR=/not/found/numpy/include" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - set_tests_properties(FindPython.CustomFailureMessage.NumPy PROPERTIES - PASS_REGULAR_EXPRESSION "Reason given by package:.+NumPy: Cannot find the directory") -endif() diff --git a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt deleted file mode 100644 index d72d258..0000000 --- a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestCustomFailureMessage.Check LANGUAGES NONE) - -find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS}) diff --git a/Tests/FindPython/DifferentComponents/CMakeLists.txt b/Tests/FindPython/DifferentComponents/CMakeLists.txt deleted file mode 100644 index e72b4bf..0000000 --- a/Tests/FindPython/DifferentComponents/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -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 deleted file mode 100644 index 98fcd5f..0000000 --- a/Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ - -find_package(Python3 REQUIRED COMPONENTS Development) diff --git a/Tests/FindPython/ExactVersion/CMakeLists.txt b/Tests/FindPython/ExactVersion/CMakeLists.txt deleted file mode 100644 index e3bb43b..0000000 --- a/Tests/FindPython/ExactVersion/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestExactVersion LANGUAGES C) - -find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) -if(NOT Python${Python_MAJOR_VERSION}_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") -endif() -if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") -endif() -if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") -endif() - -if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Interpreter not found") -endif() - -if(NOT TARGET Python${Python_MAJOR_VERSION}::Python) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Python not found") -endif() -if(NOT TARGET Python${Python_MAJOR_VERSION}::Module) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Module not found") -endif() - - -# reset artifacts and second search with exact version already founded -unset(Python${Python_MAJOR_VERSION}_EXECUTABLE) -unset(_Python${Python_MAJOR_VERSION}_EXECUTABLE CACHE) - -unset(_Python${Python_MAJOR_VERSION}_LIBRARY_RELEASE CACHE) -unset(_Python${Python_MAJOR_VERSION}_INCLUDE_DIR CACHE) - -set(Python_REQUESTED_VERSION ${Python${Python_MAJOR_VERSION}_VERSION}) -find_package(Python${Python_MAJOR_VERSION} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development) -if(NOT Python${Python_MAJOR_VERSION}_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") -endif() -if(NOT Python${Python_MAJOR_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") -endif() -if(NOT Python${Python_MAJOR_VERSION}_Development_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") -endif() - -if(NOT TARGET Python${Python_MAJOR_VERSION}::Interpreter) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Interpreter not found") -endif() - -if(NOT TARGET Python${Python_MAJOR_VERSION}::Python) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Python not found") -endif() -if(NOT TARGET Python${Python_MAJOR_VERSION}::Module) - message(SEND_ERROR "Python${Python_MAJOR_VERSION}::Module not found") -endif() diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake deleted file mode 100644 index fa51f59..0000000 --- a/Tests/FindPython/FindPythonScript.cmake +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -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/Implementation/CMakeLists.txt b/Tests/FindPython/Implementation/CMakeLists.txt deleted file mode 100644 index da33034..0000000 --- a/Tests/FindPython/Implementation/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} LANGUAGES NONE) - - -set (Python${Python_REQUESTED_VERSION}_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) - -find_package(Python${Python_REQUESTED_VERSION} COMPONENTS Interpreter) -if (NOT Python${Python_REQUESTED_VERSION}_FOUND OR NOT Python${Python_REQUESTED_VERSION}_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python${Python_REQUESTED_VERSION}") -endif() - -if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" - AND NOT Python${Python_REQUESTED_VERSION}_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python${Python_REQUESTED_VERSION}_INTERPRETER_ID})") -endif() -if (Python_REQUESTED_IMPLEMENTATION STREQUAL "CPython" - AND Python${Python_REQUESTED_VERSION}_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python${Python_REQUESTED_VERSION}_INTERPRETER_ID})") -endif() - - -set (Python_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) - -find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter) -if (NOT Python_FOUND OR NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") -endif() - -if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" - AND NOT Python_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") -endif() -if (Python_REQUESTED_IMPLEMENTATION STREQUAL "CPython" - AND Python_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") -endif() diff --git a/Tests/FindPython/IronPython/CMakeLists.txt b/Tests/FindPython/IronPython/CMakeLists.txt deleted file mode 100644 index 3c28527..0000000 --- a/Tests/FindPython/IronPython/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestIronPython LANGUAGES NONE) - -set (Python_FIND_IMPLEMENTATIONS IronPython) - -find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Compiler) -if (NOT Python_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") -endif() - -if (NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python Interpreter") -endif() -if (NOT Python_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") -endif() - -if (NOT Python_Compiler_FOUND) - message (FATAL_ERROR "Failed to find Python Compiler") -endif() -if (NOT Python_COMPILER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous compiler ID (${Python_COMPILER_ID})") -endif() - -if(NOT TARGET Python::Interpreter) - message(SEND_ERROR "Python::Interpreter not found") -endif() -if(NOT TARGET Python::Compiler) - message(SEND_ERROR "Python::Interpreter not found") -endif() diff --git a/Tests/FindPython/IronPython2/CMakeLists.txt b/Tests/FindPython/IronPython2/CMakeLists.txt deleted file mode 100644 index 0a4dcb4..0000000 --- a/Tests/FindPython/IronPython2/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestIronPython2 LANGUAGES NONE) - -set (Python2_FIND_IMPLEMENTATIONS "IronPython") - -find_package(Python2 COMPONENTS Interpreter Compiler) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") -endif() - -if (NOT Python2_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python 2 Interpreter") -endif() -if (NOT Python2_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})") -endif() - -if (NOT Python2_Compiler_FOUND) - message (FATAL_ERROR "Failed to find Python 2 Compiler") -endif() -if (NOT Python2_COMPILER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous compiler ID (${Python2_COMPILER_ID})") -endif() - -if(NOT TARGET Python2::Interpreter) - message(SEND_ERROR "Python2::Interpreter not found") -endif() -if(NOT TARGET Python2::Compiler) - message(SEND_ERROR "Python2::Compiler not found") -endif() diff --git a/Tests/FindPython/IronPython3/CMakeLists.txt b/Tests/FindPython/IronPython3/CMakeLists.txt deleted file mode 100644 index f39b84d..0000000 --- a/Tests/FindPython/IronPython3/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestIronPython3 LANGUAGES NONE) - -set (Python3_FIND_IMPLEMENTATIONS "IronPython") - -find_package(Python3 COMPONENTS Interpreter Compiler) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() - -if (NOT Python3_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python 3 Interpreter") -endif() -if (NOT Python3_INTERPRETER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})") -endif() - -if (NOT Python3_Compiler_FOUND) - message (FATAL_ERROR "Failed to find Python 3 Compiler") -endif() -if (NOT Python3_COMPILER_ID STREQUAL "IronPython") - message (FATAL_ERROR "Erroneous compiler ID (${Python3_COMPILER_ID})") -endif() - -if(NOT TARGET Python3::Interpreter) - message(SEND_ERROR "Python3::Interpreter not found") -endif() -if(NOT TARGET Python3::Compiler) - message(SEND_ERROR "Python3::Compiler not found") -endif() diff --git a/Tests/FindPython/MultiplePackages/CMakeLists.txt b/Tests/FindPython/MultiplePackages/CMakeLists.txt deleted file mode 100644 index 6536e46..0000000 --- a/Tests/FindPython/MultiplePackages/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestMultiplePackages C) - -find_package (Python REQUIRED) - -if (CMake_TEST_FindPython2) - find_package (Python2 REQUIRED COMPONENTS Interpreter Development) - - if (NOT CMake_TEST_FindPython3 AND NOT Python2_EXECUTABLE STREQUAL Python_EXECUTABLE) - message (FATAL_ERROR - "Python interpreters do not match:\n" - " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" - " Python2_EXECUTABLE='${Python3_EXECUTABLE}'\n" - ) - endif() - - Python2_add_library (spam2 MODULE ../spam.c) - target_compile_definitions (spam2 PRIVATE PYTHON2) - - add_test (NAME python2_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") - -endif() - -if (CMake_TEST_FindPython3) - find_package (Python3 REQUIRED COMPONENTS Interpreter Development) - - if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE) - message (FATAL_ERROR - "Python interpreters do not match:\n" - " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" - " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n" - ) - endif() - - Python3_add_library (spam3 MODULE ../spam.c) - target_compile_definitions (spam3 PRIVATE PYTHON3) - - add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") - -endif() diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt deleted file mode 100644 index c5552d8..0000000 --- a/Tests/FindPython/NumPy/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestNumPy LANGUAGES C) - -if(CMake_TEST_FindPython2_NumPy) - - find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) - - Python2_add_library (arraytest2 MODULE arraytest.c) - target_compile_definitions (arraytest2 PRIVATE PYTHON2) - target_link_libraries (arraytest2 PRIVATE Python2::NumPy) - - add_test (NAME python2_arraytest - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_INTERPRETER}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") - -endif() - -if(CMake_TEST_FindPython3_NumPy) - - find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) - - Python3_add_library (arraytest3 MODULE arraytest.c) - target_compile_definitions (arraytest3 PRIVATE PYTHON3) - target_link_libraries (arraytest3 PRIVATE Python3::NumPy) - - add_test (NAME python3_arraytest - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_INTERPRETER}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") - -endif() diff --git a/Tests/FindPython/NumPy/arraytest.c b/Tests/FindPython/NumPy/arraytest.c deleted file mode 100644 index 51db7bc..0000000 --- a/Tests/FindPython/NumPy/arraytest.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "Python.h" - -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION -#include - -#include "numpy/arrayobject.h" - -static PyObject* vecsq(PyObject* self, PyObject* args); - -static PyMethodDef arraytestMethods[] = { { "vecsq", vecsq, METH_VARARGS }, - { NULL, NULL } }; - -static PyObject* vecsq(PyObject* self, PyObject* args) -{ - PyArrayObject *vecin, *vecout; - npy_intp dims[2]; - double *cin, *cout; - int i, j, n, m; - - if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &vecin)) - return NULL; - - n = dims[0] = PyArray_NDIM(vecin); - vecout = (PyArrayObject*)PyArray_SimpleNew(1, dims, NPY_DOUBLE); - - cin = (double*)PyArray_DATA(vecin); - cout = (double*)PyArray_DATA(vecout); - - for (i = 0; i < n; i++) { - cout[i] = cin[i] * cin[i]; - } - return PyArray_Return(vecout); -} - -#if defined(PYTHON2) -PyMODINIT_FUNC init_C_arraytest(void) -{ - (void)Py_InitModule("arraytest2", arraytestMethods); - import_array(); -} -#endif - -#if defined(PYTHON3) -static struct PyModuleDef arraytestmodule = { - PyModuleDef_HEAD_INIT, "arraytest3", /* name of module */ - NULL, /* module documentation, may be NULL */ - -1, /* size of per-interpreter state of the module, - or -1 if the module keeps state in global variables. */ - arraytestMethods -}; - -PyMODINIT_FUNC PyInit_C_arraytest(void) -{ - PyObject* po = PyModule_Create(&arraytestmodule); - import_array(); - return po; -} -#endif diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt deleted file mode 100644 index db7e68e..0000000 --- a/Tests/FindPython/NumPyOnly/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestNumPyOnly LANGUAGES C) - -if(CMake_TEST_FindPython2_NumPy) - - find_package(Python2 REQUIRED COMPONENTS NumPy) - - Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c) - target_compile_definitions (arraytest2 PRIVATE PYTHON2) - target_link_libraries (arraytest2 PRIVATE Python2::NumPy) - -endif() - - -if(CMake_TEST_FindPython3_NumPy) - -find_package(Python3 REQUIRED COMPONENTS NumPy) - -Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c) -target_compile_definitions (arraytest3 PRIVATE PYTHON3) -target_link_libraries (arraytest3 PRIVATE Python3::NumPy) - -endif() diff --git a/Tests/FindPython/PyPy/CMakeLists.txt b/Tests/FindPython/PyPy/CMakeLists.txt deleted file mode 100644 index 2e8bc58..0000000 --- a/Tests/FindPython/PyPy/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPyPy LANGUAGES C) - -set (Python_FIND_IMPLEMENTATIONS PyPy) - -find_package(Python ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) -if (NOT Python_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION}") -endif() - -if (NOT Python_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy Interpreter") -endif() -if (NOT Python_INTERPRETER_ID STREQUAL "PyPy") - message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") -endif() - -if (NOT Python_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Module") -endif() -if (NOT Python_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development.Embed") -endif() -if (NOT Python_Development_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy ${Python_REQUESTED_VERSION} Development") -endif() - -if(NOT TARGET Python::Interpreter) - message(SEND_ERROR "Python::Interpreter not found") -endif() -if(NOT TARGET Python::Module) - message(SEND_ERROR "Python::Module not found") -endif() -if(NOT TARGET Python::Python) - message(SEND_ERROR "Python::Python not found") -endif() diff --git a/Tests/FindPython/PyPy2/CMakeLists.txt b/Tests/FindPython/PyPy2/CMakeLists.txt deleted file mode 100644 index 2d89531..0000000 --- a/Tests/FindPython/PyPy2/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPyPy2 LANGUAGES C) - -set (Python2_FIND_IMPLEMENTATIONS "PyPy") - -find_package(Python2 COMPONENTS Interpreter Development) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 2") -endif() - -if (NOT Python2_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 2 Interpreter") -endif() -if (NOT Python2_INTERPRETER_ID STREQUAL "PyPy") - message (FATAL_ERROR "Erroneous interpreter ID (${Python2_INTERPRETER_ID})") -endif() - -if (NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Module") -endif() -if (NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 2 Development.Embed") -endif() -if (NOT Python2_Development_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 2 Development") -endif() - -if(NOT TARGET Python2::Interpreter) - message(SEND_ERROR "Python2::Interpreter not found") -endif() -if(NOT TARGET Python2::Module) - message(SEND_ERROR "Python2::Module not found") -endif() -if(NOT TARGET Python2::Python) - message(SEND_ERROR "Python2::Python not found") -endif() diff --git a/Tests/FindPython/PyPy3/CMakeLists.txt b/Tests/FindPython/PyPy3/CMakeLists.txt deleted file mode 100644 index 93388a0..0000000 --- a/Tests/FindPython/PyPy3/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPyPy3 LANGUAGES C) - -set (Python3_FIND_IMPLEMENTATIONS "PyPy") - -find_package(Python3 COMPONENTS Interpreter Development) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 3") -endif() - -if (NOT Python3_Interpreter_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 3 Interpreter") -endif() -if (NOT Python3_INTERPRETER_ID STREQUAL "PyPy") - message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})") -endif() - -if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Module") -endif() -if (NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 3 Development.Embed") -endif() -if (NOT Python3_Development_FOUND) - message (FATAL_ERROR "Failed to find Python PyPy 3 Development") -endif() - -if(NOT TARGET Python3::Interpreter) - message(SEND_ERROR "Python3::Interpreter not found") -endif() -if(NOT TARGET Python3::Module) - message(SEND_ERROR "Python3::Module not found") -endif() -if(NOT TARGET Python3::Python) - message(SEND_ERROR "Python3::Python not found") -endif() diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt deleted file mode 100644 index 187a2e2..0000000 --- a/Tests/FindPython/Python/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython LANGUAGES C) - -include(CTest) - -find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) -if (NOT Python_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") -endif() -if (NOT Python_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'") -endif() -if (NOT Python_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'") -endif() - -if(NOT TARGET Python::Interpreter) - message(SEND_ERROR "Python::Interpreter not found") -endif() - -if(NOT TARGET Python::Python) - message(SEND_ERROR "Python::Python not found") -endif() -if(NOT TARGET Python::Module) - message(SEND_ERROR "Python::Module not found") -endif() - -if (Python_REQUESTED_VERSION) - Python_add_library (spam${Python_REQUESTED_VERSION} MODULE ../spam.c) - target_compile_definitions (spam${Python_REQUESTED_VERSION} PRIVATE PYTHON${Python_REQUESTED_VERSION}) - - add_test (NAME python_spam${Python_REQUESTED_VERSION} - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python_INTERPRETER}" -c "import spam${Python_REQUESTED_VERSION}; spam${Python_REQUESTED_VERSION}.system(\"cd\")") -else() - add_test(NAME findpython_script - COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python - -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake") -endif() - - -# -# New search with user's prefix -# -foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) - unset(Python_${item}) -endforeach() - -set(Python_ARTIFACTS_PREFIX "_TEST") -find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) -if (NOT Python_TEST_FOUND OR NOT Python_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} (TEST prefix)") -endif() -if (NOT Python_TEST_Development.Module_FOUND OR NOT Python_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module' (TEST prefix)") -endif() -if (NOT Python_TEST_Development.Embed_FOUND OR NOT Python_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed' (TEST prefix)") -endif() - -if(NOT TARGET Python_TEST::Interpreter) - message(SEND_ERROR "Python_TEST::Interpreter not found") -endif() - -if(NOT TARGET Python_TEST::Python) - message(SEND_ERROR "Python_TEST::Python not found") -endif() -if(NOT TARGET Python_TEST::Module) - message(SEND_ERROR "Python_TEST::Module not found") -endif() - -if (Python_REQUESTED_VERSION) - Python_TEST_add_library (TEST_spam${Python_REQUESTED_VERSION} MODULE ../TEST_spam.c) - target_compile_definitions (TEST_spam${Python_REQUESTED_VERSION} PRIVATE PYTHON${Python_REQUESTED_VERSION}) - - add_test (NAME python_TEST_spam${Python_REQUESTED_VERSION} - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python_INTERPRETER}" -c "import TEST_spam${Python_REQUESTED_VERSION}; TEST_spam${Python_REQUESTED_VERSION}.system(\"cd\")") -endif() diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt deleted file mode 100644 index ffbb140..0000000 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython2 LANGUAGES C) - -include(CTest) - -find_package(Python2 3 QUIET) -if (Python2_FOUND) - message (FATAL_ERROR "Wrong python version found: ${Python2_VERSION}") -endif() - -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") -endif() -if (NOT Python2_Development_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development' component") -endif() -if (NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component") -endif() -if (NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component") -endif() - -if(NOT TARGET Python2::Interpreter) - message(SEND_ERROR "Python2::Interpreter not found") -endif() - -if(NOT TARGET Python2::Python) - message(SEND_ERROR "Python2::Python not found") -endif() -if(NOT TARGET Python2::Module) - message(SEND_ERROR "Python2::Module not found") -endif() - -Python2_add_library (spam2 MODULE ../spam.c) -target_compile_definitions (spam2 PRIVATE PYTHON2) - -add_test (NAME python2_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") - -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") - - -# -# New search with user's prefix -# -foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) - unset(Python2_${item}) -endforeach() - -set(Python2_ARTIFACTS_PREFIX "_TEST") -find_package(Python2 REQUIRED COMPONENTS Interpreter Development) -if (NOT Python2_TEST_FOUND OR NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2 (TEST prefix)") -endif() -if (NOT Python2_TEST_Development_FOUND OR NOT Python2_Development_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development' component (TEST prefix)") -endif() -if (NOT Python2_TEST_Development.Module_FOUND OR NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component (TEST prefix)") -endif() -if (NOT Python2_TEST_Development.Embed_FOUND OR NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component (TEST prefix)") -endif() - -if(NOT TARGET Python2_TEST::Interpreter) - message(SEND_ERROR "Python2_TEST::Interpreter not found") -endif() - -if(NOT TARGET Python2_TEST::Python) - message(SEND_ERROR "Python2_TEST::Python not found") -endif() -if(NOT TARGET Python2_TEST::Module) - message(SEND_ERROR "Python2_TEST::Module not found") -endif() - -Python2_TEST_add_library (TEST_spam2 MODULE ../TEST_spam.c) -target_compile_definitions (TEST_spam2 PRIVATE PYTHON2) - -add_test (NAME python2_TEST_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_INTERPRETER}" -c "import TEST_spam2; TEST_spam2.system(\"cd\")") diff --git a/Tests/FindPython/Python2Embedded/CMakeLists.txt b/Tests/FindPython/Python2Embedded/CMakeLists.txt deleted file mode 100644 index 0a04f70..0000000 --- a/Tests/FindPython/Python2Embedded/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython2Embedded LANGUAGES C) - -include(CTest) - -find_package(Python2 REQUIRED COMPONENTS Development.Embed) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") -endif() -if (Python2_Development_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") -endif() -if (Python2_Development.Module_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' unexpectedly found") -endif() -if (NOT Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' not found") -endif() - -if(TARGET Python2::Module) - message(SEND_ERROR "Python2::Module unexpectedly found") -endif() - -if(NOT TARGET Python2::Python) - message(SEND_ERROR "Python2::Python not found") -endif() - -Python2_add_library (display_time2 SHARED ../display_time.c) -set_property (TARGET display_time2 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) -target_compile_definitions (display_time2 PRIVATE PYTHON2) - -add_executable (main2 ../main.c) -target_link_libraries (main2 PRIVATE display_time2) - -if (WIN32 OR CYGWIN OR MSYS OR MINGW) - list (JOIN Python2_RUNTIME_LIBRARY_DIRS "$" RUNTIME_DIRS) - add_test (NAME Python2.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $) -else() - add_test (NAME Python2.Embedded COMMAND main2) -endif() -set_property (TEST Python2.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/FindPython/Python2Fail/CMakeLists.txt b/Tests/FindPython/Python2Fail/CMakeLists.txt deleted file mode 100644 index 7f7b906..0000000 --- a/Tests/FindPython/Python2Fail/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython2Fail C) - -include(CTest) - -find_package(Python2 REQUIRED COMPONENTS Interpreter Development foobar) - -Python2_add_library (spam2 MODULE ../spam.c) -target_compile_definitions (spam2 PRIVATE PYTHON2) - -add_test (NAME python2_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")") diff --git a/Tests/FindPython/Python2Module/CMakeLists.txt b/Tests/FindPython/Python2Module/CMakeLists.txt deleted file mode 100644 index 6fffad4..0000000 --- a/Tests/FindPython/Python2Module/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython2Module LANGUAGES C) - -include(CTest) - -find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module) -if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") -endif() -if (Python2_Development_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") -endif() -if (Python2_Development.Embed_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' unexpectedly found") -endif() -if (NOT Python2_Development.Module_FOUND) - message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' not found") -endif() - -if(NOT TARGET Python2::Interpreter) - message(SEND_ERROR "Python2::Interpreter not found") -endif() - -if(TARGET Python2::Python) - message(SEND_ERROR "Python2::Python unexpectedly found") -endif() -if(NOT TARGET Python2::Module) - message(SEND_ERROR "Python2::Module not found") -endif() - -Python2_add_library (spam2 MODULE ../spam.c) -target_compile_definitions (spam2 PRIVATE PYTHON2) - -add_test (NAME python2_spam2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") diff --git a/Tests/FindPython/Python2SABIModule/CMakeLists.txt b/Tests/FindPython/Python2SABIModule/CMakeLists.txt deleted file mode 100644 index c43dedc..0000000 --- a/Tests/FindPython/Python2SABIModule/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython2SABIModule LANGUAGES C) - -find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module Development.SABIModule) diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt deleted file mode 100644 index bac6ed5..0000000 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython3 LANGUAGES C) - -include(CTest) - -find_package(Python3 2 QUIET) -if (Python3_FOUND) - message (FATAL_ERROR "Wrong python version found: ${Python3_VERSION}") -endif() - -find_package(Python3 REQUIRED COMPONENTS Interpreter Development) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() -if (NOT Python3_Development_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development' component") -endif() -if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component") -endif() -if (NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component") -endif() - -if(NOT TARGET Python3::Interpreter) - message(SEND_ERROR "Python3::Interpreter not found") -endif() - -if(NOT TARGET Python3::Python) - message(SEND_ERROR "Python3::Python not found") -endif() -if(NOT TARGET Python3::Module) - message(SEND_ERROR "Python3::Module not found") -endif() - -Python3_add_library (spam3 MODULE ../spam.c) -target_compile_definitions (spam3 PRIVATE PYTHON3) - -add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") - -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() -if (abi MATCHES "t") - 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") - - -# -# New search with user's prefix -# -foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) - unset(Python3_${item}) -endforeach() - -set(Python3_ARTIFACTS_PREFIX "_TEST") -find_package(Python3 REQUIRED COMPONENTS Interpreter Development) -if (NOT Python3_TEST_FOUND OR NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3 (TEST prefix)") -endif() -if (NOT Python3_TEST_Development_FOUND OR NOT Python3_Development_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development' component (TEST prefix)") -endif() -if (NOT Python3_TEST_Development.Module_FOUND OR NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component (TEST prefix)") -endif() -if (NOT Python3_TEST_Development.Embed_FOUND OR NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component (TEST prefix)") -endif() - -if(NOT TARGET Python3_TEST::Interpreter) - message(SEND_ERROR "Python3_TEST::Interpreter not found") -endif() - -if(NOT TARGET Python3_TEST::Python) - message(SEND_ERROR "Python3_TEST::Python not found") -endif() -if(NOT TARGET Python3_TEST::Module) - message(SEND_ERROR "Python3_TEST::Module not found") -endif() - -Python3_TEST_add_library (TEST_spam3 MODULE ../TEST_spam.c) -target_compile_definitions (TEST_spam3 PRIVATE PYTHON3) - -add_test (NAME python3_TEST_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_TEST_INTERPRETER}" -c "import TEST_spam3; TEST_spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python3Embedded/CMakeLists.txt b/Tests/FindPython/Python3Embedded/CMakeLists.txt deleted file mode 100644 index 46f7042..0000000 --- a/Tests/FindPython/Python3Embedded/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython3Embedded LANGUAGES C) - -include(CTest) - -find_package(Python3 REQUIRED COMPONENTS Development.Embed) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() -if (Python3_Development_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") -endif() -if (Python3_Development.Module_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") -endif() -if (NOT Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' not found") -endif() - -if(TARGET Python3::Module) - message(SEND_ERROR "Python3::Module unexpectedly found") -endif() - -if(NOT TARGET Python3::Python) - message(SEND_ERROR "Python3::Python not found") -endif() - -Python3_add_library (display_time3 SHARED ../display_time.c) -set_property (TARGET display_time3 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) -target_compile_definitions (display_time3 PRIVATE PYTHON3) - -add_executable (main3 ../main.c) -target_link_libraries (main3 PRIVATE display_time3) - -if (WIN32 OR CYGWIN OR MSYS OR MINGW) - list (JOIN Python3_RUNTIME_LIBRARY_DIRS "$" RUNTIME_DIRS) - add_test (NAME Python3.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $) -else() - add_test (NAME Python3.Embedded COMMAND main3) -endif() -set_property (TEST Python3.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/FindPython/Python3Fail/CMakeLists.txt b/Tests/FindPython/Python3Fail/CMakeLists.txt deleted file mode 100644 index 810375b..0000000 --- a/Tests/FindPython/Python3Fail/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython3Fail C) - -include(CTest) - -find_package(Python3 REQUIRED COMPONENTS Interpreter Development foobar) - -Python3_add_library (spam3 MODULE ../spam.c) -target_compile_definitions (spam3 PRIVATE PYTHON3) - -add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python3Module/CMakeLists.txt b/Tests/FindPython/Python3Module/CMakeLists.txt deleted file mode 100644 index e47a76a..0000000 --- a/Tests/FindPython/Python3Module/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython3Module LANGUAGES C) - -include(CTest) - -find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() -if (Python3_Development_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") -endif() -if (Python3_Development.SABIModule_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' unexpectedly found") -endif() -if (Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") -endif() -if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found") -endif() - -if(NOT TARGET Python3::Interpreter) - message(SEND_ERROR "Python3::Interpreter not found") -endif() - -if(TARGET Python3::Python) - message(SEND_ERROR "Python3::Python unexpectedly found") -endif() -if(TARGET Python3::SABIMOdule) - message(SEND_ERROR "Python3::SABIModule unexpectedly found") -endif() -if(TARGET Python3::Embed) - message(SEND_ERROR "Python3::Embed unexpectedly found") -endif() -if(NOT TARGET Python3::Module) - message(SEND_ERROR "Python3::Module not found") -endif() - -Python3_add_library (spam3 MODULE ../spam.c) -target_compile_definitions (spam3 PRIVATE PYTHON3) - -add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/Python3SABIModule/CMakeLists.txt b/Tests/FindPython/Python3SABIModule/CMakeLists.txt deleted file mode 100644 index 77d3abc..0000000 --- a/Tests/FindPython/Python3SABIModule/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestPython3SABIModule LANGUAGES C) - -include(CTest) - -find_package(Python3 REQUIRED COMPONENTS Interpreter Development.SABIModule) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() -if (Python3_Development_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") -endif() -if (Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") -endif() -if (Python3_Development.Module_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") -endif() -if (NOT Python3_Development.SABIModule_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") -endif() - -if(NOT TARGET Python3::Interpreter) - message(SEND_ERROR "Python3::Interpreter not found") -endif() - -if(TARGET Python3::Python) - message(SEND_ERROR "Python3::Python unexpectedly found") -endif() -if(TARGET Python3::Module) - message(SEND_ERROR "Python3::Module unexpectedly found") -endif() -if(NOT TARGET Python3::SABIModule) - message(SEND_ERROR "Python3::SABIModule not found") -endif() - -if (Python3_VERSION VERSION_GREATER_EQUAL "3.2" AND NOT Python3_SOSABI) - message(FATAL_ERROR "Python3_SOSABI unexpectedly not defined") -endif() - -Python3_add_library (spam3 MODULE USE_SABI 3 WITH_SOABI ../spam.c) -target_compile_definitions (spam3 PRIVATE PYTHON3) - -if (Python3_SOSABI) - get_property (suffix TARGET spam3 PROPERTY SUFFIX) - if (NOT suffix MATCHES "^\\.${Python3_SOSABI}") - message(FATAL_ERROR "Module suffix do not include Python3_SOSABI") - endif() -endif() - - -add_test (NAME python3_spam3 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" - "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt deleted file mode 100644 index 8be39bf..0000000 --- a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt +++ /dev/null @@ -1,196 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestRequiredArtifacts LANGUAGES C) - -include(CTest) - -if(CMake_TEST_FindPython2) - find_package(Python2 REQUIRED COMPONENTS Interpreter Development) - if (NOT Python2_FOUND) - message (FATAL_ERROR "Failed to find Python 2") - endif() - set(USER_LIBRARY "${Python2_LIBRARY_RELEASE}") - set(USER_INCLUDE_DIR "${Python2_INCLUDE_DIRS}") -else() - set(USER_LIBRARY "/path/to/invalid${CMAKE_C_LINK_LIBRARY_SUFFIX}") - set(USER_INCLUDE_DIR "/path/to/invalid/dir") -endif() - -# check some combinations for modules search without interpreter -block(SCOPE_FOR VARIABLES) - find_package(Python3 REQUIRED COMPONENTS Development.SABIModule) - if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") - endif() - if (Python3_Development_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") - endif() - if (Python3_Interpreter_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found") - endif() - if (Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") - endif() - if (Python3_Development.Module_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") - endif() - if (NOT Python3_Development.SABIModule_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") - endif() - unset(_Python3_SABI_LIBRARY_RELEASE CACHE) -endblock() - -block(SCOPE_FOR VARIABLES) - find_package(Python3 REQUIRED COMPONENTS Development.Module Development.SABIModule) - if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") - endif() - if (Python3_Development_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") - endif() - if (Python3_Interpreter_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found") - endif() - if (Python3_Development.Embed_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") - endif() - if (NOT Python3_Development.Module_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found") - endif() - if (NOT Python3_Development.SABIModule_FOUND) - message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") - endif() - unset(_Python3_LIBRARY_RELEASE CACHE) - unset(_Python3_SABI_LIBRARY_RELEASE CACHE) -endblock() - - -set(components Interpreter Development) -if (CMake_TEST_FindPython3_SABIModule AND WIN32) - list (APPEND components Development.SABIModule) -endif() -find_package(Python3 REQUIRED COMPONENTS ${components}) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() - - -add_test(NAME FindPython.RequiredArtifacts.Interpreter.VALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.VALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INTERPRETER=ON - "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -add_test(NAME FindPython.RequiredArtifacts.Interpreter.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON - "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}-bad${CMAKE_EXECUTABLE_SUFFIX}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - -add_test(NAME FindPython.RequiredArtifacts.Library.VALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.VALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_LIBRARY=ON - "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON - "-DPython3_LIBRARY=${USER_LIBRARY}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - -add_test(NAME FindPython.RequiredArtifacts.Include.VALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.VALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INCLUDE=ON - "-DPython3_INCLUDE_DIR=${Python3_INCLUDE_DIRS}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INCLUDE=ON - "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - -add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter-Library.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON - "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}" - "-DPython3_LIBRARY=${USER_LIBRARY}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - -add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library-Include.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON - "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}" - "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - -if (CMake_TEST_FindPython3_SABIModule AND WIN32) - add_test(NAME FindPython.RequiredArtifacts.SABILibrary.VALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/SABILibrary.VALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_SABI_LIBRARY=ON - "-DPython3_SABI_LIBRARY=${Python3_SABI_LIBRARY_RELEASE}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) - add_test(NAME FindPython.RequiredArtifacts.SABILibrary.INVALID COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" - "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/SABILibrary.INVALID" - ${build_generator_args} - --build-project TestRequiredArtifacts.Check - --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_SABI_LIBRARY=ON - "-DPython3_SABI_LIBRARY=${USER_LIBRARY}" - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) -endif() diff --git a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt deleted file mode 100644 index 25bdcf3..0000000 --- a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestRequiredArtifacts.Check LANGUAGES C) - -set (components) -if (CHECK_INTERPRETER) - set (required_interpreter "${Python3_EXECUTABLE}") - list (APPEND components Interpreter) -endif() -if (CHECK_LIBRARY OR CHECK_INCLUDE) - list (APPEND components Development) - if (CHECK_LIBRARY) - set (required_library "${Python3_LIBRARY}") - endif() - if (CHECK_INCLUDE) - set (required_include "${Python3_INCLUDE_DIR}") - endif() -endif() -if (CHECK_SABI_LIBRARY) - list (APPEND components Development.SABIModule) - set (required_sabi_library "${Python3_SABI_LIBRARY}") -endif() - -find_package (Python3 COMPONENTS ${components}) - - -if (PYTHON_IS_FOUND AND NOT Python3_FOUND) - message (FATAL_ERROR "Python3 unexpectedly not found") -endif() -if (NOT PYTHON_IS_FOUND AND Python3_FOUND) - message (FATAL_ERROR "Python3 unexpectedly found") -endif() - - -if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter) - message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE") -endif() - -if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library) - message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY") -endif() - -if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include) - message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR") -endif() - -if (CHECK_SABI_LIBRARY AND NOT Python3_SABI_LIBRARY_RELEASE STREQUAL required_sabi_library) - message (FATAL_ERROR "Failed to use input variable Python3_SABI_LIBRARY") -endif() diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt deleted file mode 100644 index 362df7f..0000000 --- a/Tests/FindPython/SOABI/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestSOABI LANGUAGES C) - -if(CMake_TEST_FindPython3) - find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) - if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") - endif() - - if(NOT DEFINED Python3_SOABI) - message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") - endif() - - if (Python3_Development_FOUND AND Python3_SOABI) - Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c) - target_compile_definitions (spam3 PRIVATE PYTHON3) - - get_property (suffix TARGET spam3 PROPERTY SUFFIX) - if (NOT suffix MATCHES "^.${Python3_SOABI}") - message(FATAL_ERROR "Module suffix do not include Python3_SOABI") - endif() - endif() -endif() - -if(CMake_TEST_FindPython2) - find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) - if(NOT DEFINED Python2_SOABI) - message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") - endif() - - if (Python2_Development_FOUND AND Python2_SOABI) - Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c) - target_compile_definitions (spam2 PRIVATE PYTHON2) - - get_property (suffix TARGET spam2 PROPERTY SUFFIX) - if (NOT suffix MATCHES "^.${Python2_SOABI}") - message(FATAL_ERROR "Module suffix do not include Python2_SOABI") - endif() - endif() -endif() diff --git a/Tests/FindPython/TEST_spam.c b/Tests/FindPython/TEST_spam.c deleted file mode 100644 index fc483fd..0000000 --- a/Tests/FindPython/TEST_spam.c +++ /dev/null @@ -1,41 +0,0 @@ -#define Py_LIMITED_API 3 -#include - -static PyObject* spam_system(PyObject* self, PyObject* args) -{ - char const* command; - int sts; - - if (!PyArg_ParseTuple(args, "s", &command)) - return NULL; - sts = system(command); - /* return PyLong_FromLong(sts); */ - return Py_BuildValue("i", sts); -} - -static PyMethodDef SpamMethods[] = { - { "system", spam_system, METH_VARARGS, "Execute a shell command." }, - { NULL, NULL, 0, NULL } /* Sentinel */ -}; - -#if defined(PYTHON2) -PyMODINIT_FUNC initTEST_spam2(void) -{ - (void)Py_InitModule("TEST_spam2", SpamMethods); -} -#endif - -#if defined(PYTHON3) -static struct PyModuleDef spammodule = { - PyModuleDef_HEAD_INIT, "TEST_spam3", /* name of module */ - NULL, /* module documentation, may be NULL */ - -1, /* size of per-interpreter state of the module, - or -1 if the module keeps state in global variables. */ - SpamMethods -}; - -PyMODINIT_FUNC PyInit_TEST_spam3(void) -{ - return PyModule_Create(&spammodule); -} -#endif diff --git a/Tests/FindPython/UnversionedNames/CMakeLists.txt b/Tests/FindPython/UnversionedNames/CMakeLists.txt deleted file mode 100644 index 597bd4e..0000000 --- a/Tests/FindPython/UnversionedNames/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -cmake_minimum_required(VERSION 3.19...3.20) - -project(UnversionedNames LANGUAGES NONE) - -# check if it is possible to find python with a generic name -find_program(UNVERSIONED_Python3 NAMES python3) - -if (NOT UNVERSIONED_Python3) - # no generic name available - # test cannot be done - return() -endif() - -# search with default configuration -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -if (Python3_EXECUTABLE STREQUAL UNVERSIONED_Python3) - # default configuration pick-up the generic name - # test cannot be completed - return() -endif() - -unset(Python3_EXECUTABLE) -# Force now to search first for generic name -set(Python3_FIND_UNVERSIONED_NAMES FIRST) - -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -if (NOT Python3_EXECUTABLE STREQUAL UNVERSIONED_Python3) - message(SEND_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${UNVERSIONED_Python3}") -endif() - -# To check value 'NEVER", creates directory holding a symlink to the generic name -file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/bin") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -file(CREATE_LINK "${UNVERSIONED_Python3}" "${CMAKE_CURRENT_BINARY_DIR}/bin/python3" SYMBOLIC) - -unset(Python3_EXECUTABLE) -set(Python3_FIND_UNVERSIONED_NAMES FIRST) -set(Python3_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}") -# First search: generic name must be found -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -if (NOT Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") - message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${CMAKE_CURRENT_BINARY_DIR}/bin/python3") -endif() - -unset(Python3_EXECUTABLE) -set(Python3_FIND_UNVERSIONED_NAMES LAST) - -# Second search: generic name must be found -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -if (NOT Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") - message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${CMAKE_CURRENT_BINARY_DIR}/bin/python3") -endif() - -unset(Python3_EXECUTABLE) -set(Python3_FIND_UNVERSIONED_NAMES NEVER) - -# Third search: generic name must NOT be found -find_package(Python3 REQUIRED COMPONENTS Interpreter) - -if (Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") - message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE}") -endif() diff --git a/Tests/FindPython/VersionRange/CMakeLists.txt b/Tests/FindPython/VersionRange/CMakeLists.txt deleted file mode 100644 index 957941d..0000000 --- a/Tests/FindPython/VersionRange/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -cmake_minimum_required (VERSION 3.18...3.19) - -project (TestVersionRange LANGUAGES C) - - -find_package (${Python} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter) -if (NOT ${Python}_FOUND) - message (FATAL_ERROR "Failed to find ${Python} ${Python_REQUESTED_VERSION}") -endif() - -if (Python_REQUESTED_VERSION VERSION_LESS 3.0) - set (IN_VERSION_RANGE 2.0...<3.0) - set (OUT_VERSION_RANGE 2.0...<${${Python}_VERSION}) -else() - set (IN_VERSION_RANGE 3.0...<4.0) - set (OUT_VERSION_RANGE 3.0...<${${Python}_VERSION}) -endif() - -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 (${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 '${Python} ${Python_REQUESTED_VERSION}.0...<${${Python}_VERSION} ${ARGN}'") - endif() - return() - endif() - - if (NOT ${Python}_FOUND) - message (SEND_ERROR "Not found: ${Python} ${RANGE} ${ARGN}") - elseif (NOT ${Python}_VERSION VERSION_EQUAL EXPECTED_VERSION) - message (SEND_ERROR "Wrong version: ${${Python}_VERSION} for '${Python} ${RANGE} ${ARGN}'") - endif() -endfunction() - -find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Interpreter) -if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") - find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Compiler) -else() - find_python (${${Python}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Development) -endif() - -find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Interpreter) -if (${Python}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") - find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Compiler) -else() - find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Development) -endif() - -find_python ("NONE" 5...6 COMPONENTS Interpreter) diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt deleted file mode 100644 index 7837916..0000000 --- a/Tests/FindPython/VirtualEnv/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestVirtualEnv LANGUAGES NONE) - -include(CTest) - -find_package(Python3 REQUIRED COMPONENTS Interpreter) -if (NOT Python3_FOUND) - message (FATAL_ERROR "Failed to find Python 3") -endif() - -set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv") -file (REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/py3venv") - -execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${Python3_VIRTUAL_ENV}" - RESULT_VARIABLE result - OUTPUT_VARIABLE outputs - ERROR_VARIABLE outputs) -if (result) - message (FATAL_ERROR "Fail to create virtual environment: ${outputs}") -endif() - -add_test(NAME FindPython3.VirtualEnvDefault - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") - -add_test(NAME FindPython3.VirtualEnvStandard - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") - -if(CMake_TEST_FindPython2) - add_test(NAME FindPython3.VirtualEnvOnly - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") - add_test(NAME FindPython3.UnsetVirtualEnvOnly - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - --unset=CONDA_PREFIX - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") -endif() diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake deleted file mode 100644 index 8f56d00..0000000 --- a/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -find_package (Python3 REQUIRED) - -if (NOT Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") - message (FATAL_ERROR "Fail to use virtual environment") -endif() diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake deleted file mode 100644 index 9ae4975..0000000 --- a/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -# -# Virtual environment is defined for python3 -# Trying to find a python2 using only virtual environment -# It is expecting to fail if a virtual environment is active and to success otherwise. -# -set (Python2_FIND_VIRTUALENV ONLY) -find_package (Python2 QUIET) - -if (PYTHON3_VIRTUAL_ENV AND Python2_FOUND) - message (FATAL_ERROR "Python2 unexpectedly found.") -endif() - -if (NOT PYTHON3_VIRTUAL_ENV AND NOT Python2_FOUND) - message (FATAL_ERROR "Fail to find Python2.") -endif() diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake deleted file mode 100644 index 353a91b..0000000 --- a/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -set (Python3_FIND_VIRTUALENV STANDARD) -find_package (Python3 REQUIRED) - -if (Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") - message (FATAL_ERROR "Python3 virtual env unexpectedly found.") -endif() diff --git a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt deleted file mode 100644 index 6482793..0000000 --- a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -project(TestVirtualEnvConda LANGUAGES NONE) - -include(CTest) - -find_program(CONDA_EXECUTABLE conda) -if (CONDA_EXECUTABLE EQUAL NOTFOUND) - message (FATAL_ERROR "Failed to find Conda") -endif() - -set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/condaenv") - -execute_process (COMMAND "${CONDA_EXECUTABLE}" create --no-default-packages --prefix "${Python3_VIRTUAL_ENV}" --yes python=3 - RESULT_VARIABLE result - OUTPUT_VARIABLE outputs - ERROR_VARIABLE outputs) -if (result) - message (FATAL_ERROR "Fail to create virtual environment: ${outputs}") -endif() - -add_test(NAME FindPython3.VirtualEnvDefaultConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake") - -add_test(NAME FindPython3.VirtualEnvStandardConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake") - -if(Cmake_TEST_FindPython2) - add_test(NAME FindPython3.VirtualEnvOnlyConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=VIRTUAL_ENV - "CONDA_PREFIX=${Python3_VIRTUAL_ENV}" - "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}" - -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") - add_test(NAME FindPython3.UnsetVirtualEnvOnlyConda - COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME - --unset=CONDA_PREFIX - --unset=VIRTUAL_ENV - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake") -endif() diff --git a/Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake deleted file mode 100644 index 8f56d00..0000000 --- a/Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -find_package (Python3 REQUIRED) - -if (NOT Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") - message (FATAL_ERROR "Fail to use virtual environment") -endif() diff --git a/Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake deleted file mode 100644 index 9ae4975..0000000 --- a/Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -# -# Virtual environment is defined for python3 -# Trying to find a python2 using only virtual environment -# It is expecting to fail if a virtual environment is active and to success otherwise. -# -set (Python2_FIND_VIRTUALENV ONLY) -find_package (Python2 QUIET) - -if (PYTHON3_VIRTUAL_ENV AND Python2_FOUND) - message (FATAL_ERROR "Python2 unexpectedly found.") -endif() - -if (NOT PYTHON3_VIRTUAL_ENV AND NOT Python2_FOUND) - message (FATAL_ERROR "Fail to find Python2.") -endif() diff --git a/Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake b/Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake deleted file mode 100644 index 353a91b..0000000 --- a/Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -set (Python3_FIND_VIRTUALENV STANDARD) -find_package (Python3 REQUIRED) - -if (Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") - message (FATAL_ERROR "Python3 virtual env unexpectedly found.") -endif() diff --git a/Tests/FindPython/display_time.c b/Tests/FindPython/display_time.c deleted file mode 100644 index 7b95f1f..0000000 --- a/Tests/FindPython/display_time.c +++ /dev/null @@ -1,41 +0,0 @@ - -#include - -#define PY_SSIZE_T_CLEAN -#include - -#include "display_time.h" - -void display_time(void) -{ -#if defined(PYTHON3) - PyConfig config; - PyStatus status; - - PyConfig_InitPythonConfig(&config); - status = - PyConfig_SetBytesString(&config, &config.program_name, "display_time"); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - - char* cmd = "from time import time,ctime\n" - "print('Today is', ctime(time()))\n"; -#else - char* program = "display_time"; - char* cmd = "from time import time,ctime\n" - "print 'Today is', ctime(time())\n"; - - Py_SetProgramName(program); /* optional but recommended */ -#endif - Py_Initialize(); - PyRun_SimpleString(cmd); -#if defined(PYTHON3) - if (Py_FinalizeEx() < 0) { - exit(120); - } - PyConfig_Clear(&config); -#else - Py_Finalize(); -#endif -} diff --git a/Tests/FindPython/display_time.h b/Tests/FindPython/display_time.h deleted file mode 100644 index d825e02..0000000 --- a/Tests/FindPython/display_time.h +++ /dev/null @@ -1,2 +0,0 @@ - -void display_time(); diff --git a/Tests/FindPython/main.c b/Tests/FindPython/main.c deleted file mode 100644 index 0119ce0..0000000 --- a/Tests/FindPython/main.c +++ /dev/null @@ -1,7 +0,0 @@ - -#include "display_time.h" - -int main(void) -{ - display_time(); -} diff --git a/Tests/FindPython/spam.c b/Tests/FindPython/spam.c deleted file mode 100644 index 063bf35..0000000 --- a/Tests/FindPython/spam.c +++ /dev/null @@ -1,41 +0,0 @@ -#define Py_LIMITED_API 3 -#include - -static PyObject* spam_system(PyObject* self, PyObject* args) -{ - char const* command; - int sts; - - if (!PyArg_ParseTuple(args, "s", &command)) - return NULL; - sts = system(command); - /* return PyLong_FromLong(sts); */ - return Py_BuildValue("i", sts); -} - -static PyMethodDef SpamMethods[] = { - { "system", spam_system, METH_VARARGS, "Execute a shell command." }, - { NULL, NULL, 0, NULL } /* Sentinel */ -}; - -#if defined(PYTHON2) -PyMODINIT_FUNC initspam2(void) -{ - (void)Py_InitModule("spam2", SpamMethods); -} -#endif - -#if defined(PYTHON3) -static struct PyModuleDef spammodule = { - PyModuleDef_HEAD_INIT, "spam3", /* name of module */ - NULL, /* module documentation, may be NULL */ - -1, /* size of per-interpreter state of the module, - or -1 if the module keeps state in global variables. */ - SpamMethods -}; - -PyMODINIT_FUNC PyInit_spam3(void) -{ - return PyModule_Create(&spammodule); -} -#endif diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 1748b72..83980de 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -421,6 +421,71 @@ if(CMAKE_GENERATOR MATCHES "Make|Ninja") add_RunCMake_test(Instrumentation) endif() add_RunCMake_test(ConfigDir) +if(CMake_TEST_FindPython2) + add_RunCMake_test(FindPython2.CPython TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython2_CPython=TRUE + -DCMake_TEST_FindPython2=TRUE) + set_property(TEST RunCMake.FindPython2.CPython PROPERTY LABELS Python2) +endif() +if(CMake_TEST_FindPython3) + add_RunCMake_test(FindPython3.CPython TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + -DCMake_TEST_FindPython3_CPython=TRUE + -DCMake_TEST_FindPython3=TRUE) + set_property(TEST RunCMake.FindPython3.CPython PROPERTY LABELS Python3) +endif() +if(CMake_TEST_FindPython2_IronPython) + add_RunCMake_test(FindPython2.IronPython TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython2_IronPython=${CMake_TEST_FindPython2_IronPython}) + set_property(TEST RunCMake.FindPython2.IronPython PROPERTY LABELS Python2) +endif() +if(CMake_TEST_FindPython3_IronPython) + add_RunCMake_test(FindPython3.IronPython TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3} + -DCMake_TEST_FindPython3_IronPython=${CMake_TEST_FindPython3_IronPython}) + set_property(TEST RunCMake.FindPython3.IronPython PROPERTY LABELS Python3) +endif() +if(CMake_TEST_FindPython2_PyPy) + add_RunCMake_test(FindPython2.PyPy TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython2_PyPy=${CMake_TEST_FindPython2_PyPy}) + set_property(TEST RunCMake.FindPython2.PyPy PROPERTY LABELS Python2) +endif() +if(CMake_TEST_FindPython3_PyPy) + add_RunCMake_test(FindPython3.PyPy TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython3_PyPy=${CMake_TEST_FindPython3_PyPy}) + set_property(TEST RunCMake.FindPython3.PyPy PROPERTY LABELS Python3) +endif() +if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython2_SABIModule OR CMake_TEST_FindPython2_NumPy + OR CMake_TEST_FindPython3 OR CMake_TEST_FindPython3_SABIModule OR CMake_TEST_FindPython3_NumPy + OR CMake_TEST_FindPython3_Conda) + add_RunCMake_test(FindPython.Various TEST_DIR FindPython + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + "-DRunCMake_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + -DCMake_TEST_FindPython_Various=TRUE + -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython2_SABIModule=${CMake_TEST_FindPython2_SABIModule} + -DCMake_TEST_FindPython2_NumPy=${CMake_TEST_FindPython2_NumPy} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3} + + -DCMake_TEST_FindPython3_SABIModule=${CMake_TEST_FindPython3_SABIModule} + -DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy} + -DCMake_TEST_FindPython3_Conda=${CMake_TEST_FindPython3_Conda}) + set_property(TEST RunCMake.FindPython.Various PROPERTY LABELS Python2 Python3) +endif() add_RunCMake_test(FindBoost) add_RunCMake_test(FindLua) add_RunCMake_test(FindOpenGL) diff --git a/Tests/RunCMake/FindPython/ArtifactsInteractive.cmake b/Tests/RunCMake/FindPython/ArtifactsInteractive.cmake new file mode 100644 index 0000000..bba4d71 --- /dev/null +++ b/Tests/RunCMake/FindPython/ArtifactsInteractive.cmake @@ -0,0 +1,22 @@ +enable_language(C) + +set (components Interpreter Development) +if (CMake_TEST_FindPython3_NumPy) + list (APPEND components NumPy) +endif() + +find_package(Python3 REQUIRED COMPONENTS ${components}) + +if (Python3_ARTIFACTS_INTERACTIVE) + if (NOT DEFINED CACHE{Python3_EXECUTABLE} + OR NOT DEFINED CACHE{Python3_LIBRARY} OR NOT DEFINED CACHE{Python3_INCLUDE_DIR} + OR (CMake_TEST_FindPython3_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) + message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=ON Failed.") + endif() +else() + if (DEFINED CACHE{Python3_EXECUTABLE} + OR DEFINED CACHE{Python3_LIBRARY} OR DEFINED CACHE{Python3_INCLUDE_DIR} + OR (CMake_TEST_FindPython3_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR})) + message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=OFF Failed.") + endif() +endif() diff --git a/Tests/RunCMake/FindPython/ArtifactsPrefix.cmake b/Tests/RunCMake/FindPython/ArtifactsPrefix.cmake new file mode 100644 index 0000000..8a8dde4 --- /dev/null +++ b/Tests/RunCMake/FindPython/ArtifactsPrefix.cmake @@ -0,0 +1,22 @@ +enable_language(C) + +set(Python_ARTIFACTS_PREFIX "_V2") +find_package (Python 2 EXACT REQUIRED) + +if(NOT Python_V2_FOUND OR NOT Python_FOUND) + message(FATAL_ERROR "Python v2 interpreter not found.") +endif() +if(NOT Python_V2_VERSION_MAJOR VERSION_EQUAL 2) + message(FATAL_ERROR "Python v2 interpreter: wrong major version.") +endif() + + +set(Python_ARTIFACTS_PREFIX "_V3") +find_package (Python 3 EXACT REQUIRED) + +if(NOT Python_V3_FOUND OR NOT Python_FOUND) + message(FATAL_ERROR "Python v3 interpreter not found.") +endif() +if(NOT Python_V3_VERSION_MAJOR VERSION_EQUAL 3) + message(FATAL_ERROR "Python v3 interpreter: wrong major version.") +endif() diff --git a/Tests/RunCMake/FindPython/CMakeLists.txt b/Tests/RunCMake/FindPython/CMakeLists.txt new file mode 100644 index 0000000..9693fcc --- /dev/null +++ b/Tests/RunCMake/FindPython/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12...4.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.Include-stderr.txt b/Tests/RunCMake/FindPython/CustomFailureMessage.Include-stderr.txt new file mode 100644 index 0000000..879cc7c --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.Include-stderr.txt @@ -0,0 +1,4 @@ + Could NOT find Python3 \(missing: .*Development.*\).* + + Reason given by package: * + Development: Cannot find the directory "/not/found/include" diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.Interpreter-stderr.txt b/Tests/RunCMake/FindPython/CustomFailureMessage.Interpreter-stderr.txt new file mode 100644 index 0000000..9450a04 --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.Interpreter-stderr.txt @@ -0,0 +1,4 @@ + Could NOT find Python3 \(missing: .*Interpreter.*\).* + + Reason given by package: * + Interpreter: Cannot run the interpreter "/not/found/interpreter" diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.Library-stderr.txt b/Tests/RunCMake/FindPython/CustomFailureMessage.Library-stderr.txt new file mode 100644 index 0000000..5e806c4 --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.Library-stderr.txt @@ -0,0 +1,4 @@ + Could NOT find Python3 \(missing: .*Development.*\).* + + Reason given by package: * + Development: Cannot find the library "/not/found/library" diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.Multiple-stderr.txt b/Tests/RunCMake/FindPython/CustomFailureMessage.Multiple-stderr.txt new file mode 100644 index 0000000..26cec30 --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.Multiple-stderr.txt @@ -0,0 +1,6 @@ + Could NOT find Python3 \(missing: .*Interpreter + Development.*\).* + + Reason given by package: * + Interpreter: Cannot run the interpreter "/not/found/interpreter" + Development: Cannot find the library "/not/found/library" diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.NumPy-stderr.txt b/Tests/RunCMake/FindPython/CustomFailureMessage.NumPy-stderr.txt new file mode 100644 index 0000000..9d7bccd --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.NumPy-stderr.txt @@ -0,0 +1,4 @@ + Could NOT find Python3 \(missing: .*NumPy.*\).* + + Reason given by package: * + NumPy: Cannot find the directory "/not/found/numpy/include" diff --git a/Tests/RunCMake/FindPython/CustomFailureMessage.cmake b/Tests/RunCMake/FindPython/CustomFailureMessage.cmake new file mode 100644 index 0000000..c604c74 --- /dev/null +++ b/Tests/RunCMake/FindPython/CustomFailureMessage.cmake @@ -0,0 +1,4 @@ + +string(REPLACE ":" ";" CHECK_COMPONENTS "${CHECK_COMPONENTS}") + +find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS}) diff --git a/Tests/RunCMake/FindPython/DifferentComponents.cmake b/Tests/RunCMake/FindPython/DifferentComponents.cmake new file mode 100644 index 0000000..30cd44e --- /dev/null +++ b/Tests/RunCMake/FindPython/DifferentComponents.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_subdirectory(subdir) + +find_package(Python3 REQUIRED COMPONENTS Development.Module) diff --git a/Tests/RunCMake/FindPython/ExactVersion.cmake b/Tests/RunCMake/FindPython/ExactVersion.cmake new file mode 100644 index 0000000..6c048bd --- /dev/null +++ b/Tests/RunCMake/FindPython/ExactVersion.cmake @@ -0,0 +1,54 @@ +enable_language(C) + +find_package(${PYTHON} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) +if(NOT ${PYTHON}_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") +endif() +if(NOT ${PYTHON}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") +endif() +if(NOT ${PYTHON}_Development_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") +endif() + +if(NOT TARGET ${PYTHON}::Interpreter) + message(SEND_ERROR "${PYTHON}::Interpreter not found") +endif() + +if(NOT TARGET ${PYTHON}::Python) + message(SEND_ERROR "${PYTHON}::Python not found") +endif() +if(NOT TARGET ${PYTHON}::Module) + message(SEND_ERROR "${PYTHON}::Module not found") +endif() + + +# reset artifacts and second search with exact version already founded +unset(${PYTHON}_EXECUTABLE) +unset(_${PYTHON}_EXECUTABLE CACHE) + +unset(_${PYTHON}_LIBRARY_RELEASE CACHE) +unset(_${PYTHON}_INCLUDE_DIR CACHE) + +set(Python_REQUESTED_VERSION ${${PYTHON}_VERSION}) +find_package(${PYTHON} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter Development) +if(NOT ${PYTHON}_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") +endif() +if(NOT ${PYTHON}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Interpreter") +endif() +if(NOT ${PYTHON}_Development_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} Development") +endif() + +if(NOT TARGET ${PYTHON}::Interpreter) + message(SEND_ERROR "${PYTHON}::Interpreter not found") +endif() + +if(NOT TARGET ${PYTHON}::Python) + message(SEND_ERROR "${PYTHON}::Python not found") +endif() +if(NOT TARGET ${PYTHON}::Module) + message(SEND_ERROR "${PYTHON}::Module not found") +endif() diff --git a/Tests/RunCMake/FindPython/FindPythonScript.cmake b/Tests/RunCMake/FindPython/FindPythonScript.cmake new file mode 100644 index 0000000..fa51f59 --- /dev/null +++ b/Tests/RunCMake/FindPython/FindPythonScript.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +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/RunCMake/FindPython/Implementation.cmake b/Tests/RunCMake/FindPython/Implementation.cmake new file mode 100644 index 0000000..134c72c --- /dev/null +++ b/Tests/RunCMake/FindPython/Implementation.cmake @@ -0,0 +1,33 @@ + +set (Python${Python_REQUESTED_VERSION}_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) + +find_package(Python${Python_REQUESTED_VERSION} COMPONENTS Interpreter) +if (NOT Python${Python_REQUESTED_VERSION}_FOUND OR NOT Python${Python_REQUESTED_VERSION}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python${Python_REQUESTED_VERSION}") +endif() + +if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" + AND NOT Python${Python_REQUESTED_VERSION}_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${Python${Python_REQUESTED_VERSION}_INTERPRETER_ID})") +endif() +if (Python_REQUESTED_IMPLEMENTATION STREQUAL "CPython" + AND Python${Python_REQUESTED_VERSION}_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${Python${Python_REQUESTED_VERSION}_INTERPRETER_ID})") +endif() + + +set (Python_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION}) + +find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter) +if (NOT Python_FOUND OR NOT Python_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") +endif() + +if (Python_REQUESTED_IMPLEMENTATION STREQUAL "IronPython" + AND NOT Python_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") +endif() +if (Python_REQUESTED_IMPLEMENTATION STREQUAL "CPython" + AND Python_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${Python_INTERPRETER_ID})") +endif() diff --git a/Tests/RunCMake/FindPython/IronPython.cmake b/Tests/RunCMake/FindPython/IronPython.cmake new file mode 100644 index 0000000..d8f490b --- /dev/null +++ b/Tests/RunCMake/FindPython/IronPython.cmake @@ -0,0 +1,36 @@ + +set (${PYTHON}_FIND_IMPLEMENTATIONS IronPython) + +if(PYTHON STREQUAL "Python") + set(IronPython_VERSION "IronPython ${Python_REQUESTED_VERSION}") +elseif(PYTHON STREQUAL "Python2") + set(IronPython_VERSION "IronPython2") +else() + set(IronPython_VERSION "IronPython3") +endif() + +find_package(${PYTHON} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Compiler) +if (NOT ${PYTHON}_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") +endif() + +if (NOT ${PYTHON}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python Interpreter") +endif() +if (NOT ${PYTHON}_INTERPRETER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous interpreter ID (${${PYTHON}_INTERPRETER_ID})") +endif() + +if (NOT ${PYTHON}_Compiler_FOUND) + message (FATAL_ERROR "Failed to find Python Compiler") +endif() +if (NOT ${PYTHON}_COMPILER_ID STREQUAL "IronPython") + message (FATAL_ERROR "Erroneous compiler ID (${${PYTHON}_COMPILER_ID})") +endif() + +if(NOT TARGET ${PYTHON}::Interpreter) + message(SEND_ERROR "${PYTHON}::Interpreter not found") +endif() +if(NOT TARGET ${PYTHON}::Compiler) + message(SEND_ERROR "${PYTHON}::Interpreter not found") +endif() diff --git a/Tests/RunCMake/FindPython/MultiplePackages.cmake b/Tests/RunCMake/FindPython/MultiplePackages.cmake new file mode 100644 index 0000000..e32e9ed --- /dev/null +++ b/Tests/RunCMake/FindPython/MultiplePackages.cmake @@ -0,0 +1,45 @@ +enable_language(C) + +include(CTest) + +find_package (Python REQUIRED) + +if (CMake_TEST_FindPython2) + find_package (Python2 REQUIRED COMPONENTS Interpreter Development) + + if (NOT CMake_TEST_FindPython3 AND NOT Python2_EXECUTABLE STREQUAL Python_EXECUTABLE) + message (FATAL_ERROR + "Python interpreters do not match:\n" + " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" + " Python2_EXECUTABLE='${Python3_EXECUTABLE}'\n" + ) + endif() + + Python2_add_library (spam2 MODULE spam.c) + target_compile_definitions (spam2 PRIVATE PYTHON2) + + add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") + +endif() + +if (CMake_TEST_FindPython3) + find_package (Python3 REQUIRED COMPONENTS Interpreter Development) + + if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE) + message (FATAL_ERROR + "Python interpreters do not match:\n" + " Python_EXECUTABLE='${Python_EXECUTABLE}'\n" + " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n" + ) + endif() + + Python3_add_library (spam3 MODULE spam.c) + target_compile_definitions (spam3 PRIVATE PYTHON3) + + add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") + +endif() diff --git a/Tests/RunCMake/FindPython/NumPy.cmake b/Tests/RunCMake/FindPython/NumPy.cmake new file mode 100644 index 0000000..274d38d --- /dev/null +++ b/Tests/RunCMake/FindPython/NumPy.cmake @@ -0,0 +1,31 @@ +enable_language(C) + +include(CTest) + +if(CMake_TEST_FindPython2_NumPy) + + find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy) + + Python2_add_library (arraytest2 MODULE arraytest.c) + target_compile_definitions (arraytest2 PRIVATE PYTHON2) + target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + + add_test (NAME python2_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") + +endif() + +if(CMake_TEST_FindPython3_NumPy) + + find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy) + + Python3_add_library (arraytest3 MODULE arraytest.c) + target_compile_definitions (arraytest3 PRIVATE PYTHON3) + target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + + add_test (NAME python3_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") + +endif() diff --git a/Tests/RunCMake/FindPython/NumPyOnly.cmake b/Tests/RunCMake/FindPython/NumPyOnly.cmake new file mode 100644 index 0000000..0f98da7 --- /dev/null +++ b/Tests/RunCMake/FindPython/NumPyOnly.cmake @@ -0,0 +1,31 @@ +enable_language(C) + +include(CTest) + +if(CMake_TEST_FindPython2_NumPy) + + find_package (Python2 REQUIRED COMPONENTS NumPy) + + Python2_add_library (arraytest2 MODULE arraytest.c) + target_compile_definitions (arraytest2 PRIVATE PYTHON2) + target_link_libraries (arraytest2 PRIVATE Python2::NumPy) + + add_test (NAME python2_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));") + +endif() + +if(CMake_TEST_FindPython3_NumPy) + + find_package (Python3 REQUIRED COMPONENTS NumPy) + + Python3_add_library (arraytest3 MODULE arraytest.c) + target_compile_definitions (arraytest3 PRIVATE PYTHON3) + target_link_libraries (arraytest3 PRIVATE Python3::NumPy) + + add_test (NAME python3_arraytest + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));") + +endif() diff --git a/Tests/RunCMake/FindPython/PyPy.cmake b/Tests/RunCMake/FindPython/PyPy.cmake new file mode 100644 index 0000000..6bbbe84 --- /dev/null +++ b/Tests/RunCMake/FindPython/PyPy.cmake @@ -0,0 +1,43 @@ +enable_language(C) + +set (${PYTHON}_FIND_IMPLEMENTATIONS PyPy) + +if(PYTHON STREQUAL "Python") + set(PyPy_VERSION "PyPy ${Python_REQUESTED_VERSION}") +elseif(PYTHON STREQUAL "Python2") + set(PyPy_VERSION "PyPy2") +else() + set(PyPy_VERSION "PyPy3") +endif() + +find_package(${PYTHON} ${Python_REQUESTED_VERSION} COMPONENTS Interpreter Development) +if (NOT ${PYTHON}_FOUND) + message (FATAL_ERROR "Failed to find Python ${PyPy_VERSION}") +endif() + +if (NOT ${PYTHON}_Interpreter_FOUND) + message (FATAL_ERROR "Failed to find Python ${PyPy_VERSION} Interpreter") +endif() +if (NOT ${PYTHON}_INTERPRETER_ID STREQUAL "PyPy") + message (FATAL_ERROR "Erroneous interpreter ID (${${PYTHON}_INTERPRETER_ID})") +endif() + +if (NOT ${PYTHON}_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python ${PyPy_VERSION} Development.Module") +endif() +if (NOT ${PYTHON}_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python ${PyPy_VERSION} Development.Embed") +endif() +if (NOT ${PYTHON}_Development_FOUND) + message (FATAL_ERROR "Failed to find Python ${PyPy_VERSION} Development") +endif() + +if(NOT TARGET ${PYTHON}::Interpreter) + message(SEND_ERROR "${PYTHON}::Interpreter not found") +endif() +if(NOT TARGET ${PYTHON}::Module) + message(SEND_ERROR "${PYTHON}::Module not found") +endif() +if(NOT TARGET ${PYTHON}::Python) + message(SEND_ERROR "${PYTHON}::Python not found") +endif() diff --git a/Tests/RunCMake/FindPython/Python.cmake b/Tests/RunCMake/FindPython/Python.cmake new file mode 100644 index 0000000..2171055 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python.cmake @@ -0,0 +1,78 @@ +enable_language(C) + +include(CTest) + +find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) +if (NOT Python_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}") +endif() +if (NOT Python_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'") +endif() +if (NOT Python_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'") +endif() + +if(NOT TARGET Python::Interpreter) + message(SEND_ERROR "Python::Interpreter not found") +endif() + +if(NOT TARGET Python::Python) + message(SEND_ERROR "Python::Python not found") +endif() +if(NOT TARGET Python::Module) + message(SEND_ERROR "Python::Module not found") +endif() + +if (Python_REQUESTED_VERSION) + Python_add_library (spam${Python_REQUESTED_VERSION} MODULE spam.c) + target_compile_definitions (spam${Python_REQUESTED_VERSION} PRIVATE PYTHON${Python_REQUESTED_VERSION}) + + add_test (NAME python_spam${Python_REQUESTED_VERSION} + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python_INTERPRETER}" -c "import spam${Python_REQUESTED_VERSION}; spam${Python_REQUESTED_VERSION}.system(\"cd\")") +else() + add_test(NAME findpython_script + COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python + -P "${CMAKE_CURRENT_LIST_DIR}/FindPythonScript.cmake") +endif() + + +# +# New search with user's prefix +# +foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) + unset(Python_${item}) +endforeach() + +set(Python_ARTIFACTS_PREFIX "_TEST") +find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development) +if (NOT Python_TEST_FOUND OR NOT Python_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION} (TEST prefix)") +endif() +if (NOT Python_TEST_Development.Module_FOUND OR NOT Python_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module' (TEST prefix)") +endif() +if (NOT Python_TEST_Development.Embed_FOUND OR NOT Python_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed' (TEST prefix)") +endif() + +if(NOT TARGET Python_TEST::Interpreter) + message(SEND_ERROR "Python_TEST::Interpreter not found") +endif() + +if(NOT TARGET Python_TEST::Python) + message(SEND_ERROR "Python_TEST::Python not found") +endif() +if(NOT TARGET Python_TEST::Module) + message(SEND_ERROR "Python_TEST::Module not found") +endif() + +if (Python_REQUESTED_VERSION) + Python_TEST_add_library (TEST_spam${Python_REQUESTED_VERSION} MODULE TEST_spam.c) + target_compile_definitions (TEST_spam${Python_REQUESTED_VERSION} PRIVATE PYTHON${Python_REQUESTED_VERSION}) + + add_test (NAME python_TEST_spam${Python_REQUESTED_VERSION} + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python_INTERPRETER}" -c "import TEST_spam${Python_REQUESTED_VERSION}; TEST_spam${Python_REQUESTED_VERSION}.system(\"cd\")") +endif() diff --git a/Tests/RunCMake/FindPython/Python2-BadComponent-result.txt b/Tests/RunCMake/FindPython/Python2-BadComponent-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2-BadComponent-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FindPython/Python2-BadComponent-stderr.txt b/Tests/RunCMake/FindPython/Python2-BadComponent-stderr.txt new file mode 100644 index 0000000..991989a --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2-BadComponent-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find Python2 \(missing: foobar\) \(found version "[0-9.]+"\) diff --git a/Tests/RunCMake/FindPython/Python2-BadComponent.cmake b/Tests/RunCMake/FindPython/Python2-BadComponent.cmake new file mode 100644 index 0000000..d79f4b1 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2-BadComponent.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development foobar) diff --git a/Tests/RunCMake/FindPython/Python2.cmake b/Tests/RunCMake/FindPython/Python2.cmake new file mode 100644 index 0000000..43cc9a8 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2.cmake @@ -0,0 +1,86 @@ +enable_language(C) + +include(CTest) + +find_package(Python2 3 QUIET) +if (Python2_FOUND) + message (FATAL_ERROR "Wrong python version found: ${Python2_VERSION}") +endif() + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2") +endif() +if (NOT Python2_Development_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development' component") +endif() +if (NOT Python2_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component") +endif() +if (NOT Python2_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component") +endif() + +if(NOT TARGET Python2::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(NOT TARGET Python2::Python) + message(SEND_ERROR "Python2::Python not found") +endif() +if(NOT TARGET Python2::Module) + message(SEND_ERROR "Python2::Module not found") +endif() + +Python2_add_library (spam2 MODULE spam.c) +target_compile_definitions (spam2 PRIVATE PYTHON2) + +add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") + +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") + + +# +# New search with user's prefix +# +foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) + unset(Python2_${item}) +endforeach() + +set(Python2_ARTIFACTS_PREFIX "_TEST") +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python2_TEST_FOUND OR NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2 (TEST prefix)") +endif() +if (NOT Python2_TEST_Development_FOUND OR NOT Python2_Development_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development' component (TEST prefix)") +endif() +if (NOT Python2_TEST_Development.Module_FOUND OR NOT Python2_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development.Module' component (TEST prefix)") +endif() +if (NOT Python2_TEST_Development.Embed_FOUND OR NOT Python2_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python 2 'Development.Embed' component (TEST prefix)") +endif() + +if(NOT TARGET Python2_TEST::Interpreter) + message(SEND_ERROR "Python2_TEST::Interpreter not found") +endif() + +if(NOT TARGET Python2_TEST::Python) + message(SEND_ERROR "Python2_TEST::Python not found") +endif() +if(NOT TARGET Python2_TEST::Module) + message(SEND_ERROR "Python2_TEST::Module not found") +endif() + +Python2_TEST_add_library (TEST_spam2 MODULE TEST_spam.c) +target_compile_definitions (TEST_spam2 PRIVATE PYTHON2) + +add_test (NAME python2_TEST_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import TEST_spam2; TEST_spam2.system(\"cd\")") diff --git a/Tests/RunCMake/FindPython/Python2Embedded.cmake b/Tests/RunCMake/FindPython/Python2Embedded.cmake new file mode 100644 index 0000000..de65202 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2Embedded.cmake @@ -0,0 +1,40 @@ +enable_language(C) + +include(CTest) + +find_package(Python2 REQUIRED COMPONENTS Development.Embed) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2") +endif() +if (Python2_Development_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") +endif() +if (Python2_Development.Module_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' unexpectedly found") +endif() +if (NOT Python2_Development.Embed_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' not found") +endif() + +if(TARGET Python2::Module) + message(SEND_ERROR "Python2::Module unexpectedly found") +endif() + +if(NOT TARGET Python2::Python) + message(SEND_ERROR "Python2::Python not found") +endif() + +Python2_add_library (display_time2 SHARED display_time.c) +set_property (TARGET display_time2 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_definitions (display_time2 PRIVATE PYTHON2) + +add_executable (main2 main.c) +target_link_libraries (main2 PRIVATE display_time2) + +if (WIN32 OR CYGWIN OR MSYS OR MINGW) + list (JOIN Python2_RUNTIME_LIBRARY_DIRS "$" RUNTIME_DIRS) + add_test (NAME Python2.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $) +else() + add_test (NAME Python2.Embedded COMMAND main2) +endif() +set_property (TEST Python2.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/RunCMake/FindPython/Python2Module.cmake b/Tests/RunCMake/FindPython/Python2Module.cmake new file mode 100644 index 0000000..8996aa1 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2Module.cmake @@ -0,0 +1,35 @@ +enable_language(C) + +include(CTest) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2") +endif() +if (Python2_Development_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found") +endif() +if (Python2_Development.Embed_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' unexpectedly found") +endif() +if (NOT Python2_Development.Module_FOUND) + message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' not found") +endif() + +if(NOT TARGET Python2::Interpreter) + message(SEND_ERROR "Python2::Interpreter not found") +endif() + +if(TARGET Python2::Python) + message(SEND_ERROR "Python2::Python unexpectedly found") +endif() +if(NOT TARGET Python2::Module) + message(SEND_ERROR "Python2::Module not found") +endif() + +Python2_add_library (spam2 MODULE spam.c) +target_compile_definitions (spam2 PRIVATE PYTHON2) + +add_test (NAME python2_spam2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")") diff --git a/Tests/RunCMake/FindPython/Python2SABIModule-result.txt b/Tests/RunCMake/FindPython/Python2SABIModule-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2SABIModule-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt b/Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt new file mode 100644 index 0000000..ae72b68 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt @@ -0,0 +1,2 @@ + Reason given by package: * + Development: SABIModule requires version 3.2 or upper. diff --git a/Tests/RunCMake/FindPython/Python2SABIModule.cmake b/Tests/RunCMake/FindPython/Python2SABIModule.cmake new file mode 100644 index 0000000..a7e7378 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python2SABIModule.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module Development.SABIModule) diff --git a/Tests/RunCMake/FindPython/Python3-BadComponent-result.txt b/Tests/RunCMake/FindPython/Python3-BadComponent-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3-BadComponent-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FindPython/Python3-BadComponent-stderr.txt b/Tests/RunCMake/FindPython/Python3-BadComponent-stderr.txt new file mode 100644 index 0000000..3b1df74 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3-BadComponent-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .+/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find Python3 \(missing: foobar\) \(found version "[0-9.]+"\) diff --git a/Tests/RunCMake/FindPython/Python3-BadComponent.cmake b/Tests/RunCMake/FindPython/Python3-BadComponent.cmake new file mode 100644 index 0000000..e19a5c5 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3-BadComponent.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development foobar) diff --git a/Tests/RunCMake/FindPython/Python3.cmake b/Tests/RunCMake/FindPython/Python3.cmake new file mode 100644 index 0000000..6f0eae0 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3.cmake @@ -0,0 +1,86 @@ + +enable_language(C) + +include(CTest) + +find_package(Python3 2 QUIET) +if (Python3_FOUND) + message (FATAL_ERROR "Wrong python version found: ${Python3_VERSION}") +endif() + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() +if (NOT Python3_Development_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development' component") +endif() +if (NOT Python3_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component") +endif() +if (NOT Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component") +endif() + +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python3::Interpreter not found") +endif() + +if(NOT TARGET Python3::Python) + message(SEND_ERROR "Python3::Python not found") +endif() +if(NOT TARGET Python3::Module) + message(SEND_ERROR "Python3::Module not found") +endif() + +Python3_add_library (spam3 MODULE spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") + +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") + +# +# New search with user's prefix +# +foreach(item IN ITEMS FOUND Development_FOUND Development.Module_FOUND Development.Embed_FOUND) + unset(Python3_${item}) +endforeach() + +set(Python3_ARTIFACTS_PREFIX "_TEST") +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python3_TEST_FOUND OR NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3 (TEST prefix)") +endif() +if (NOT Python3_TEST_Development_FOUND OR NOT Python3_Development_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development' component (TEST prefix)") +endif() +if (NOT Python3_TEST_Development.Module_FOUND OR NOT Python3_Development.Module_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development.Module' component (TEST prefix)") +endif() +if (NOT Python3_TEST_Development.Embed_FOUND OR NOT Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Failed to find Python 3 'Development.Embed' component (TEST prefix)") +endif() + +if(NOT TARGET Python3_TEST::Interpreter) + message(SEND_ERROR "Python3_TEST::Interpreter not found") +endif() + +if(NOT TARGET Python3_TEST::Python) + message(SEND_ERROR "Python3_TEST::Python not found") +endif() +if(NOT TARGET Python3_TEST::Module) + message(SEND_ERROR "Python3_TEST::Module not found") +endif() + +Python3_TEST_add_library (TEST_spam3 MODULE TEST_spam.c) +target_compile_definitions (TEST_spam3 PRIVATE PYTHON3) + +add_test (NAME python3_TEST_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import TEST_spam3; TEST_spam3.system(\"cd\")") diff --git a/Tests/RunCMake/FindPython/Python3Embedded.cmake b/Tests/RunCMake/FindPython/Python3Embedded.cmake new file mode 100644 index 0000000..9ef4e74 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3Embedded.cmake @@ -0,0 +1,40 @@ +enable_language(C) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Development.Embed) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() +if (Python3_Development_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") +endif() +if (Python3_Development.Module_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") +endif() +if (NOT Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' not found") +endif() + +if(TARGET Python3::Module) + message(SEND_ERROR "Python3::Module unexpectedly found") +endif() + +if(NOT TARGET Python3::Python) + message(SEND_ERROR "Python3::Python not found") +endif() + +Python3_add_library (display_time3 SHARED display_time.c) +set_property (TARGET display_time3 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_definitions (display_time3 PRIVATE PYTHON3) + +add_executable (main3 main.c) +target_link_libraries (main3 PRIVATE display_time3) + +if (WIN32 OR CYGWIN OR MSYS OR MINGW) + list (JOIN Python3_RUNTIME_LIBRARY_DIRS "$" RUNTIME_DIRS) + add_test (NAME Python3.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $) +else() + add_test (NAME Python3.Embedded COMMAND main3) +endif() +set_property (TEST Python3.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is") diff --git a/Tests/RunCMake/FindPython/Python3Module.cmake b/Tests/RunCMake/FindPython/Python3Module.cmake new file mode 100644 index 0000000..2fa8bae --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3Module.cmake @@ -0,0 +1,44 @@ +enable_language(C) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() +if (Python3_Development_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") +endif() +if (Python3_Development.SABIModule_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' unexpectedly found") +endif() +if (Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") +endif() +if (NOT Python3_Development.Module_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found") +endif() + +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python3::Interpreter not found") +endif() + +if(TARGET Python3::Python) + message(SEND_ERROR "Python3::Python unexpectedly found") +endif() +if(TARGET Python3::SABIMOdule) + message(SEND_ERROR "Python3::SABIModule unexpectedly found") +endif() +if(TARGET Python3::Embed) + message(SEND_ERROR "Python3::Embed unexpectedly found") +endif() +if(NOT TARGET Python3::Module) + message(SEND_ERROR "Python3::Module not found") +endif() + +Python3_add_library (spam3 MODULE spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/RunCMake/FindPython/Python3SABIModule.cmake b/Tests/RunCMake/FindPython/Python3SABIModule.cmake new file mode 100644 index 0000000..20cea97 --- /dev/null +++ b/Tests/RunCMake/FindPython/Python3SABIModule.cmake @@ -0,0 +1,53 @@ +enable_language(C) + +include(CTest) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development.SABIModule) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() +if (Python3_Development_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") +endif() +if (Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") +endif() +if (Python3_Development.Module_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") +endif() +if (NOT Python3_Development.SABIModule_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") +endif() + +if(NOT TARGET Python3::Interpreter) + message(SEND_ERROR "Python3::Interpreter not found") +endif() + +if(TARGET Python3::Python) + message(SEND_ERROR "Python3::Python unexpectedly found") +endif() +if(TARGET Python3::Module) + message(SEND_ERROR "Python3::Module unexpectedly found") +endif() +if(NOT TARGET Python3::SABIModule) + message(SEND_ERROR "Python3::SABIModule not found") +endif() + +if (Python3_VERSION VERSION_GREATER_EQUAL "3.2" AND NOT Python3_SOSABI) + message(FATAL_ERROR "Python3_SOSABI unexpectedly not defined") +endif() + +Python3_add_library (spam3 MODULE USE_SABI 3 WITH_SOABI spam.c) +target_compile_definitions (spam3 PRIVATE PYTHON3) + +if (Python3_SOSABI) + get_property (suffix TARGET spam3 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^\\.${Python3_SOSABI}") + message(FATAL_ERROR "Module suffix do not include Python3_SOSABI") + endif() +endif() + + +add_test (NAME python3_spam3 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + "${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")") diff --git a/Tests/RunCMake/FindPython/PythonArtifacts.cmake.in b/Tests/RunCMake/FindPython/PythonArtifacts.cmake.in new file mode 100644 index 0000000..0c18aa7 --- /dev/null +++ b/Tests/RunCMake/FindPython/PythonArtifacts.cmake.in @@ -0,0 +1,32 @@ +set(USER_EXECUTABLE "@USER_EXECUTABLE@") +set(USER_LIBRARY "@USER_LIBRARY@") +set(USER_INCLUDE_DIR "@USER_INCLUDE_DIR@") + +if(CHECK_INTERPRETER) + if(INVALID_ARTIFACTS MATCHES "INTERPRETER") + set(Python3_EXECUTABLE "@USER_EXECUTABLE@") + else() + set(Python3_EXECUTABLE "@Python3_EXECUTABLE@") + endif() +endif() +if(CHECK_LIBRARY) + if(INVALID_ARTIFACTS MATCHES "LIBRARY") + set(Python3_LIBRARY "@USER_LIBRARY@") + else() + set(Python3_LIBRARY "@_Python3_LIBRARY_RELEASE@") + endif() +endif() +if(CHECK_INCLUDE) + if(INVALID_ARTIFACTS MATCHES "INCLUDE") + set(Python3_INCLUDE_DIR "@USER_INCLUDE_DIR@") + else() + set(Python3_INCLUDE_DIR "@Python3_INCLUDE_DIRS@") + endif() +endif() +if(CHECK_SABI_LIBRARY) + if(INVALID_ARTIFACTS MATCHES "SABI_LIBRARY") + set(Python3_SABI_LIBRARY "@USER_LIBRARY@") + else() + set(Python3_SABI_LIBRARY "@_Python3_SABI_LIBRARY_RELEASE@") + endif() +endif() diff --git a/Tests/RunCMake/FindPython/RequiredArtifacts.cmake b/Tests/RunCMake/FindPython/RequiredArtifacts.cmake new file mode 100644 index 0000000..51895ef --- /dev/null +++ b/Tests/RunCMake/FindPython/RequiredArtifacts.cmake @@ -0,0 +1,84 @@ +enable_language(C) + +include(CTest) + +if(CMake_TEST_FindPython2) + find_package(Python2 REQUIRED COMPONENTS Interpreter Development) + if (NOT Python2_FOUND) + message (FATAL_ERROR "Failed to find Python 2") + endif() + set(USER_EXECUTABLE "${Python2_EXECUTABLE}") + set(USER_LIBRARY "${Python2_LIBRARY_RELEASE}") + set(USER_INCLUDE_DIR "${Python2_INCLUDE_DIRS}") +else() + set(USER_EXECUTABLE "/path/to/invalid-exe${CMAKE_EXECUTABLE_SUFFIX}") + set(USER_LIBRARY "/path/to/invalid-lib${CMAKE_C_LINK_LIBRARY_SUFFIX}") + set(USER_INCLUDE_DIR "/path/to/invalid/dir") +endif() + +# check some combinations for modules search without interpreter +if(CMake_TEST_FindPython3_SABIModule) + block(SCOPE_FOR VARIABLES) + find_package(Python3 REQUIRED COMPONENTS Development.SABIModule) + if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") + endif() + if (Python3_Development_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") + endif() + if (Python3_Interpreter_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found") + endif() + if (Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") + endif() + if (Python3_Development.Module_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found") + endif() + if (NOT Python3_Development.SABIModule_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") + endif() + unset(_Python3_SABI_LIBRARY_RELEASE CACHE) + endblock() +endif() + +block(SCOPE_FOR VARIABLES) + set(components Development.Module) + if (CMake_TEST_FindPython3_SABIModule) + list (APPEND components Development.SABIModule) + endif() + find_package(Python3 REQUIRED COMPONENTS ${components}) + if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") + endif() + if (Python3_Development_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found") + endif() + if (Python3_Interpreter_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found") + endif() + if (Python3_Development.Embed_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found") + endif() + if (NOT Python3_Development.Module_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found") + endif() + if (CMake_TEST_FindPython3_SABIModule AND NOT Python3_Development.SABIModule_FOUND) + message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found") + endif() + unset(_Python3_LIBRARY_RELEASE CACHE) + unset(_Python3_SABI_LIBRARY_RELEASE CACHE) +endblock() + + +set(components Interpreter Development) +if (CMake_TEST_FindPython3_SABIModule) + list (APPEND components Development.SABIModule) +endif() +find_package(Python3 REQUIRED COMPONENTS ${components}) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() + +configure_file("${CMAKE_SOURCE_DIR}/PythonArtifacts.cmake.in" + "${CMAKE_BINARY_DIR}/PythonArtifacts.cmake" @ONLY) diff --git a/Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake b/Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake new file mode 100644 index 0000000..b47f43b --- /dev/null +++ b/Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake @@ -0,0 +1,49 @@ +enable_language(C) + +include("${PYTHON_ARTIFACTS}") + +set (components) +if (CHECK_INTERPRETER) + set (required_interpreter "${Python3_EXECUTABLE}") + list (APPEND components Interpreter) +endif() +if (CHECK_LIBRARY OR CHECK_INCLUDE) + list (APPEND components Development) + if (CHECK_LIBRARY) + set (required_library "${Python3_LIBRARY}") + endif() + if (CHECK_INCLUDE) + set (required_include "${Python3_INCLUDE_DIR}") + endif() +endif() +if (CHECK_SABI_LIBRARY) + list (APPEND components Development.SABIModule) + set (required_sabi_library "${Python3_SABI_LIBRARY}") +endif() + +find_package (Python3 COMPONENTS ${components}) + + +if (PYTHON_IS_FOUND AND NOT Python3_FOUND) + message (FATAL_ERROR "Python3 unexpectedly not found") +endif() +if (NOT PYTHON_IS_FOUND AND Python3_FOUND) + message (FATAL_ERROR "Python3 unexpectedly found") +endif() + + +if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter) + message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE") +endif() + +if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library) + message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY") +endif() + +if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include) + message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR") +endif() + +if (CHECK_SABI_LIBRARY AND NOT Python3_SABI_LIBRARY_RELEASE STREQUAL required_sabi_library) + message (FATAL_ERROR "Failed to use input variable Python3_SABI_LIBRARY") +endif() diff --git a/Tests/RunCMake/FindPython/RunCMakeTest.cmake b/Tests/RunCMake/FindPython/RunCMakeTest.cmake new file mode 100644 index 0000000..5b77f55 --- /dev/null +++ b/Tests/RunCMake/FindPython/RunCMakeTest.cmake @@ -0,0 +1,329 @@ +include(RunCMake) + +if(RunCMake_BUILD_TYPE) + set(Python_BUILD_TYPE "${RunCMake_BUILD_TYPE}") +else() + set(Python_BUILD_TYPE "Release") +endif() + +function(run_python test) + set(one_value_args TYPE ACTION VARIANT STRATEGY) + set(multi_value_args OPTIONS) + cmake_parse_arguments(PARSE_ARGV 1 RP "" "${one_value_args}" "${multi_value_args}") + + if(RP_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "run_python: unparsed arguments: ${RP_UNPARSED_ARGUMENTS}") + endif() + + set(test_name "${test}") + if(RP_VARIANT) + string(APPEND test_name ".${RP_VARIANT}") + set(RunCMake_TEST_VARIANT_DESCRIPTION ".${RP_VARIANT}") + endif() + + set(options ${RP_OPTIONS}) + if(RP_STRATEGY) + string(APPEND test_name ".${RP_STRATEGY}") + string(APPEND RunCMake_TEST_VARIANT_DESCRIPTION ".${RP_STRATEGY}") + if (NOT RP_TYPE) + set(RP_TYPE ${test}) + endif() + list(APPEND options -D${RP_TYPE}_FIND_STRATEGY=${RP_STRATEGY}) + endif() + if(RP_TYPE) + list(APPEND options -DPYTHON=${RP_TYPE}) + endif() + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND options -DCMAKE_BUILD_TYPE=${Python_BUILD_TYPE}) + endif() + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test_name}-build") + if(options) + run_cmake_with_options(${test} ${options}) + else() + run_cmake(${test}) + endif() + if(NOT RP_ACTION) + return() + endif() + + set(RunCMake_TEST_NO_CLEAN 1) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + run_cmake_command(${test_name}-build ${CMAKE_COMMAND} --build . --config ${Python_BUILD_TYPE}) + if(RP_ACTION STREQUAL "BUILD") + return() + endif() + + run_cmake_command(${test_name}-run ${CMAKE_CTEST_COMMAND} -C ${Python_BUILD_TYPE} -V) +endfunction() + + +function(run_python_with_virtualenv test) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test}-build") + set(virtual_env "${RunCMake_TEST_BINARY_DIR}/py3venv") + run_cmake_with_options(${test} "-DPYTHON3_VIRTUAL_ENV=${virtual_env}") + set(RunCMake_TEST_NO_CLEAN 1) + set(tests Default Standard) + if(CMake_TEST_FindPython2) + list(APPEND tests Only) + endif() + if(test MATCHES "Conda") + set(RunCMake_TEST_VARIANT_DESCRIPTION ".Conda") + set(init_venv --unset=VIRTUAL_ENV "CONDA_PREFIX=${virtual_env}") + else() + set(RunCMake_TEST_VARIANT_DESCRIPTION ".CPython") + set(init_venv --unset=CONDA_PREFIX "VIRTUAL_ENV=${virtual_env}") + endif() + foreach(test IN LISTS tests) + run_cmake_script(VirtualEnv${test} -E env --unset=PYTHONHOME ${init_venv} + "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${virtual_env}") + endforeach() + if(CMake_TEST_FindPython2) + string(APPEND RunCMake_TEST_VARIANT_DESCRIPTION ".Unset") + run_cmake_script(VirtualEnvOnly -E env --unset=PYTHONHOME --unset=VIRTUAL_ENV --unset=CONDA_PREFIX + "${CMAKE_COMMAND}") + endif() +endfunction() + +macro(required_artifacts_check variant) + run_python(RequiredArtifactsCheck VARIANT ${variant} + OPTIONS "-DPYTHON_ARTIFACTS=${RunCMake_BINARY_DIR}/RequiredArtifacts-build/PythonArtifacts.cmake" + ${ARGN}) +endmacro() + +function(required_artifacts) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/RequiredArtifacts-build") + run_cmake_with_options(RequiredArtifacts "-DCMake_TEST_FindPython2=${CMake_TEST_FindPython2}" + "-DCMake_TEST_FindPython3_SABIModule=${CMake_TEST_FindPython3_SABIModule}") + if(EXISTS "${RunCMake_TEST_BINARY_DIR}/PythonArtifacts.cmake") + required_artifacts_check("Interpreter.VALID" -DPYTHON_IS_FOUND=TRUE + -DCHECK_INTERPRETER=ON) + required_artifacts_check("Interpreter.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=INTERPRETER + -DCHECK_INTERPRETER=ON) + required_artifacts_check("Library.VALID" -DPYTHON_IS_FOUND=TRUE + -DCHECK_LIBRARY=ON) + required_artifacts_check("Library.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=LIBRARY + -DCHECK_LIBRARY=ON) + required_artifacts_check("Include.VALID" -DPYTHON_IS_FOUND=TRUE + -DCHECK_INCLUDE=ON) + required_artifacts_check("Include.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=INCLUDE + -DCHECK_INCLUDE=ON) + required_artifacts_check("Interpreter.VALID,Library.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=LIBRARY + -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON) + required_artifacts_check("Library.VALID,Include.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=INCLUDE + -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON) + if (CMake_TEST_FindPython3_SABIModule AND WIN32) + required_artifacts_check("SABILibrary.VALID" -DPYTHON_IS_FOUND=TRUE + -DCHECK_SABI_LIBRARY=ON) + required_artifacts_check("SABILibrary.INVALID" -DPYTHON_IS_FOUND=FALSE -DINVALID_ARTIFACTS=SABI_LIBRARY + -DCHECK_SABI_LIBRARY=ON) + endif() + endif() +endfunction() + +function(custom_failure_message_check name components) + set(RunCMake_TEST_EXPECT_RESULT 1) + file(READ "${RunCMake_SOURCE_DIR}/CustomFailureMessage.${name}-stderr.txt" RunCMake_TEST_EXPECT_stderr) + run_python(CustomFailureMessage VARIANT "${name}" OPTIONS "-DCHECK_COMPONENTS=${components}" ${ARGN}) +endfunction() + + +if(CMake_TEST_FindPython2_CPython) + run_cmake(Python2-BadComponent) + run_python(Python2Module ACTION RUN) + run_python(Python2Embedded ACTION RUN) + run_python(Python2 STRATEGY LOCATION ACTION RUN) + run_python(Python2 STRATEGY VERSION ACTION RUN) + run_python(Python STRATEGY LOCATION VARIANT V2 ACTION RUN OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(Python STRATEGY VERSION VARIANT V2 OPTIONS ACTION RUN OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(ExactVersion TYPE Python2 STRATEGY LOCATION VARIANT Python2 + OPTIONS -DPython_REQUESTED_VERSION=2.1.2) + run_python(ExactVersion TYPE Python2 STRATEGY VERSION VARIANT Python2 + OPTIONS -DPython_REQUESTED_VERSION=2.1.2) + run_python(ExactVersion TYPE Python STRATEGY LOCATION VARIANT Python.V2 + OPTIONS -DPython_REQUESTED_VERSION=2.1.2) + run_python(ExactVersion TYPE Python STRATEGY VERSION VARIANT Python.V2 + OPTIONS -DPython_REQUESTED_VERSION=2.1.2) + run_python(VersionRange TYPE Python2 STRATEGY LOCATION VARIANT Python2 + OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(VersionRange TYPE Python2 STRATEGY VERSION VARIANT Python2 + OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(VersionRange TYPE Python STRATEGY LOCATION VARIANT Python.V2 + OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(VersionRange TYPE Python STRATEGY VERSION VARIANT Python.V2 + OPTIONS -DPython_REQUESTED_VERSION=2) +endif() + +if(CMake_TEST_FindPython3_CPython) + run_cmake(Python3-BadComponent) + run_cmake(DifferentComponents) + run_python(Python3Module ACTION RUN) + if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) + run_python(Python3Embedded ACTION RUN) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + run_cmake(UnversionedNames) + endif() + run_python(Python3 STRATEGY LOCATION ACTION RUN) + run_python(Python3 STRATEGY VERSION ACTION RUN) + run_python(Python STRATEGY LOCATION VARIANT V3 ACTION RUN OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(Python STRATEGY VERSION VARIANT V3 ACTION RUN OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(ExactVersion TYPE Python3 STRATEGY LOCATION VARIANT Python3 + OPTIONS -DPython_REQUESTED_VERSION=3.1.2) + run_python(ExactVersion TYPE Python3 STRATEGY VERSION VARIANT Python3 + OPTIONS -DPython_REQUESTED_VERSION=3.1.2) + run_python(ExactVersion TYPE Python STRATEGY LOCATION VARIANT Python.V3 + OPTIONS -DPython_REQUESTED_VERSION=3.1.2) + run_python(ExactVersion TYPE Python STRATEGY VERSION VARIANT Python.V3 + OPTIONS -DPython_REQUESTED_VERSION=3.1.2) + run_python(VersionRange TYPE Python3 STRATEGY LOCATION VARIANT Python3 + OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(VersionRange TYPE Python3 STRATEGY VERSION VARIANT Python3 + OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(VersionRange TYPE Python STRATEGY LOCATION VARIANT Python.V3 + OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(VersionRange TYPE Python STRATEGY VERSION VARIANT Python.V3 + OPTIONS -DPython_REQUESTED_VERSION=3) + custom_failure_message_check("Interpreter" "Interpreter" -DPython3_EXECUTABLE=/not/found/interpreter) + custom_failure_message_check("Library" "Development" -DPython3_LIBRARY=/not/found/library) + custom_failure_message_check("Include" "Development" -DPython3_INCLUDE_DIR=/not/found/include) + custom_failure_message_check("Multiple" "Interpreter:Development" -DPython3_EXECUTABLE=/not/found/interpreter + -DPython3_LIBRARY=/not/found/library) +endif() + +if(CMake_TEST_FindPython2_CPython OR CMake_TEST_FindPython3_CPython) + run_python(Python STRATEGY LOCATION VARIANT Python ACTION RUN) + run_python(Python STRATEGY VERSION VARIANT Python ACTION RUN) +endif() + +if(CMake_TEST_FindPython2_IronPython) + run_python(IronPython TYPE Python2 STRATEGY LOCATION VARIANT IronPython2) + run_python(IronPython TYPE Python2 STRATEGY VERSION VARIANT IronPython2) + run_python(IronPython TYPE Python STRATEGY LOCATION VARIANT V2 OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(IronPython TYPE Python STRATEGY VERSION VARIANT V2 OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(VersionRange TYPE Python2 STRATEGY LOCATION VARIANT IronPython2 + OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python2 STRATEGY VERSION VARIANT IronPython2 + OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python STRATEGY LOCATION VARIANT IronPython.V2 + OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python STRATEGY VERSION VARIANT IronPython.V2 + OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) +endif() + +if(CMake_TEST_FindPython3_IronPython) + run_python(IronPython TYPE Python3 STRATEGY LOCATION VARIANT IronPython3) + run_python(IronPython TYPE Python3 STRATEGY VERSION VARIANT IronPython3) + run_python(IronPython TYPE Python STRATEGY LOCATION VARIANT V3 OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(IronPython TYPE Python STRATEGY VERSION VARIANT V3 OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(VersionRange TYPE Python3 STRATEGY LOCATION VARIANT IronPython3 + OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python3 STRATEGY VERSION VARIANT IronPython3 + OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python STRATEGY LOCATION VARIANT IronPython.V3 + OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) + run_python(VersionRange TYPE Python STRATEGY VERSION VARIANT IronPython.V3 + OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython2_FIND_IMPLEMENTATIONS=IronPython) +endif() + +if(CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython) + run_python(IronPython TYPE Python STRATEGY LOCATION VARIANT IronPython) + run_python(IronPython TYPE Python STRATEGY VERSION VARIANT IronPython) +endif() + +if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython) + run_python(Implementation VARIANT CPython2 OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython_REQUESTED_IMPLEMENTATIONS=CPython) + run_python(Implementation VARIANT IronPython2 OPTIONS -DPython_REQUESTED_VERSION=2 + -DPython_REQUESTED_IMPLEMENTATIONS=IronPython) +endif() + +if (CMake_TEST_FindPython3 AND CMake_TEST_FindPython3_IronPython) + run_python(Implementation VARIANT CPython3 OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython_REQUESTED_IMPLEMENTATIONS=CPython) + run_python(Implementation VARIANT IronPython3 OPTIONS -DPython_REQUESTED_VERSION=3 + -DPython_REQUESTED_IMPLEMENTATIONS=IronPython) +endif() + +if(CMake_TEST_FindPython2_PyPy) + run_python(PyPy TYPE Python2 STRATEGY LOCATION VARIANT PyPy2) + run_python(PyPy TYPE Python2 STRATEGY VERSION VARIANT PyPy2) + run_python(PyPy TYPE Python STRATEGY LOCATION VARIANT V2 OPTIONS -DPython_REQUESTED_VERSION=2) + run_python(PyPy TYPE Python STRATEGY VERSION VARIANT V2 OPTIONS -DPython_REQUESTED_VERSION=2) +endif() + +if(CMake_TEST_FindPython3_PyPy) + run_python(PyPy TYPE Python3 STRATEGY LOCATION VARIANT PyPy3) + run_python(PyPy TYPE Python3 STRATEGY VERSION VARIANT PyPy3) + run_python(PyPy TYPE Python STRATEGY LOCATION VARIANT V3 OPTIONS -DPython_REQUESTED_VERSION=3) + run_python(PyPy TYPE Python STRATEGY VERSION VARIANT V3 OPTIONS -DPython_REQUESTED_VERSION=3) +endif() + +if(CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy) + run_python(PyPy TYPE Python STRATEGY LOCATION VARIANT PyPy) + run_python(PyPy TYPE Python STRATEGY VERSION VARIANT PyPy) +endif() + +if(CMake_TEST_FindPython_Various) + if(CMake_TEST_FindPython3) + run_python_with_virtualenv(VirtualEnv) + required_artifacts() + run_python(ArtifactsInteractive VARIANT "ON" + OPTIONS -DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy} + -DPython3_ARTIFACTS_INTERACTIVE=ON) + run_python(ArtifactsInteractive VARIANT "OFF" + OPTIONS -DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy} + -DPython3_ARTIFACTS_INTERACTIVE=OFF) + endif() + + if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) + if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") + run_python(SOABI VARIANT "Interpreter" ACTION BUILD + OPTIONS -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3} + -DCMake_TEST_FindPython_COMPONENT=Interpreter) + run_python(SOABI VARIANT "Development" ACTION BUILD + OPTIONS -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3} + -DCMake_TEST_FindPython_COMPONENT=Development) + endif() + run_python(MultiplePackages ACTION RUN + OPTIONS -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3}) + endif() + + if(CMake_TEST_FindPython2 AND CMake_TEST_FindPython3) + run_cmake(ArtifactsPrefix) + endif() + + if(CMake_TEST_FindPython2_SABIModule) + run_cmake(Python2SABIModule) + endif() + if(CMake_TEST_FindPython3_SABIModule) + run_python(Python3SABIModule) + endif() + + if(CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy) + run_python(NumPy ACTION RUN + OPTIONS -DCMake_TEST_FindPython2_NumPy=${CMake_TEST_FindPython2_NumPy} + -DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}) + run_python(NumPyOnly ACTION RUN + OPTIONS -DCMake_TEST_FindPython2_NumPy=${CMake_TEST_FindPython2_NumPy} + -DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}) + if(CMake_TEST_FindPython3_NumPy) + custom_failure_message_check("NumPy" "Interpreter:Development:NumPy" -DPython3_NumPy_INCLUDE_DIR=/not/found/numpy/include) + endif() + endif() + + if(CMake_TEST_FindPython3_Conda) + run_python_with_virtualenv(VirtualEnvConda) + endif() +endif() diff --git a/Tests/RunCMake/FindPython/SOABI.cmake b/Tests/RunCMake/FindPython/SOABI.cmake new file mode 100644 index 0000000..2a0bc95 --- /dev/null +++ b/Tests/RunCMake/FindPython/SOABI.cmake @@ -0,0 +1,39 @@ +enable_language(C) + +if(CMake_TEST_FindPython3) + find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) + if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") + endif() + + if(NOT DEFINED Python3_SOABI) + message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") + endif() + + if (Python3_Development_FOUND AND Python3_SOABI) + Python3_add_library (spam3 MODULE WITH_SOABI spam.c) + target_compile_definitions (spam3 PRIVATE PYTHON3) + + get_property (suffix TARGET spam3 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python3_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python3_SOABI") + endif() + endif() +endif() + +if(CMake_TEST_FindPython2) + find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT}) + if(NOT DEFINED Python2_SOABI) + message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found") + endif() + + if (Python2_Development_FOUND AND Python2_SOABI) + Python2_add_library (spam2 MODULE WITH_SOABI spam.c) + target_compile_definitions (spam2 PRIVATE PYTHON2) + + get_property (suffix TARGET spam2 PROPERTY SUFFIX) + if (NOT suffix MATCHES "^.${Python2_SOABI}") + message(FATAL_ERROR "Module suffix do not include Python2_SOABI") + endif() + endif() +endif() diff --git a/Tests/RunCMake/FindPython/TEST_spam.c b/Tests/RunCMake/FindPython/TEST_spam.c new file mode 100644 index 0000000..f1e6bd1 --- /dev/null +++ b/Tests/RunCMake/FindPython/TEST_spam.c @@ -0,0 +1,45 @@ +#if !defined(_WIN32) +/* Disabled for Windows to avoid to link with the wrong library specified by + * #pragma */ +# define Py_LIMITED_API 3 +#endif +#include + +static PyObject* spam_system(PyObject* self, PyObject* args) +{ + char const* command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + /* return PyLong_FromLong(sts); */ + return Py_BuildValue("i", sts); +} + +static PyMethodDef SpamMethods[] = { + { "system", spam_system, METH_VARARGS, "Execute a shell command." }, + { NULL, NULL, 0, NULL } /* Sentinel */ +}; + +#if defined(PYTHON2) +PyMODINIT_FUNC initTEST_spam2(void) +{ + (void)Py_InitModule("TEST_spam2", SpamMethods); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef spammodule = { + PyModuleDef_HEAD_INIT, "TEST_spam3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + SpamMethods +}; + +PyMODINIT_FUNC PyInit_TEST_spam3(void) +{ + return PyModule_Create(&spammodule); +} +#endif diff --git a/Tests/RunCMake/FindPython/UnversionedNames.cmake b/Tests/RunCMake/FindPython/UnversionedNames.cmake new file mode 100644 index 0000000..0f9123f --- /dev/null +++ b/Tests/RunCMake/FindPython/UnversionedNames.cmake @@ -0,0 +1,65 @@ + +# check if it is possible to find python with a generic name +find_program(UNVERSIONED_Python3 NAMES python3) + +if (NOT UNVERSIONED_Python3) + # no generic name available + # test cannot be done + return() +endif() + +# search with default configuration +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +if (Python3_EXECUTABLE STREQUAL UNVERSIONED_Python3) + # default configuration pick-up the generic name + # test cannot be completed + return() +endif() + +unset(Python3_EXECUTABLE) +# Force now to search first for generic name +set(Python3_FIND_UNVERSIONED_NAMES FIRST) + +set(Python3_FIND_FRAMEWORK NEVER) + +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +if (NOT Python3_EXECUTABLE STREQUAL UNVERSIONED_Python3) + message(SEND_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${UNVERSIONED_Python3}") +endif() + +# To check value 'NEVER", creates directory holding a symlink to the generic name +file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/bin") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +file(CREATE_LINK "${UNVERSIONED_Python3}" "${CMAKE_CURRENT_BINARY_DIR}/bin/python3" SYMBOLIC) + +unset(Python3_EXECUTABLE) +set(Python3_FIND_UNVERSIONED_NAMES FIRST) +set(Python3_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}") +# First search: generic name must be found +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +if (NOT Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") + message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${CMAKE_CURRENT_BINARY_DIR}/bin/python3") +endif() + +unset(Python3_EXECUTABLE) +set(Python3_FIND_UNVERSIONED_NAMES LAST) + +# Second search: generic name must be found +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +if (NOT Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") + message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE} instead of ${CMAKE_CURRENT_BINARY_DIR}/bin/python3") +endif() + +unset(Python3_EXECUTABLE) +set(Python3_FIND_UNVERSIONED_NAMES NEVER) + +# Third search: generic name must NOT be found +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +if (Python3_EXECUTABLE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/bin/python3") + message(FATAL_ERROR "Found unexpected interpreter ${Python3_EXECUTABLE}") +endif() diff --git a/Tests/RunCMake/FindPython/VersionRange.cmake b/Tests/RunCMake/FindPython/VersionRange.cmake new file mode 100644 index 0000000..34d3392 --- /dev/null +++ b/Tests/RunCMake/FindPython/VersionRange.cmake @@ -0,0 +1,62 @@ +enable_language(C) + + +find_package (${PYTHON} ${Python_REQUESTED_VERSION} EXACT COMPONENTS Interpreter) +if (NOT ${PYTHON}_FOUND) + message (FATAL_ERROR "Failed to find ${PYTHON} ${Python_REQUESTED_VERSION}") +endif() + +if (Python_REQUESTED_VERSION VERSION_LESS 3.0) + set (IN_VERSION_RANGE 2.0...<3.0) + set (OUT_VERSION_RANGE 2.0...<${${PYTHON}_VERSION}) +else() + set (IN_VERSION_RANGE 3.0...<4.0) + set (OUT_VERSION_RANGE 3.0...<${${PYTHON}_VERSION}) +endif() + +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 (${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 '${PYTHON} ${Python_REQUESTED_VERSION}.0...<${${PYTHON}_VERSION} ${ARGN}'") + endif() + return() + endif() + + if (NOT ${PYTHON}_FOUND) + message (SEND_ERROR "Not found: ${PYTHON} ${RANGE} ${ARGN}") + elseif (NOT ${PYTHON}_VERSION VERSION_EQUAL EXPECTED_VERSION) + message (SEND_ERROR "Wrong version: ${${PYTHON}_VERSION} for '${PYTHON} ${RANGE} ${ARGN}'") + endif() +endfunction() + +find_python (${${PYTHON}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Interpreter) +if (${PYTHON}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") + find_python (${${PYTHON}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Compiler) +else() + find_python (${${PYTHON}_VERSION} ${IN_VERSION_RANGE} COMPONENTS Development) +endif() + +find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Interpreter) +if (${PYTHON}_FIND_IMPLEMENTATIONS STREQUAL "IronPython") + find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Compiler) +else() + find_python ("NONE" ${OUT_VERSION_RANGE} COMPONENTS Development) +endif() + +find_python ("NONE" 5...6 COMPONENTS Interpreter) diff --git a/Tests/RunCMake/FindPython/VirtualEnv.cmake b/Tests/RunCMake/FindPython/VirtualEnv.cmake new file mode 100644 index 0000000..26f8146 --- /dev/null +++ b/Tests/RunCMake/FindPython/VirtualEnv.cmake @@ -0,0 +1,15 @@ + +find_package(Python3 REQUIRED COMPONENTS Interpreter) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Failed to find Python 3") +endif() + +file (REMOVE_RECURSE "${PYTHON3_VIRTUAL_ENV}") + +execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${PYTHON3_VIRTUAL_ENV}" + RESULT_VARIABLE result + OUTPUT_VARIABLE outputs + ERROR_VARIABLE outputs) +if (result) + message (FATAL_ERROR "Fail to create virtual environment: ${outputs}") +endif() diff --git a/Tests/RunCMake/FindPython/VirtualEnvConda.cmake b/Tests/RunCMake/FindPython/VirtualEnvConda.cmake new file mode 100644 index 0000000..63da931 --- /dev/null +++ b/Tests/RunCMake/FindPython/VirtualEnvConda.cmake @@ -0,0 +1,17 @@ + +if(DEFINED ENV{CONDA_EXE}) + set(CONDA_EXECUTABLE "$ENV{CONDA_EXE}") +else() + find_program(CONDA_EXECUTABLE conda NO_CACHE) + if (NOT CONDA_EXECUTABLE) + message (FATAL_ERROR "Failed to find Conda") + endif() +endif() + +execute_process (COMMAND "${CONDA_EXECUTABLE}" create --no-default-packages --prefix "${PYTHON3_VIRTUAL_ENV}" --yes python=3 + RESULT_VARIABLE result + OUTPUT_VARIABLE outputs + ERROR_VARIABLE outputs) +if (result) + message (FATAL_ERROR "Fail to create virtual environment: ${outputs}") +endif() diff --git a/Tests/RunCMake/FindPython/VirtualEnvDefault.cmake b/Tests/RunCMake/FindPython/VirtualEnvDefault.cmake new file mode 100644 index 0000000..8f56d00 --- /dev/null +++ b/Tests/RunCMake/FindPython/VirtualEnvDefault.cmake @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) + +find_package (Python3 REQUIRED) + +if (NOT Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") + message (FATAL_ERROR "Fail to use virtual environment") +endif() diff --git a/Tests/RunCMake/FindPython/VirtualEnvOnly.cmake b/Tests/RunCMake/FindPython/VirtualEnvOnly.cmake new file mode 100644 index 0000000..9ae4975 --- /dev/null +++ b/Tests/RunCMake/FindPython/VirtualEnvOnly.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.15) + +# +# Virtual environment is defined for python3 +# Trying to find a python2 using only virtual environment +# It is expecting to fail if a virtual environment is active and to success otherwise. +# +set (Python2_FIND_VIRTUALENV ONLY) +find_package (Python2 QUIET) + +if (PYTHON3_VIRTUAL_ENV AND Python2_FOUND) + message (FATAL_ERROR "Python2 unexpectedly found.") +endif() + +if (NOT PYTHON3_VIRTUAL_ENV AND NOT Python2_FOUND) + message (FATAL_ERROR "Fail to find Python2.") +endif() diff --git a/Tests/RunCMake/FindPython/VirtualEnvStandard.cmake b/Tests/RunCMake/FindPython/VirtualEnvStandard.cmake new file mode 100644 index 0000000..353a91b --- /dev/null +++ b/Tests/RunCMake/FindPython/VirtualEnvStandard.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) + +set (Python3_FIND_VIRTUALENV STANDARD) +find_package (Python3 REQUIRED) + +if (Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+") + message (FATAL_ERROR "Python3 virtual env unexpectedly found.") +endif() diff --git a/Tests/RunCMake/FindPython/arraytest.c b/Tests/RunCMake/FindPython/arraytest.c new file mode 100644 index 0000000..6bead00 --- /dev/null +++ b/Tests/RunCMake/FindPython/arraytest.c @@ -0,0 +1,58 @@ +#include "Python.h" + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include + +#include "numpy/arrayobject.h" + +static PyObject* vecsq(PyObject* self, PyObject* args); + +static PyMethodDef arraytestMethods[] = { { "vecsq", vecsq, METH_VARARGS }, + { NULL, NULL } }; + +static PyObject* vecsq(PyObject* self, PyObject* args) +{ + PyArrayObject *vecin, *vecout; + npy_intp dims[2]; + double *cin, *cout; + int i, j, n, m; + + if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &vecin)) + return NULL; + + n = dims[0] = PyArray_NDIM(vecin); + vecout = (PyArrayObject*)PyArray_SimpleNew(1, dims, NPY_DOUBLE); + + cin = (double*)PyArray_DATA(vecin); + cout = (double*)PyArray_DATA(vecout); + + for (i = 0; i < n; i++) { + cout[i] = cin[i] * cin[i]; + } + return PyArray_Return(vecout); +} + +#if defined(PYTHON2) +PyMODINIT_FUNC initarraytest2(void) +{ + (void)Py_InitModule("arraytest2", arraytestMethods); + import_array(); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef arraytestmodule = { + PyModuleDef_HEAD_INIT, "arraytest3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + arraytestMethods +}; + +PyMODINIT_FUNC PyInit_arraytest3(void) +{ + PyObject* po = PyModule_Create(&arraytestmodule); + import_array(); + return po; +} +#endif diff --git a/Tests/RunCMake/FindPython/display_time.c b/Tests/RunCMake/FindPython/display_time.c new file mode 100644 index 0000000..7b95f1f --- /dev/null +++ b/Tests/RunCMake/FindPython/display_time.c @@ -0,0 +1,41 @@ + +#include + +#define PY_SSIZE_T_CLEAN +#include + +#include "display_time.h" + +void display_time(void) +{ +#if defined(PYTHON3) + PyConfig config; + PyStatus status; + + PyConfig_InitPythonConfig(&config); + status = + PyConfig_SetBytesString(&config, &config.program_name, "display_time"); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + + char* cmd = "from time import time,ctime\n" + "print('Today is', ctime(time()))\n"; +#else + char* program = "display_time"; + char* cmd = "from time import time,ctime\n" + "print 'Today is', ctime(time())\n"; + + Py_SetProgramName(program); /* optional but recommended */ +#endif + Py_Initialize(); + PyRun_SimpleString(cmd); +#if defined(PYTHON3) + if (Py_FinalizeEx() < 0) { + exit(120); + } + PyConfig_Clear(&config); +#else + Py_Finalize(); +#endif +} diff --git a/Tests/RunCMake/FindPython/display_time.h b/Tests/RunCMake/FindPython/display_time.h new file mode 100644 index 0000000..d825e02 --- /dev/null +++ b/Tests/RunCMake/FindPython/display_time.h @@ -0,0 +1,2 @@ + +void display_time(); diff --git a/Tests/RunCMake/FindPython/main.c b/Tests/RunCMake/FindPython/main.c new file mode 100644 index 0000000..0119ce0 --- /dev/null +++ b/Tests/RunCMake/FindPython/main.c @@ -0,0 +1,7 @@ + +#include "display_time.h" + +int main(void) +{ + display_time(); +} diff --git a/Tests/RunCMake/FindPython/spam.c b/Tests/RunCMake/FindPython/spam.c new file mode 100644 index 0000000..29661f8 --- /dev/null +++ b/Tests/RunCMake/FindPython/spam.c @@ -0,0 +1,45 @@ +#if !defined(_WIN32) +/* Disabled for Windows to avoid to link with the wrong library specified by + * #pragma */ +# define Py_LIMITED_API 3 +#endif +#include + +static PyObject* spam_system(PyObject* self, PyObject* args) +{ + char const* command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + /* return PyLong_FromLong(sts); */ + return Py_BuildValue("i", sts); +} + +static PyMethodDef SpamMethods[] = { + { "system", spam_system, METH_VARARGS, "Execute a shell command." }, + { NULL, NULL, 0, NULL } /* Sentinel */ +}; + +#if defined(PYTHON2) +PyMODINIT_FUNC initspam2(void) +{ + (void)Py_InitModule("spam2", SpamMethods); +} +#endif + +#if defined(PYTHON3) +static struct PyModuleDef spammodule = { + PyModuleDef_HEAD_INIT, "spam3", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + SpamMethods +}; + +PyMODINIT_FUNC PyInit_spam3(void) +{ + return PyModule_Create(&spammodule); +} +#endif diff --git a/Tests/RunCMake/FindPython/subdir/CMakeLists.txt b/Tests/RunCMake/FindPython/subdir/CMakeLists.txt new file mode 100644 index 0000000..98fcd5f --- /dev/null +++ b/Tests/RunCMake/FindPython/subdir/CMakeLists.txt @@ -0,0 +1,2 @@ + +find_package(Python3 REQUIRED COMPONENTS Development) -- cgit v0.12