Files
CMake/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt
Marc Chevrier 2549dc7c93 FindPython: Enable C language in tests that find the Development component
Since commit 5537ccd814 (FindPython: Tests optimizations, 2020-10-01)
some FindPython tests fail because the Development component cannot be
found without knowing `CMAKE_LIBRARY_ARCHITECTURE`.  Enable at least one
language in each of these test cases to get that value.  This is
consistent with use in practice because the Development component does
not make much sense without a language to compile sources anyway.

Fixes: #21277
2020-10-07 12:01:43 -04:00

42 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.1)
project(TestRequiredArtifacts.Check LANGUAGES C)
set (components)
if (CHECK_INTERPRETER)
set (required_interpreter "${Python3_EXECUTABLE}")
list (APPEND components Interpreter)
endif()
if (CHECK_LIBRARY OR CHECK_INCLUDE)
list (APPEND components Development)
if (CHECK_LIBRARY)
set (required_library "${Python3_LIBRARY}")
endif()
if (CHECK_INCLUDE)
set (required_include "${Python3_INCLUDE_DIR}")
endif()
endif()
find_package (Python3 COMPONENTS ${components})
if (PYTHON_IS_FOUND AND NOT Python3_FOUND)
message (FATAL_ERROR "Python3 unexpectedly not found")
endif()
if (NOT PYTHON_IS_FOUND AND Python3_FOUND)
message (FATAL_ERROR "Python3 unexpectedly found")
endif()
if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter)
message (FATAL_ERROR "Failed to use input variable Python3_EXECUTABLE")
endif()
if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
message (FATAL_ERROR "Failed to use input variable Python3_LIBRARY")
endif()
if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
message (FATAL_ERROR "Failed to use input variable Python3_INCLUDE_DIR")
endif()