summaryrefslogtreecommitdiff
path: root/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt
blob: b859ac57f32a1b49a3deb2bd41efb89917e40388 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 "Fail to use input variable Python3_EXECUTABLE")
endif()

if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
  message (FATAL_ERROR "Fail to use input variable Python3_LIBRARY")
endif()

if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
  message (FATAL_ERROR "Fail to use input variable Python3_INCLUDE_DIR")
endif()