forked from KhronosGroup/SPIRV-LLVM-Translator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (70 loc) · 2.05 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
include(FindPkgConfig)
llvm_canonicalize_cmake_booleans(SPIRV_SKIP_CLANG_BUILD)
llvm_canonicalize_cmake_booleans(SPIRV_SKIP_DEBUG_INFO_TESTS)
# required by lit.site.cfg.py.in
get_target_property(LLVM_SPIRV_DIR llvm-spirv BINARY_DIR)
set(LLVM_SPIRV_TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# find spirv-val
pkg_search_module(SPIRV_TOOLS SPIRV-Tools)
if(SPIRV_TOOLS_FOUND)
find_program(SPIRV_TOOLS_SPIRV_VAL NAMES spirv-val PATHS ${SPIRV_TOOLS_PREFIX}/bin)
if(SPIRV_TOOLS_SPIRV_VAL)
get_filename_component(SPIRV_TOOLS_BINDIR "${SPIRV_TOOLS_SPIRV_VAL}" DIRECTORY)
set(SPIRV_TOOLS_SPIRV_VAL_FOUND True)
endif()
endif()
if(NOT SPIRV_TOOLS_SPIRV_VAL)
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 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)
endif(NOT 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(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(BUILD_EXTERNAL)