Просмотр исходного кода

Merge topic 'FindPython-tests-refactoring'

aed9dffdc9 FindPython: migrate tests to RunCMake framework

Acked-by: Kitware Robot <[email protected]>
Merge-request: !10380
Marc Chevrier 11 месяцев назад
Родитель
Сommit
5120987bc3
77 измененных файлов с 899 добавлено и 1915 удалено
  1. 2 2
      Modules/FindPython/Support.cmake
  2. 30 38
      Tests/CMakeLists.txt
  3. 0 955
      Tests/FindPython/CMakeLists.txt
  4. 0 79
      Tests/FindPython/CustomFailureMessage/CMakeLists.txt
  5. 0 5
      Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt
  6. 0 56
      Tests/FindPython/ExactVersion/CMakeLists.txt
  7. 0 31
      Tests/FindPython/IronPython/CMakeLists.txt
  8. 0 31
      Tests/FindPython/IronPython2/CMakeLists.txt
  9. 0 31
      Tests/FindPython/IronPython3/CMakeLists.txt
  10. 0 24
      Tests/FindPython/NumPyOnly/CMakeLists.txt
  11. 0 37
      Tests/FindPython/PyPy/CMakeLists.txt
  12. 0 37
      Tests/FindPython/PyPy2/CMakeLists.txt
  13. 0 37
      Tests/FindPython/PyPy3/CMakeLists.txt
  14. 0 14
      Tests/FindPython/Python2Fail/CMakeLists.txt
  15. 0 14
      Tests/FindPython/Python3Fail/CMakeLists.txt
  16. 0 196
      Tests/FindPython/RequiredArtifacts/CMakeLists.txt
  17. 0 64
      Tests/FindPython/VersionRange/CMakeLists.txt
  18. 0 49
      Tests/FindPython/VirtualEnv/CMakeLists.txt
  19. 0 48
      Tests/FindPython/VirtualEnvConda/CMakeLists.txt
  20. 0 7
      Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake
  21. 0 17
      Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake
  22. 0 8
      Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake
  23. 65 0
      Tests/RunCMake/CMakeLists.txt
  24. 1 3
      Tests/RunCMake/FindPython/ArtifactsInteractive.cmake
  25. 1 3
      Tests/RunCMake/FindPython/ArtifactsPrefix.cmake
  26. 3 0
      Tests/RunCMake/FindPython/CMakeLists.txt
  27. 4 0
      Tests/RunCMake/FindPython/CustomFailureMessage.Include-stderr.txt
  28. 4 0
      Tests/RunCMake/FindPython/CustomFailureMessage.Interpreter-stderr.txt
  29. 4 0
      Tests/RunCMake/FindPython/CustomFailureMessage.Library-stderr.txt
  30. 6 0
      Tests/RunCMake/FindPython/CustomFailureMessage.Multiple-stderr.txt
  31. 4 0
      Tests/RunCMake/FindPython/CustomFailureMessage.NumPy-stderr.txt
  32. 4 0
      Tests/RunCMake/FindPython/CustomFailureMessage.cmake
  33. 1 3
      Tests/RunCMake/FindPython/DifferentComponents.cmake
  34. 54 0
      Tests/RunCMake/FindPython/ExactVersion.cmake
  35. 0 0
      Tests/RunCMake/FindPython/FindPythonScript.cmake
  36. 0 4
      Tests/RunCMake/FindPython/Implementation.cmake
  37. 36 0
      Tests/RunCMake/FindPython/IronPython.cmake
  38. 5 5
      Tests/RunCMake/FindPython/MultiplePackages.cmake
  39. 2 2
      Tests/RunCMake/FindPython/NumPy.cmake
  40. 31 0
      Tests/RunCMake/FindPython/NumPyOnly.cmake
  41. 43 0
      Tests/RunCMake/FindPython/PyPy.cmake
  42. 4 6
      Tests/RunCMake/FindPython/Python.cmake
  43. 1 0
      Tests/RunCMake/FindPython/Python2-BadComponent-result.txt
  44. 2 0
      Tests/RunCMake/FindPython/Python2-BadComponent-stderr.txt
  45. 3 0
      Tests/RunCMake/FindPython/Python2-BadComponent.cmake
  46. 4 6
      Tests/RunCMake/FindPython/Python2.cmake
  47. 3 5
      Tests/RunCMake/FindPython/Python2Embedded.cmake
  48. 2 4
      Tests/RunCMake/FindPython/Python2Module.cmake
  49. 1 0
      Tests/RunCMake/FindPython/Python2SABIModule-result.txt
  50. 2 0
      Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt
  51. 1 3
      Tests/RunCMake/FindPython/Python2SABIModule.cmake
  52. 1 0
      Tests/RunCMake/FindPython/Python3-BadComponent-result.txt
  53. 2 0
      Tests/RunCMake/FindPython/Python3-BadComponent-stderr.txt
  54. 3 0
      Tests/RunCMake/FindPython/Python3-BadComponent.cmake
  55. 5 64
      Tests/RunCMake/FindPython/Python3.cmake
  56. 3 5
      Tests/RunCMake/FindPython/Python3Embedded.cmake
  57. 2 4
      Tests/RunCMake/FindPython/Python3Module.cmake
  58. 2 4
      Tests/RunCMake/FindPython/Python3SABIModule.cmake
  59. 32 0
      Tests/RunCMake/FindPython/PythonArtifacts.cmake.in
  60. 84 0
      Tests/RunCMake/FindPython/RequiredArtifacts.cmake
  61. 2 2
      Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake
  62. 329 0
      Tests/RunCMake/FindPython/RunCMakeTest.cmake
  63. 3 5
      Tests/RunCMake/FindPython/SOABI.cmake
  64. 5 1
      Tests/RunCMake/FindPython/TEST_spam.c
  65. 2 3
      Tests/RunCMake/FindPython/UnversionedNames.cmake
  66. 62 0
      Tests/RunCMake/FindPython/VersionRange.cmake
  67. 15 0
      Tests/RunCMake/FindPython/VirtualEnv.cmake
  68. 17 0
      Tests/RunCMake/FindPython/VirtualEnvConda.cmake
  69. 0 0
      Tests/RunCMake/FindPython/VirtualEnvDefault.cmake
  70. 0 0
      Tests/RunCMake/FindPython/VirtualEnvOnly.cmake
  71. 0 0
      Tests/RunCMake/FindPython/VirtualEnvStandard.cmake
  72. 2 2
      Tests/RunCMake/FindPython/arraytest.c
  73. 0 0
      Tests/RunCMake/FindPython/display_time.c
  74. 0 0
      Tests/RunCMake/FindPython/display_time.h
  75. 0 0
      Tests/RunCMake/FindPython/main.c
  76. 5 1
      Tests/RunCMake/FindPython/spam.c
  77. 0 0
      Tests/RunCMake/FindPython/subdir/CMakeLists.txt

+ 2 - 2
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)

+ 30 - 38
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()

+ 0 - 955
Tests/FindPython/CMakeLists.txt

@@ -1,955 +0,0 @@
-if(CMake_TEST_FindPython2)
-  add_test(NAME FindPython.Python2.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python2.Development.Module COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python2Fail COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.V2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python2.ExactVersion.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python2.ExactVersion.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python.V2.ExactVersion.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.V2.ExactVersion.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python2.VersionRange.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python3.Development.Module COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python3Fail COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.V3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python3.ExactVersion.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python3.ExactVersion.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.V3.ExactVersion.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.V3.ExactVersion.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.Python3.VersionRange.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-      --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 $<CONFIGURATION>
-      )
-  endif()
-
-  add_test(NAME FindPython.RequiredArtifacts COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.ArtifactsInteractive.ON COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.ArtifactsInteractive.OFF COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.CustomFailureMessage COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.DifferentComponents COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-      --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Python.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  if (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
-    add_test(NAME FindPython.Interpreter.SOABI COMMAND
-      ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-      --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 $<CONFIGURATION>
-      )
-    add_test(NAME FindPython.Development.SOABI COMMAND
-      ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-      --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 $<CONFIGURATION>
-      )
-
-    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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-  )
-  add_test(NAME FindPython.NumPyOnly COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Implementation.IronPython2 COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.Implementation.IronPython3 COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.IronPython2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.IronPython.V2.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.IronPython.V2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.IronPython2.VersionRange.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.IronPython3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.IronPython.V3.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.IronPython.V3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.IronPython3.VersionRange.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.IronPython.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.PyPy2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.PyPy.V2.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.PyPy.V2.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.PyPy3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  add_test(NAME FindPython.PyPy.V3.LOCATION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.PyPy.V3.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  add_test(NAME FindPython.PyPy.VERSION COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-
-  set_property(TEST FindPython.PyPy.LOCATION FindPython.PyPy.VERSION
-               APPEND PROPERTY LABELS Python2 Python3)
-endif()

+ 0 - 79
Tests/FindPython/CustomFailureMessage/CMakeLists.txt

@@ -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 $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-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 $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-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 $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-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 $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-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 $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-    )
-  set_tests_properties(FindPython.CustomFailureMessage.NumPy PROPERTIES
-    PASS_REGULAR_EXPRESSION "Reason given by package:.+NumPy: Cannot find the directory")
-endif()

+ 0 - 5
Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt

@@ -1,5 +0,0 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestCustomFailureMessage.Check LANGUAGES NONE)
-
-find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS})

+ 0 - 56
Tests/FindPython/ExactVersion/CMakeLists.txt

@@ -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()

+ 0 - 31
Tests/FindPython/IronPython/CMakeLists.txt

@@ -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()

+ 0 - 31
Tests/FindPython/IronPython2/CMakeLists.txt

@@ -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()

+ 0 - 31
Tests/FindPython/IronPython3/CMakeLists.txt

@@ -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()

+ 0 - 24
Tests/FindPython/NumPyOnly/CMakeLists.txt

@@ -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()

+ 0 - 37
Tests/FindPython/PyPy/CMakeLists.txt

@@ -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()

+ 0 - 37
Tests/FindPython/PyPy2/CMakeLists.txt

@@ -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()

+ 0 - 37
Tests/FindPython/PyPy3/CMakeLists.txt

@@ -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()

+ 0 - 14
Tests/FindPython/Python2Fail/CMakeLists.txt

@@ -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=$<TARGET_FILE_DIR:spam2>"
-          "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")

+ 0 - 14
Tests/FindPython/Python3Fail/CMakeLists.txt

@@ -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=$<TARGET_FILE_DIR:spam3>"
-          "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")

+ 0 - 196
Tests/FindPython/RequiredArtifacts/CMakeLists.txt

@@ -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 $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-add_test(NAME FindPython.RequiredArtifacts.Interpreter.INVALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-
-add_test(NAME FindPython.RequiredArtifacts.Library.VALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-
-add_test(NAME FindPython.RequiredArtifacts.Include.VALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-
-add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-
-add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND
-  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-  --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 $<CONFIGURATION>
-  )
-
-if (CMake_TEST_FindPython3_SABIModule AND WIN32)
-  add_test(NAME FindPython.RequiredArtifacts.SABILibrary.VALID COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-  )
-  add_test(NAME FindPython.RequiredArtifacts.SABILibrary.INVALID COMMAND
-    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
-    --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 $<CONFIGURATION>
-  )
-endif()

+ 0 - 64
Tests/FindPython/VersionRange/CMakeLists.txt

@@ -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)

+ 0 - 49
Tests/FindPython/VirtualEnv/CMakeLists.txt

@@ -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()

+ 0 - 48
Tests/FindPython/VirtualEnvConda/CMakeLists.txt

@@ -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()

+ 0 - 7
Tests/FindPython/VirtualEnvConda/VirtualEnvDefault.cmake

@@ -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()

+ 0 - 17
Tests/FindPython/VirtualEnvConda/VirtualEnvOnly.cmake

@@ -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()

+ 0 - 8
Tests/FindPython/VirtualEnvConda/VirtualEnvStandard.cmake

@@ -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()

+ 65 - 0
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)

+ 1 - 3
Tests/FindPython/ArtifactsInteractive/CMakeLists.txt → Tests/RunCMake/FindPython/ArtifactsInteractive.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestArtifactsInteractive LANGUAGES C)
+enable_language(C)
 
 set (components Interpreter Development)
 if (CMake_TEST_FindPython3_NumPy)

+ 1 - 3
Tests/FindPython/ArtifactsPrefix/CMakeLists.txt → Tests/RunCMake/FindPython/ArtifactsPrefix.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.31)
-
-project(TestArtifactsPrefix C)
+enable_language(C)
 
 set(Python_ARTIFACTS_PREFIX "_V2")
 find_package (Python 2 EXACT REQUIRED)

+ 3 - 0
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)

+ 4 - 0
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"

+ 4 - 0
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"

+ 4 - 0
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"

+ 6 - 0
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"

+ 4 - 0
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"

+ 4 - 0
Tests/RunCMake/FindPython/CustomFailureMessage.cmake

@@ -0,0 +1,4 @@
+
+string(REPLACE ":" ";" CHECK_COMPONENTS "${CHECK_COMPONENTS}")
+
+find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS})

+ 1 - 3
Tests/FindPython/DifferentComponents/CMakeLists.txt → Tests/RunCMake/FindPython/DifferentComponents.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestDifferentComponents LANGUAGES C)
+enable_language(C)
 
 add_subdirectory(subdir)
 

+ 54 - 0
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()

+ 0 - 0
Tests/FindPython/FindPythonScript.cmake → Tests/RunCMake/FindPython/FindPythonScript.cmake


+ 0 - 4
Tests/FindPython/Implementation/CMakeLists.txt → Tests/RunCMake/FindPython/Implementation.cmake

@@ -1,7 +1,3 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} LANGUAGES NONE)
-
 
 set (Python${Python_REQUESTED_VERSION}_FIND_IMPLEMENTATIONS ${Python_REQUESTED_IMPLEMENTATION})
 

+ 36 - 0
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()

+ 5 - 5
Tests/FindPython/MultiplePackages/CMakeLists.txt → Tests/RunCMake/FindPython/MultiplePackages.cmake

@@ -1,6 +1,6 @@
-cmake_minimum_required(VERSION 3.15)
+enable_language(C)
 
-project(TestMultiplePackages C)
+include(CTest)
 
 find_package (Python REQUIRED)
 
@@ -15,11 +15,11 @@ if (CMake_TEST_FindPython2)
     )
   endif()
 
-  Python2_add_library (spam2 MODULE ../spam.c)
+  Python2_add_library (spam2 MODULE spam.c)
   target_compile_definitions (spam2 PRIVATE PYTHON2)
 
   add_test (NAME python2_spam2
-            COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+            COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
             "${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")")
 
 endif()
@@ -35,7 +35,7 @@ if (CMake_TEST_FindPython3)
     )
   endif()
 
-  Python3_add_library (spam3 MODULE ../spam.c)
+  Python3_add_library (spam3 MODULE spam.c)
   target_compile_definitions (spam3 PRIVATE PYTHON3)
 
   add_test (NAME python3_spam3

+ 2 - 2
Tests/FindPython/NumPy/CMakeLists.txt → Tests/RunCMake/FindPython/NumPy.cmake

@@ -1,6 +1,6 @@
-cmake_minimum_required(VERSION 3.15)
+enable_language(C)
 
-project(TestNumPy LANGUAGES C)
+include(CTest)
 
 if(CMake_TEST_FindPython2_NumPy)
 

+ 31 - 0
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=$<TARGET_FILE_DIR:arraytest2>"
+    "${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=$<TARGET_FILE_DIR:arraytest3>"
+    "${Python3_INTERPRETER}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
+
+endif()

+ 43 - 0
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()

+ 4 - 6
Tests/FindPython/Python/CMakeLists.txt → Tests/RunCMake/FindPython/Python.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -27,7 +25,7 @@ if(NOT TARGET Python::Module)
 endif()
 
 if (Python_REQUESTED_VERSION)
-  Python_add_library (spam${Python_REQUESTED_VERSION} MODULE ../spam.c)
+  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}
@@ -36,7 +34,7 @@ if (Python_REQUESTED_VERSION)
 else()
   add_test(NAME findpython_script
            COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python
-           -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+           -P "${CMAKE_CURRENT_LIST_DIR}/FindPythonScript.cmake")
 endif()
 
 
@@ -71,7 +69,7 @@ if(NOT TARGET Python_TEST::Module)
 endif()
 
 if (Python_REQUESTED_VERSION)
-  Python_TEST_add_library (TEST_spam${Python_REQUESTED_VERSION} MODULE ../TEST_spam.c)
+  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}

+ 1 - 0
Tests/RunCMake/FindPython/Python2-BadComponent-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
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.]+"\)

+ 3 - 0
Tests/RunCMake/FindPython/Python2-BadComponent.cmake

@@ -0,0 +1,3 @@
+enable_language(C)
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development foobar)

+ 4 - 6
Tests/FindPython/Python2/CMakeLists.txt → Tests/RunCMake/FindPython/Python2.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython2 LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -34,7 +32,7 @@ if(NOT TARGET Python2::Module)
   message(SEND_ERROR "Python2::Module not found")
 endif()
 
-Python2_add_library (spam2 MODULE ../spam.c)
+Python2_add_library (spam2 MODULE spam.c)
 target_compile_definitions (spam2 PRIVATE PYTHON2)
 
 add_test (NAME python2_spam2
@@ -44,7 +42,7 @@ add_test (NAME python2_spam2
 add_test(NAME findpython2_script
          COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2
          -DPython2_FIND_STRATEGY=${Python2_FIND_STRATEGY}
-         -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+         -P "${CMAKE_CURRENT_LIST_DIR}/FindPythonScript.cmake")
 
 
 #
@@ -80,7 +78,7 @@ 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)
+Python2_TEST_add_library (TEST_spam2 MODULE TEST_spam.c)
 target_compile_definitions (TEST_spam2 PRIVATE PYTHON2)
 
 add_test (NAME python2_TEST_spam2

+ 3 - 5
Tests/FindPython/Python2Embedded/CMakeLists.txt → Tests/RunCMake/FindPython/Python2Embedded.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython2Embedded LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -26,11 +24,11 @@ if(NOT TARGET Python2::Python)
   message(SEND_ERROR "Python2::Python not found")
 endif()
 
-Python2_add_library (display_time2 SHARED ../display_time.c)
+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)
+add_executable (main2 main.c)
 target_link_libraries (main2 PRIVATE display_time2)
 
 if (WIN32 OR CYGWIN OR MSYS OR MINGW)

+ 2 - 4
Tests/FindPython/Python2Module/CMakeLists.txt → Tests/RunCMake/FindPython/Python2Module.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython2Module LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -29,7 +27,7 @@ if(NOT TARGET Python2::Module)
   message(SEND_ERROR "Python2::Module not found")
 endif()
 
-Python2_add_library (spam2 MODULE ../spam.c)
+Python2_add_library (spam2 MODULE spam.c)
 target_compile_definitions (spam2 PRIVATE PYTHON2)
 
 add_test (NAME python2_spam2

+ 1 - 0
Tests/RunCMake/FindPython/Python2SABIModule-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/FindPython/Python2SABIModule-stderr.txt

@@ -0,0 +1,2 @@
+      Reason given by package: *
+          Development: SABIModule requires version 3.2 or upper.

+ 1 - 3
Tests/FindPython/Python2SABIModule/CMakeLists.txt → Tests/RunCMake/FindPython/Python2SABIModule.cmake

@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython2SABIModule LANGUAGES C)
+enable_language(C)
 
 find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module Development.SABIModule)

+ 1 - 0
Tests/RunCMake/FindPython/Python3-BadComponent-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
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.]+"\)

+ 3 - 0
Tests/RunCMake/FindPython/Python3-BadComponent.cmake

@@ -0,0 +1,3 @@
+enable_language(C)
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development foobar)

+ 5 - 64
Tests/FindPython/Python3/CMakeLists.txt → Tests/RunCMake/FindPython/Python3.cmake

@@ -1,6 +1,5 @@
-cmake_minimum_required(VERSION 3.15)
 
-project(TestPython3 LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -34,7 +33,7 @@ if(NOT TARGET Python3::Module)
   message(SEND_ERROR "Python3::Module not found")
 endif()
 
-Python3_add_library (spam3 MODULE ../spam.c)
+Python3_add_library (spam3 MODULE spam.c)
 target_compile_definitions (spam3 PRIVATE PYTHON3)
 
 add_test (NAME python3_spam3
@@ -44,65 +43,7 @@ add_test (NAME python3_spam3
 add_test(NAME findpython3_script
          COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
          -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
-         -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
-
-
-## Try a new search specifying only expected ABI
-# retrieve ABI of python interpreter
-execute_process (COMMAND "${Python3_EXECUTABLE}" -c
-                         "import sys; sys.stdout.write(sys.abiflags)"
-                 RESULT_VARIABLE result
-                 OUTPUT_VARIABLE abi
-                 ERROR_QUIET
-                 OUTPUT_STRIP_TRAILING_WHITESPACE)
-if (result)
-  # assume ABI is not supported
-  set (abi "")
-endif()
-
-# define FIND_ABI variable
-if (abi MATCHES "d")
-  set (Python3_VALID_ABI "ON")
-else()
-  set (Python3_VALID_ABI "OFF")
-endif()
-if (abi MATCHES "m")
-  list (APPEND Python3_VALID_ABI "ON")
-else()
-  list (APPEND Python3_VALID_ABI "OFF")
-endif()
-if (abi MATCHES "u")
-  list (APPEND Python3_VALID_ABI "ON")
-else()
-  list (APPEND Python3_VALID_ABI "OFF")
-endif()
-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")
-
+         -P "${CMAKE_CURRENT_LIST_DIR}/FindPythonScript.cmake")
 
 #
 # New search with user's prefix
@@ -137,9 +78,9 @@ 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)
+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=$<TARGET_FILE_DIR:TEST_spam3>"
-          "${Python3_TEST_INTERPRETER}" -c "import TEST_spam3; TEST_spam3.system(\"cd\")")
+          "${Python3_INTERPRETER}" -c "import TEST_spam3; TEST_spam3.system(\"cd\")")

+ 3 - 5
Tests/FindPython/Python3Embedded/CMakeLists.txt → Tests/RunCMake/FindPython/Python3Embedded.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython3Embedded LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -26,11 +24,11 @@ if(NOT TARGET Python3::Python)
   message(SEND_ERROR "Python3::Python not found")
 endif()
 
-Python3_add_library (display_time3 SHARED ../display_time.c)
+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)
+add_executable (main3 main.c)
 target_link_libraries (main3 PRIVATE display_time3)
 
 if (WIN32 OR CYGWIN OR MSYS OR MINGW)

+ 2 - 4
Tests/FindPython/Python3Module/CMakeLists.txt → Tests/RunCMake/FindPython/Python3Module.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython3Module LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -38,7 +36,7 @@ if(NOT TARGET Python3::Module)
   message(SEND_ERROR "Python3::Module not found")
 endif()
 
-Python3_add_library (spam3 MODULE ../spam.c)
+Python3_add_library (spam3 MODULE spam.c)
 target_compile_definitions (spam3 PRIVATE PYTHON3)
 
 add_test (NAME python3_spam3

+ 2 - 4
Tests/FindPython/Python3SABIModule/CMakeLists.txt → Tests/RunCMake/FindPython/Python3SABIModule.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestPython3SABIModule LANGUAGES C)
+enable_language(C)
 
 include(CTest)
 
@@ -39,7 +37,7 @@ 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)
+Python3_add_library (spam3 MODULE USE_SABI 3 WITH_SOABI spam.c)
 target_compile_definitions (spam3 PRIVATE PYTHON3)
 
 if (Python3_SOSABI)

+ 32 - 0
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()

+ 84 - 0
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)

+ 2 - 2
Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt → Tests/RunCMake/FindPython/RequiredArtifactsCheck.cmake

@@ -1,6 +1,6 @@
-cmake_minimum_required(VERSION 3.15)
+enable_language(C)
 
-project(TestRequiredArtifacts.Check LANGUAGES C)
+include("${PYTHON_ARTIFACTS}")
 
 set (components)
 if (CHECK_INTERPRETER)

+ 329 - 0
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()

+ 3 - 5
Tests/FindPython/SOABI/CMakeLists.txt → Tests/RunCMake/FindPython/SOABI.cmake

@@ -1,6 +1,4 @@
-cmake_minimum_required(VERSION 3.15)
-
-project(TestSOABI LANGUAGES C)
+enable_language(C)
 
 if(CMake_TEST_FindPython3)
   find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
@@ -13,7 +11,7 @@ if(CMake_TEST_FindPython3)
   endif()
 
   if (Python3_Development_FOUND AND Python3_SOABI)
-    Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c)
+    Python3_add_library (spam3 MODULE WITH_SOABI spam.c)
     target_compile_definitions (spam3 PRIVATE PYTHON3)
 
     get_property (suffix TARGET spam3 PROPERTY SUFFIX)
@@ -30,7 +28,7 @@ if(CMake_TEST_FindPython2)
   endif()
 
   if (Python2_Development_FOUND AND Python2_SOABI)
-    Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c)
+    Python2_add_library (spam2 MODULE WITH_SOABI spam.c)
     target_compile_definitions (spam2 PRIVATE PYTHON2)
 
     get_property (suffix TARGET spam2 PROPERTY SUFFIX)

+ 5 - 1
Tests/FindPython/TEST_spam.c → Tests/RunCMake/FindPython/TEST_spam.c

@@ -1,4 +1,8 @@
-#define Py_LIMITED_API 3
+#if !defined(_WIN32)
+/* Disabled for Windows to avoid to link with the wrong library specified by
+ * #pragma */
+#  define Py_LIMITED_API 3
+#endif
 #include <Python.h>
 
 static PyObject* spam_system(PyObject* self, PyObject* args)

+ 2 - 3
Tests/FindPython/UnversionedNames/CMakeLists.txt → Tests/RunCMake/FindPython/UnversionedNames.cmake

@@ -1,6 +1,3 @@
-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)
@@ -24,6 +21,8 @@ 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)

+ 62 - 0
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)

+ 15 - 0
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()

+ 17 - 0
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()

+ 0 - 0
Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake → Tests/RunCMake/FindPython/VirtualEnvDefault.cmake


+ 0 - 0
Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake → Tests/RunCMake/FindPython/VirtualEnvOnly.cmake


+ 0 - 0
Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake → Tests/RunCMake/FindPython/VirtualEnvStandard.cmake


+ 2 - 2
Tests/FindPython/NumPy/arraytest.c → Tests/RunCMake/FindPython/arraytest.c

@@ -33,7 +33,7 @@ static PyObject* vecsq(PyObject* self, PyObject* args)
 }
 
 #if defined(PYTHON2)
-PyMODINIT_FUNC init_C_arraytest(void)
+PyMODINIT_FUNC initarraytest2(void)
 {
   (void)Py_InitModule("arraytest2", arraytestMethods);
   import_array();
@@ -49,7 +49,7 @@ static struct PyModuleDef arraytestmodule = {
   arraytestMethods
 };
 
-PyMODINIT_FUNC PyInit_C_arraytest(void)
+PyMODINIT_FUNC PyInit_arraytest3(void)
 {
   PyObject* po = PyModule_Create(&arraytestmodule);
   import_array();

+ 0 - 0
Tests/FindPython/display_time.c → Tests/RunCMake/FindPython/display_time.c


+ 0 - 0
Tests/FindPython/display_time.h → Tests/RunCMake/FindPython/display_time.h


+ 0 - 0
Tests/FindPython/main.c → Tests/RunCMake/FindPython/main.c


+ 5 - 1
Tests/FindPython/spam.c → Tests/RunCMake/FindPython/spam.c

@@ -1,4 +1,8 @@
-#define Py_LIMITED_API 3
+#if !defined(_WIN32)
+/* Disabled for Windows to avoid to link with the wrong library specified by
+ * #pragma */
+#  define Py_LIMITED_API 3
+#endif
 #include <Python.h>
 
 static PyObject* spam_system(PyObject* self, PyObject* args)

+ 0 - 0
Tests/FindPython/DifferentComponents/subdir/CMakeLists.txt → Tests/RunCMake/FindPython/subdir/CMakeLists.txt