blob: 51895eff8672ce17070478ee75d5b7d404f21e0b (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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)
|