-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
161 lines (135 loc) · 4.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
find_package(LLVM CONFIG HINTS "${LLVM_DIR}")
if(NOT LLVM_FOUND)
message(STATUS "LLVM not found at: ${LLVM_DIR}.")
find_package(LLVM REQUIRED CONFIG)
endif()
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
function(cutests_find_llvm_progs target names)
cmake_parse_arguments(ARG "ABORT_IF_MISSING;SHOW_VAR" "DEFAULT_EXE" "HINTS" ${ARGN})
set(TARGET_TMP ${target})
find_program(
${target}
NAMES ${names}
PATHS ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH
)
if(NOT ${target})
find_program(
${target}
NAMES ${names}
HINTS ${ARG_HINTS}
)
endif()
if(NOT ${target})
set(target_missing_message "")
if(ARG_DEFAULT_EXE)
unset(${target} CACHE)
set(${target}
${ARG_DEFAULT_EXE}
CACHE
STRING
"Default value for ${TARGET_TMP}."
)
set(target_missing_message "Using default: ${ARG_DEFAULT_EXE}")
endif()
set(message_status STATUS)
if(ARG_ABORT_IF_MISSING AND NOT ARG_DEFAULT_EXE)
set(message_status SEND_ERROR)
endif()
message(${message_status}
"Did not find LLVM program " "${names}"
" in ${LLVM_TOOLS_BINARY_DIR}, in system path or hints " "\"${ARG_HINTS}\"" ". "
${target_missing_message}
)
endif()
if(ARG_SHOW_VAR)
mark_as_advanced(CLEAR ${target})
else()
mark_as_advanced(${target})
endif()
endfunction()
cutests_find_llvm_progs(CUTESTS_FILECHECK_EXEC "FileCheck-${LLVM_VERSION_MAJOR};FileCheck" ABORT_IF_MISSING)
if(LLVM_EXTERNAL_LIT)
cmake_path(GET LLVM_EXTERNAL_LIT PARENT_PATH LLVM_EXTERNAL_LIT_DIR)
endif()
cutests_find_llvm_progs(CUTESTS_LIT_EXEC
"llvm-lit;lit;lit.py"
HINTS ${LLVM_EXTERNAL_LIT_DIR} /usr/lib/llvm-${LLVM_VERSION_MAJOR} /usr/lib/llvm /usr/bin /usr/local/bin /opt/local/bin
ABORT_IF_MISSING
)
function(configure_cutests_lit_site_cfg input output)
set(LIT_SITE_CFG_IN_HEADER
"## Autogenerated for cutests from ${input}\n## Do not edit!"
)
set(CUTESTS_PROJECT_DIR ${PROJECT_SOURCE_DIR})
set(CUTESTS_BUILD_DIR ${CMAKE_BINARY_DIR})
set(CUTESTS_TEST_CUSAN_DIR ${CMAKE_BINARY_DIR}/testsuite-exec)
file(MAKE_DIRECTORY ${CUTESTS_TEST_CUSAN_DIR})
file(READ ${input} contents)
string(CONFIGURE "${contents}" contents @ONLY)
file(GENERATE
OUTPUT
${output}
CONTENT
"${contents}"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ
WORLD_READ
)
endfunction()
configure_cutests_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
function(cutests_add_lit_testsuite target comment)
cmake_parse_arguments(ARG "" "" "PARAMS;DEPENDS;ARGS" ${ARGN})
foreach(param ${ARG_PARAMS})
list(APPEND TEST_PARAMS --param ${param})
endforeach()
add_custom_target(${target}
COMMAND ${CUTESTS_LIT_EXEC} ${ARG_ARGS} ${TEST_PARAMS} ${ARG_UNPARSED_ARGUMENTS}
COMMENT "${comment}"
USES_TERMINAL
)
if (ARG_DEPENDS)
add_dependencies(${target} ${ARG_DEPENDS})
endif()
endfunction()
function(cutests_add_lit_target)
cmake_parse_arguments(ARG "" "" "SUITES" ${ARGN})
foreach(suite IN LISTS ARG_SUITES)
if("${suite}" STREQUAL "all")
set(SUITE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(TARGET_NAME check-cutests)
else()
set(SUITE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${suite})
set(TARGET_NAME check-cutests-${suite})
endif()
if(NOT EXISTS ${SUITE_PATH} AND NOT "${suite}" STREQUAL "staging")
message(WARNING "Could not find suitable lit test target at ${SUITE_PATH}")
continue()
endif()
cutests_add_lit_testsuite(${TARGET_NAME}
"Running the lit suite cutests"
${SUITE_PATH}
ARGS -v -j 1
PARAMS cutests_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
endforeach()
endfunction()
set(CUTESTS_SUITES
all
staging
cuda-to-mpi
mpi-to-cuda
cuda-only
)
cutests_add_lit_target(SUITES ${CUTESTS_SUITES})
add_test(
NAME cutests-lit-suite
COMMAND
${CUTESTS_LIT_EXEC} -j 1 --param
cutests_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
${CMAKE_CURRENT_SOURCE_DIR}
)