summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-03-02 16:45:25 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-03-05 15:44:48 (GMT)
commite5b4c742385b7bcddb9b667cad37795b0aef3f32 (patch)
treee4f12be194969b1d0a66be736082929b763fc1a2 /Tests
parent07a7bc0e3fc370eaa5593cffcd07c0ea739cfc9c (diff)
downloadCMake-e5b4c742385b7bcddb9b667cad37795b0aef3f32.zip
CMake-e5b4c742385b7bcddb9b667cad37795b0aef3f32.tar.gz
CMake-e5b4c742385b7bcddb9b667cad37795b0aef3f32.tar.bz2
FindPython: Add possibility to control scope of artifacts.
Fixes: #20362
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindPython/ArtifactsInteractive/CMakeLists.txt24
-rw-r--r--Tests/FindPython/CMakeLists.txt29
-rw-r--r--Tests/FindPython/Python3/CMakeLists.txt6
3 files changed, 56 insertions, 3 deletions
diff --git a/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt
new file mode 100644
index 0000000..524be92
--- /dev/null
+++ b/Tests/FindPython/ArtifactsInteractive/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestArtifactsInteractive LANGUAGES C)
+
+set (components Interpreter Development)
+if (CMake_TEST_FindPython_NumPy)
+ list (APPEND components NumPy)
+endif()
+
+find_package(Python3 REQUIRED COMPONENTS ${components})
+
+if (Python3_ARTIFACTS_INTERACTIVE)
+ if (NOT DEFINED CACHE{Python3_EXECUTABLE}
+ OR NOT DEFINED CACHE{Python3_LIBRARY} OR NOT DEFINED CACHE{Python3_INCLUDE_DIR}
+ OR (CMake_TEST_FindPython_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}))
+ message (FATAL_ERROR "Python3_ARTIFACTS_INTERACTIVE=OFF Failed.")
+ endif()
+endif()
diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt
index bfec986..bd6e8ab 100644
--- a/Tests/FindPython/CMakeLists.txt
+++ b/Tests/FindPython/CMakeLists.txt
@@ -134,6 +134,35 @@ if(CMake_TEST_FindPython)
--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_FindPython_NumPy=${CMake_TEST_FindPython_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_FindPython_NumPy=${CMake_TEST_FindPython_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
diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt
index 6691a48..34ebd2c 100644
--- a/Tests/FindPython/Python3/CMakeLists.txt
+++ b/Tests/FindPython/Python3/CMakeLists.txt
@@ -15,14 +15,14 @@ if (NOT Python3_FOUND)
endif()
if(NOT TARGET Python3::Interpreter)
- message(SEND_ERROR "Python2::Interpreter not found")
+ message(SEND_ERROR "Python3::Interpreter not found")
endif()
if(NOT TARGET Python3::Python)
- message(SEND_ERROR "Python2::Python not found")
+ message(SEND_ERROR "Python3::Python not found")
endif()
if(NOT TARGET Python3::Module)
- message(SEND_ERROR "Python2::Module not found")
+ message(SEND_ERROR "Python3::Module not found")
endif()
Python3_add_library (spam3 MODULE ../spam.c)