forked from KhronosGroup/SPIRV-LLVM-Translator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (125 loc) · 4.08 KB
/
CMakeLists.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
llvm_canonicalize_cmake_booleans(SPIRV_SKIP_CLANG_BUILD)
llvm_canonicalize_cmake_booleans(SPIRV_SKIP_DEBUG_INFO_TESTS)
llvm_canonicalize_cmake_booleans(LLVM_BUILD_SHARED_LIBS)
llvm_canonicalize_cmake_booleans(LLVM_SPIRV_BUILD_EXTERNAL)
# required by lit.site.cfg.py.in
get_target_property(LLVM_SPIRV_DIR llvm-spirv BINARY_DIR)
get_target_property(LLVM_SPIRV_LIB_DIR LLVMSPIRVLib BINARY_DIR)
set(LLVM_SPIRV_TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(SPIRV_TOOLS_FOUND AND NOT SPIRV-Tools-tools_FOUND)
# we found SPIRV-Tools via pkgconfig
find_program(SPIRV_TOOLS_SPIRV_AS NAMES spirv-as PATHS ${SPIRV_TOOLS_PREFIX}/bin)
if(SPIRV_TOOLS_SPIRV_AS)
set(SPIRV_TOOLS_SPIRV_AS_FOUND True)
endif()
find_program(SPIRV_TOOLS_SPIRV_DIS NAMES spirv-dis PATHS ${SPIRV_TOOLS_PREFIX}/bin)
if(SPIRV_TOOLS_SPIRV_DIS)
set(SPIRV_TOOLS_SPIRV_DIS_FOUND True)
endif()
find_program(SPIRV_TOOLS_SPIRV_LINK NAMES spirv-link PATHS ${SPIRV_TOOLS_PREFIX}/bin)
if(SPIRV_TOOLS_SPIRV_LINK)
set(SPIRV_TOOLS_SPIRV_LINK_FOUND True)
endif()
find_program(SPIRV_TOOLS_SPIRV_VAL NAMES spirv-val PATHS ${SPIRV_TOOLS_PREFIX}/bin)
if(SPIRV_TOOLS_SPIRV_VAL)
set(SPIRV_TOOLS_SPIRV_VAL_FOUND True)
endif()
set(SPIRV_TOOLS_BINDIR "${SPIRV_TOOLS_PREFIX}/bin")
if (LLVM_SPIRV_ENABLE_LIBSPIRV_DIS)
set(SPIRV_ENABLE_LIBSPIRV_DIS ON)
endif()
elseif(SPIRV-Tools-tools_FOUND)
# we found SPIRV-Tools via cmake targets
if(TARGET spirv-as)
set(SPIRV_TOOLS_SPIRV_AS_FOUND True)
endif()
if(TARGET spirv-dis)
set(SPIRV_TOOLS_SPIRV_DIS_FOUND True)
endif()
if(TARGET spirv-link)
set(SPIRV_TOOLS_SPIRV_LINK_FOUND True)
endif()
if(TARGET spirv-val)
set(SPIRV_TOOLS_SPIRV_VAL_FOUND True)
endif()
get_target_property(SPIRV_AS_PATH spirv-as IMPORTED_LOCATION_RELEASE)
if(NOT SPIRV_AS_PATH)
get_target_property(SPIRV_AS_PATH spirv-as IMPORTED_LOCATION_DEBUG)
endif()
if(SPIRV_AS_PATH)
cmake_path(GET SPIRV_AS_PATH PARENT_PATH SPIRV_AS_PATH)
endif()
set(SPIRV_TOOLS_BINDIR "${SPIRV_AS_PATH}")
endif()
if(NOT SPIRV_TOOLS_SPIRV_AS_FOUND)
message(WARNING "spirv-as not found! SPIR-V assembly tests will not be run.")
set(SPIRV_TOOLS_SPIRV_AS_FOUND False)
endif()
if(NOT SPIRV_TOOLS_SPIRV_DIS_FOUND)
message(WARNING "spirv-dis not found! SPIR-V disassembly tests will not be run.")
set(SPIRV_TOOLS_SPIRV_DIS_FOUND False)
endif()
if(NOT SPIRV_TOOLS_SPIRV_LINK_FOUND)
message(WARNING "spirv-link not found! SPIR-V test involving the linker will not be run.")
set(SPIRV_TOOLS_SPIRV_LINK_FOUND False)
endif()
if(NOT SPIRV_TOOLS_SPIRV_VAL_FOUND)
message(WARNING "spirv-val not found! SPIR-V generated for test suite will not be validated.")
set(SPIRV_TOOLS_SPIRV_VAL_FOUND False)
endif()
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)
if(NOT LLVM_SPIRV_BUILD_EXTERNAL)
set(LLVM_SPIRV_TEST_DEPS
FileCheck
count
llvm-as
llvm-config
llvm-dis
not
)
if(NOT SPIRV_SKIP_CLANG_BUILD)
list(APPEND LLVM_SPIRV_TEST_DEPS
clang
)
endif(NOT SPIRV_SKIP_CLANG_BUILD)
if(NOT SPIRV_SKIP_DEBUG_INFO_TESTS)
list(APPEND LLVM_SPIRV_TEST_DEPS
llc
llvm-dwarfdump
llvm-objdump
llvm-readelf
llvm-readobj
)
endif(NOT SPIRV_SKIP_DEBUG_INFO_TESTS)
if(LLVM_BUILD_SHARED_LIBS)
list(APPEND LLVM_SPIRV_TEST_DEPS
opt
)
endif()
endif(NOT LLVM_SPIRV_BUILD_EXTERNAL)
add_lit_testsuite(check-llvm-spirv "Running the LLVM-SPIRV regression tests"
${CMAKE_CURRENT_BINARY_DIR}
ARGS
--verbose
DEPENDS
${LLVM_SPIRV_TEST_DEPS}
llvm-spirv
)
# to enable a custom test target on cmake below 3.11
# starting with 3.11 "test" is only reserved if ENABLE_TESTING(ON)
if(LLVM_SPIRV_BUILD_EXTERNAL)
cmake_policy(PUSH)
if(POLICY CMP0037 AND ${CMAKE_VERSION} VERSION_LESS "3.11.0")
cmake_policy(SET CMP0037 OLD)
endif(POLICY CMP0037 AND ${CMAKE_VERSION} VERSION_LESS "3.11.0")
add_custom_target(test
DEPENDS
check-llvm-spirv
)
cmake_policy(POP)
endif(LLVM_SPIRV_BUILD_EXTERNAL)