summaryrefslogtreecommitdiffstats
path: root/Tests/FindPython
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-06-13 15:46:32 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2023-06-15 13:28:55 (GMT)
commit711d1da1255a028947d1117852caa8f33604bd81 (patch)
tree64d65a0b31f6afa50f56cec6923e8875360a2f72 /Tests/FindPython
parent883cbf41710ce3a4c4798f9ced93681ec87115cc (diff)
downloadCMake-711d1da1255a028947d1117852caa8f33604bd81.zip
CMake-711d1da1255a028947d1117852caa8f33604bd81.tar.gz
CMake-711d1da1255a028947d1117852caa8f33604bd81.tar.bz2
FindPython: add capability to select python version for the tests
Diffstat (limited to 'Tests/FindPython')
-rw-r--r--Tests/FindPython/ArtifactsInteractive/CMakeLists.txt6
-rw-r--r--Tests/FindPython/CMakeLists.txt419
-rw-r--r--Tests/FindPython/CustomFailureMessage/CMakeLists.txt2
-rw-r--r--Tests/FindPython/MultiplePackages/CMakeLists.txt52
-rw-r--r--Tests/FindPython/NumPy/CMakeLists.txt37
-rw-r--r--Tests/FindPython/NumPyOnly/CMakeLists.txt20
-rw-r--r--Tests/FindPython/RequiredArtifacts/CMakeLists.txt27
-rw-r--r--Tests/FindPython/SOABI/CMakeLists.txt51
-rw-r--r--Tests/FindPython/VirtualEnv/CMakeLists.txt26
-rw-r--r--Tests/FindPython/VirtualEnvConda/CMakeLists.txt26
10 files changed, 365 insertions, 301 deletions
diff --git a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt
index 99823a6..18f8fda 100644
--- a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt
+++ b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
project(TestArtifactsInteractive LANGUAGES C)
set (components Interpreter Development)
-if (CMake_TEST_FindPython_NumPy)
+if (CMake_TEST_FindPython3_NumPy)
list (APPEND components NumPy)
endif()
@@ -12,13 +12,13 @@ find_package(Python3 REQUIRED COMPONENTS ${components})
if (Python3_ARTIFACTS_INTERACTIVE)
if (NOT DEFINED CACHE{Python3_EXECUTABLE}
OR NOT DEFINED CACHE{Python3_LIBRARY} OR NOT DEFINED CACHE{Python3_INCLUDE_DIR}
- OR (CMake_TEST_FindPython_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR}))
+ OR (CMake_TEST_FindPython3_NumPy AND NOT DEFINED CACHE{Python3_NumPy_INCLUDE_DIR}))
message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=ON Failed.")
endif()
else()
if (DEFINED CACHE{Python3_EXECUTABLE}
OR DEFINED CACHE{Python3_LIBRARY} OR DEFINED CACHE{Python3_INCLUDE_DIR}
- OR (CMake_TEST_FindPython_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR}))
+ OR (CMake_TEST_FindPython3_NumPy AND DEFINED CACHE{Python3_NumPy_INCLUDE_DIR}))
message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=OFF Failed.")
endif()
endif()
diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt
index b6942c9..3e1993e 100644
--- a/Tests/FindPython/CMakeLists.txt
+++ b/Tests/FindPython/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(CMake_TEST_FindPython)
+if(CMake_TEST_FindPython2)
add_test(NAME FindPython.Python2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -44,6 +44,129 @@ if(CMake_TEST_FindPython)
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>
+ )
+endif()
+
+if(CMake_TEST_FindPython3)
add_test(NAME FindPython.Python3.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -89,46 +212,6 @@ if(CMake_TEST_FindPython)
set_tests_properties(FindPython.Python3Fail PROPERTIES
PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)")
- 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>
- )
- 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.Python.V3.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -150,30 +233,6 @@ if(CMake_TEST_FindPython)
--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.Python3.ExactVersion.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -198,28 +257,6 @@ if(CMake_TEST_FindPython)
-DPython3_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.Python.V3.ExactVersion.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -263,46 +300,6 @@ if(CMake_TEST_FindPython)
--build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3
-DPython3_FIND_STRATEGY=VERSION
)
- 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.Python.V3.VersionRange.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -324,17 +321,6 @@ if(CMake_TEST_FindPython)
-DPython_FIND_STRATEGY=VERSION
)
- 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>
- )
-
add_test(NAME FindPython.VirtualEnv COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -346,16 +332,6 @@ if(CMake_TEST_FindPython)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- 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>
- )
add_test(NAME FindPython.Python3Embedded COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -377,7 +353,7 @@ if(CMake_TEST_FindPython)
--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_SABIModule=${CMake_TEST_FindPython_SABIModule}"
+ "-DCMake_TEST_FindPython3_SABIModule=${CMake_TEST_FindPython3_SABIModule}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -391,7 +367,7 @@ if(CMake_TEST_FindPython)
--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_NumPy=${CMake_TEST_FindPython_NumPy}"
+ "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}"
"-DPython3_ARTIFACTS_INTERACTIVE=ON"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -405,7 +381,7 @@ if(CMake_TEST_FindPython)
--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_NumPy=${CMake_TEST_FindPython_NumPy}"
+ "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}"
"-DPython3_ARTIFACTS_INTERACTIVE=OFF"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -420,7 +396,7 @@ if(CMake_TEST_FindPython)
--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_NumPy=${CMake_TEST_FindPython_NumPy}"
+ "-DCMake_TEST_FindPython3_NumPy=${CMake_TEST_FindPython3_NumPy}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -437,6 +413,41 @@ if(CMake_TEST_FindPython)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+ 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}
+ )
+ 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>
@@ -466,20 +477,20 @@ if(CMake_TEST_FindPython)
)
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}
+ 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>
)
- endif()
endif()
-if(CMake_TEST_FindPython_SABIModule)
+
+if(CMake_TEST_FindPython2_SABIModule)
add_test(NAME FindPython.Python2.Development.SABIModule COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -492,7 +503,9 @@ if(CMake_TEST_FindPython_SABIModule)
)
set_tests_properties(FindPython.Python2.Development.SABIModule PROPERTIES
PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: .*Development\\.SABIModule")
+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.
@@ -508,7 +521,7 @@ if(CMake_TEST_FindPython_SABIModule)
)
endif()
-if(CMake_TEST_FindPython_NumPy)
+if(CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy)
add_test(NAME FindPython.NumPy COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -530,7 +543,7 @@ if(CMake_TEST_FindPython_NumPy)
)
endif()
-if(CMake_TEST_FindPython_Conda)
+if(CMake_TEST_FindPython3_Conda)
add_test(NAME FindPython.VirtualEnvConda COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -543,7 +556,7 @@ if(CMake_TEST_FindPython_Conda)
)
endif()
-if (CMake_TEST_FindPython AND CMake_TEST_FindPython_IronPython)
+if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython)
add_test(NAME FindPython.Implementation.CPython COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -566,7 +579,7 @@ if (CMake_TEST_FindPython AND CMake_TEST_FindPython_IronPython)
)
endif()
-if(CMake_TEST_FindPython_IronPython)
+if(CMake_TEST_FindPython2_IronPython)
add_test(NAME FindPython.IronPython2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -653,7 +666,7 @@ if(CMake_TEST_FindPython_IronPython)
)
endif()
-if(CMake_TEST_FindPython_PyPy)
+if(CMake_TEST_FindPython2_PyPy)
add_test(NAME FindPython.PyPy2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -675,85 +688,91 @@ if(CMake_TEST_FindPython_PyPy)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.PyPy3.LOCATION COMMAND
+ add_test(NAME FindPython.PyPy.V2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3"
- "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.LOCATION"
+ "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V2.LOCATION"
${build_generator_args}
- --build-project TestPyPy3
- --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
+ --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.PyPy3.VERSION COMMAND
+ add_test(NAME FindPython.PyPy.V2.VERSION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3"
- "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.VERSION"
+ "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V2.VERSION"
${build_generator_args}
- --build-project TestPyPy3
- --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
+ --build-project TestPyPy
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+endif()
- add_test(NAME FindPython.PyPy.LOCATION COMMAND
+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/PyPy"
- "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.LOCATION"
+ "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.LOCATION"
${build_generator_args}
- --build-project TestPyPy
- --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION
+ --build-project TestPyPy3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.PyPy.VERSION COMMAND
+ add_test(NAME FindPython.PyPy3.VERSION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy"
- "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.VERSION"
+ "${CMake_SOURCE_DIR}/Tests/FindPython/PyPy3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy3.VERSION"
${build_generator_args}
- --build-project TestPyPy
- --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION
+ --build-project TestPyPy3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.PyPy.V2.LOCATION COMMAND
+
+ 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.V2.LOCATION"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V3.LOCATION"
${build_generator_args}
--build-project TestPyPy
- --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=LOCATION
+ --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.V2.VERSION COMMAND
+ 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.V2.VERSION"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.V3.VERSION"
${build_generator_args}
--build-project TestPyPy
- --build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_FIND_STRATEGY=VERSION
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.PyPy.V3.LOCATION COMMAND
+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.V3.LOCATION"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.LOCATION"
${build_generator_args}
--build-project TestPyPy
- --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION
+ --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.PyPy.V3.VERSION COMMAND
+ 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.V3.VERSION"
+ "${CMake_BINARY_DIR}/Tests/FindPython/PyPy.VERSION"
${build_generator_args}
--build-project TestPyPy
- --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION
+ --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
endif()
diff --git a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt
index 283aeec..e0148f3 100644
--- a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt
+++ b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt
@@ -62,7 +62,7 @@ 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_FindPython_NumPy)
+if (CMake_TEST_FindPython3_NumPy)
add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
diff --git a/Tests/FindPython/MultiplePackages/CMakeLists.txt b/Tests/FindPython/MultiplePackages/CMakeLists.txt
index 4845035..352a2f6f 100644
--- a/Tests/FindPython/MultiplePackages/CMakeLists.txt
+++ b/Tests/FindPython/MultiplePackages/CMakeLists.txt
@@ -2,32 +2,44 @@ cmake_minimum_required(VERSION 3.5)
project(TestMultiplePackages C)
-find_package (Python2 REQUIRED COMPONENTS Interpreter Development)
-find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
-
-# Must find Python 3
find_package (Python REQUIRED)
-if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE)
- message (FATAL_ERROR
- "Python interpreters do not match:\n"
- " Python_EXECUTABLE='${Python_EXECUTABLE}'\n"
- " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n"
+if (CMake_TEST_FindPython2)
+ find_package (Python2 REQUIRED COMPONENTS Interpreter Development)
+
+ if (NOT CMake_TEST_FindPython3 AND NOT Python2_EXECUTABLE STREQUAL Python_EXECUTABLE)
+ message (FATAL_ERROR
+ "Python interpreters do not match:\n"
+ " Python_EXECUTABLE='${Python_EXECUTABLE}'\n"
+ " Python2_EXECUTABLE='${Python3_EXECUTABLE}'\n"
)
-endif()
+ endif()
+
+ Python2_add_library (spam2 MODULE ../spam.c)
+ target_compile_definitions (spam2 PRIVATE PYTHON2)
+ add_test (NAME python2_spam2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
-Python2_add_library (spam2 MODULE ../spam.c)
-target_compile_definitions (spam2 PRIVATE PYTHON2)
+endif()
+
+if (CMake_TEST_FindPython3)
+ find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
-Python3_add_library (spam3 MODULE ../spam.c)
-target_compile_definitions (spam3 PRIVATE PYTHON3)
+ if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE)
+ message (FATAL_ERROR
+ "Python interpreters do not match:\n"
+ " Python_EXECUTABLE='${Python_EXECUTABLE}'\n"
+ " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n"
+ )
+ endif()
+ Python3_add_library (spam3 MODULE ../spam.c)
+ target_compile_definitions (spam3 PRIVATE PYTHON3)
-add_test (NAME python2_spam2
- COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
- "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
+ add_test (NAME python3_spam3
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
-add_test (NAME python3_spam3
- COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
- "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
+endif()
diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt
index 9920336..336bb83 100644
--- a/Tests/FindPython/NumPy/CMakeLists.txt
+++ b/Tests/FindPython/NumPy/CMakeLists.txt
@@ -2,21 +2,30 @@ cmake_minimum_required(VERSION 3.5)
project(TestNumPy LANGUAGES C)
-find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy)
-find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
+if(CMake_TEST_FindPython2_NumPy)
-Python2_add_library (arraytest2 MODULE arraytest.c)
-target_compile_definitions (arraytest2 PRIVATE PYTHON2)
-target_link_libraries (arraytest2 PRIVATE Python2::NumPy)
+ find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy)
-Python3_add_library (arraytest3 MODULE arraytest.c)
-target_compile_definitions (arraytest3 PRIVATE PYTHON3)
-target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
+ 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_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
+ add_test (NAME python2_arraytest
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>"
+ "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
-add_test (NAME python3_arraytest
- COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>"
- "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
+endif()
+
+if(CMake_TEST_FindPython3_NumPy)
+
+ find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
+
+ Python3_add_library (arraytest3 MODULE arraytest.c)
+ target_compile_definitions (arraytest3 PRIVATE PYTHON3)
+ target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
+
+ add_test (NAME python3_arraytest
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>"
+ "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
+
+endif()
diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt
index 9aa1bcf..115cf2b 100644
--- a/Tests/FindPython/NumPyOnly/CMakeLists.txt
+++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt
@@ -2,13 +2,23 @@ cmake_minimum_required(VERSION 3.5)
project(TestNumPyOnly LANGUAGES C)
-find_package(Python2 REQUIRED COMPONENTS NumPy)
-find_package(Python3 REQUIRED COMPONENTS NumPy)
+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()
-Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c)
-target_compile_definitions (arraytest2 PRIVATE PYTHON2)
-target_link_libraries (arraytest2 PRIVATE Python2::NumPy)
+
+if(CMake_TEST_FindPython3_NumPy)
+
+find_package(Python3 REQUIRED COMPONENTS NumPy)
Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c)
target_compile_definitions (arraytest3 PRIVATE PYTHON3)
target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
+
+endif()
diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
index cb9d4d3..eec28a5 100644
--- a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
+++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
@@ -4,13 +4,20 @@ project(TestRequiredArtifacts LANGUAGES C)
include(CTest)
-find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
-if (NOT Python2_FOUND)
- message (FATAL_ERROR "Failed to find Python 2")
+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()
set(components Interpreter Development)
-if (CMake_TEST_FindPython_SABIModule AND WIN32)
+if (CMake_TEST_FindPython3_SABIModule AND WIN32)
list (APPEND components Development.SABIModule)
endif()
find_package(Python3 REQUIRED COMPONENTS ${components})
@@ -61,7 +68,7 @@ add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND
${build_generator_args}
--build-project TestRequiredArtifacts.Check
--build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON
- "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}"
+ "-DPython3_LIBRARY=${USER_LIBRARY}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -84,7 +91,7 @@ add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND
${build_generator_args}
--build-project TestRequiredArtifacts.Check
--build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INCLUDE=ON
- "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}"
+ "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -97,7 +104,7 @@ add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND
--build-project TestRequiredArtifacts.Check
--build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON
"-DPython3_EXECUTABLE=${Python3_EXECUTABLE}"
- "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}"
+ "-DPython3_LIBRARY=${USER_LIBRARY}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
@@ -110,11 +117,11 @@ add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND
--build-project TestRequiredArtifacts.Check
--build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON
"-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}"
- "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}"
+ "-DPython3_INCLUDE_DIR=${USER_INCLUDE_DIR}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
-if (CMake_TEST_FindPython_SABIModule AND WIN32)
+if (CMake_TEST_FindPython3_SABIModule AND WIN32)
add_test(NAME FindPython.RequiredArtifacts.SABILibrary.VALID COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -134,7 +141,7 @@ if (CMake_TEST_FindPython_SABIModule AND WIN32)
${build_generator_args}
--build-project TestRequiredArtifacts.Check
--build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_SABI_LIBRARY=ON
- "-DPython3_SABI_LIBRARY=${Python2_LIBRARY_RELEASE}"
+ "-DPython3_SABI_LIBRARY=${USER_LIBRARY}"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
endif()
diff --git a/Tests/FindPython/SOABI/CMakeLists.txt b/Tests/FindPython/SOABI/CMakeLists.txt
index 60399d3..6c0e9a9 100644
--- a/Tests/FindPython/SOABI/CMakeLists.txt
+++ b/Tests/FindPython/SOABI/CMakeLists.txt
@@ -2,37 +2,40 @@ cmake_minimum_required(VERSION 3.5)
project(TestSOABI LANGUAGES C)
-find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
-if (NOT Python3_FOUND)
- message (FATAL_ERROR "Failed to find Python 3")
-endif()
+if(CMake_TEST_FindPython3)
+ find_package(Python3 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
+ if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3")
+ endif()
-if(NOT DEFINED Python3_SOABI)
- message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
-endif()
+ if(NOT DEFINED Python3_SOABI)
+ message(FATAL_ERROR "Python3_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
+ endif()
-if (Python3_Development_FOUND AND Python3_SOABI)
- Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c)
- target_compile_definitions (spam3 PRIVATE PYTHON3)
+ if (Python3_Development_FOUND AND Python3_SOABI)
+ Python3_add_library (spam3 MODULE WITH_SOABI ../spam.c)
+ target_compile_definitions (spam3 PRIVATE PYTHON3)
- get_property (suffix TARGET spam3 PROPERTY SUFFIX)
- if (NOT suffix MATCHES "^.${Python3_SOABI}")
- message(FATAL_ERROR "Module suffix do not include Python3_SOABI")
+ get_property (suffix TARGET spam3 PROPERTY SUFFIX)
+ if (NOT suffix MATCHES "^.${Python3_SOABI}")
+ message(FATAL_ERROR "Module suffix do not include Python3_SOABI")
+ endif()
endif()
endif()
+if(CMake_TEST_FindPython2)
+ find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
+ if(NOT DEFINED Python2_SOABI)
+ message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
+ endif()
-find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
-if(NOT DEFINED Python2_SOABI)
- message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
-endif()
-
-if (Python2_Development_FOUND AND Python2_SOABI)
- Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c)
- target_compile_definitions (spam2 PRIVATE PYTHON2)
+ if (Python2_Development_FOUND AND Python2_SOABI)
+ Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c)
+ target_compile_definitions (spam2 PRIVATE PYTHON2)
- get_property (suffix TARGET spam2 PROPERTY SUFFIX)
- if (NOT suffix MATCHES "^.${Python2_SOABI}")
- message(FATAL_ERROR "Module suffix do not include Python2_SOABI")
+ get_property (suffix TARGET spam2 PROPERTY SUFFIX)
+ if (NOT suffix MATCHES "^.${Python2_SOABI}")
+ message(FATAL_ERROR "Module suffix do not include Python2_SOABI")
+ endif()
endif()
endif()
diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt
index e2e5bd2..ea742ea 100644
--- a/Tests/FindPython/VirtualEnv/CMakeLists.txt
+++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt
@@ -27,21 +27,23 @@ add_test(NAME FindPython3.VirtualEnvDefault
"${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
-P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake")
-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")
-
add_test(NAME FindPython3.VirtualEnvStandard
COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
--unset=CONDA_PREFIX
"VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
"${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
-P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake")
+
+if(CMake_TEST_FindPython2)
+ add_test(NAME FindPython3.VirtualEnvOnly
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ --unset=CONDA_PREFIX
+ "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake")
+ add_test(NAME FindPython3.UnsetVirtualEnvOnly
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ --unset=VIRTUAL_ENV
+ --unset=CONDA_PREFIX
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake")
+endif()
diff --git a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt
index 2f7c0db..3a64c31 100644
--- a/Tests/FindPython/VirtualEnvConda/CMakeLists.txt
+++ b/Tests/FindPython/VirtualEnvConda/CMakeLists.txt
@@ -26,21 +26,23 @@ add_test(NAME FindPython3.VirtualEnvDefaultConda
"${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
-P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake")
-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")
-
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()