-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
executable file
·331 lines (306 loc) · 9.45 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
cmake_minimum_required(VERSION 2.8.12)
project(CLSmith)
include(CheckIncludeFile)
set(CLSmith_PACKAGE "CLSmith")
set(CLSmith_PACKAGE_BUGREPORT "[email protected]")
set(CLSmith_PACKAGE_NAME "CLSmith")
set(CLSmith_PACKAGE_STRING "CLSmith x.y.z")
set(CLSmith_PACKAGE_TARNAME "CLSmith")
set(CLSmith_PACKAGE_URL "http://multicore.doc.ic.ac.uk/tools/CLsmith/index.php")
set(CLSmith_PACKAGE_VERSION "x.y.z")
set(CLSmith_VERSION "x.y.z")
execute_process(COMMAND "git" "show" "-s" "--format=%h" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE CLSmith_GIT_HASH)
string(STRIP "${CLSmith_GIT_HASH}" CLSmith_GIT_HASH)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to RelWithDebInfo")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-long-long -Wall -std=c++11")
endif()
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
add_definitions(-DGIT_VERSION=\"${CLSmith_GIT_HASH}\")
add_definitions(-DTARGET_CPU_${CMAKE_SYSTEM_PROCESSOR}=1)
add_definitions(-DPACKAGE_NAME=\"${CLSmith_PACKAGE_NAME}\")
add_definitions(-DPACKAGE_TARNAME=\"${CLSmith_PACKAGE_TARNAME}\")
add_definitions(-DPACKAGE_VERSION=\"${CLSmith_PACKAGE_VERSION}\")
add_definitions(-DPACKAGE_STRING=\"${CLSmith_PACKAGE_STRING}\")
add_definitions(-DPACKAGE_BUGREPORT=\"${CLSmith_PACKAGE_BUGREPORT}\")
add_definitions(-DPACKAGE_URL=\"${CLSmith_PACKAGE_URL}\")
add_definitions(-DPACKAGE=\"${CLSmith_PACKAGE}\")
add_definitions(-DVERSION=\"${CLSmith_VERSION}\")
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(WIN32)
set(CLSmith_WINDOWS_SOURCES
runtime/windows/rand48.h
runtime/windows/_rand48.c
runtime/windows/lrand48.c
runtime/windows/srand48.c
)
endif()
include_directories(src)
add_executable(CLSmith
#CSmith files
${CLSmith_WINDOWS_SOURCES}
src/AbsExtension.cpp
src/AbsExtension.h
src/AbsProgramGenerator.cpp
src/AbsProgramGenerator.h
src/AbsRndNumGenerator.cpp
src/AbsRndNumGenerator.h
src/ArrayVariable.cpp
src/ArrayVariable.h
src/Block.cpp
src/Block.h
src/Bookkeeper.cpp
src/Bookkeeper.h
src/CFGEdge.cpp
src/CFGEdge.h
src/CGContext.cpp
src/CGContext.h
src/CGOptions.cpp
src/CGOptions.h
src/CVQualifiers.cpp
src/CVQualifiers.h
src/Common.h
src/CommonMacros.h
src/CompatibleChecker.cpp
src/CompatibleChecker.h
src/Constant.cpp
src/Constant.h
src/CoverageTestExtension.cpp
src/CoverageTestExtension.h
src/CrestExtension.cpp
src/CrestExtension.h
src/DFSOutputMgr.cpp
src/DFSOutputMgr.h
src/DFSProgramGenerator.cpp
src/DFSProgramGenerator.h
src/DFSRndNumGenerator.cpp
src/DFSRndNumGenerator.h
src/DefaultOutputMgr.cpp
src/DefaultOutputMgr.h
src/DefaultProgramGenerator.cpp
src/DefaultProgramGenerator.h
src/DefaultRndNumGenerator.cpp
src/DefaultRndNumGenerator.h
src/DeltaMonitor.cpp
src/DeltaMonitor.h
src/DepthSpec.cpp
src/DepthSpec.h
src/Effect.cpp
src/Effect.h
src/Enumerator.h
src/Error.cpp
src/Error.h
src/Expression.cpp
src/Expression.h
src/ExpressionAssign.cpp
src/ExpressionAssign.h
src/ExpressionComma.cpp
src/ExpressionComma.h
src/ExpressionFuncall.cpp
src/ExpressionFuncall.h
src/ExpressionVariable.cpp
src/ExpressionVariable.h
src/ExtensionMgr.cpp
src/ExtensionMgr.h
src/ExtensionValue.cpp
src/ExtensionValue.h
src/Fact.cpp
src/Fact.h
src/FactMgr.cpp
src/FactMgr.h
src/FactPointTo.cpp
src/FactPointTo.h
src/FactUnion.cpp
src/FactUnion.h
src/Filter.cpp
src/Filter.h
src/Finalization.cpp
src/Finalization.h
src/Function.cpp
src/Function.h
src/FunctionInvocation.cpp
src/FunctionInvocation.h
src/FunctionInvocationBinary.cpp
src/FunctionInvocationBinary.h
src/FunctionInvocationUnary.cpp
src/FunctionInvocationUnary.h
src/FunctionInvocationUser.cpp
src/FunctionInvocationUser.h
src/KleeExtension.cpp
src/KleeExtension.h
src/Lhs.cpp
src/Lhs.h
src/LinearSequence.cpp
src/LinearSequence.h
src/MspFilters.cpp
src/MspFilters.h
src/OutputMgr.cpp
src/OutputMgr.h
src/PartialExpander.cpp
src/PartialExpander.h
src/Probabilities.cpp
src/Probabilities.h
src/ProbabilityTable.h
src/RandomNumber.cpp
src/RandomNumber.h
#src/RandomProgramGenerator.cpp
src/Reducer.cpp
src/Reducer.h
src/ReducerOutputMgr.cpp
src/ReducerOutputMgr.h
src/SafeOpFlags.cpp
src/SafeOpFlags.h
src/Sequence.cpp
src/Sequence.h
src/SequenceFactory.cpp
src/SequenceFactory.h
src/SequenceLineParser.h
src/SimpleDeltaRndNumGenerator.cpp
src/SimpleDeltaRndNumGenerator.h
src/SimpleDeltaSequence.cpp
src/SimpleDeltaSequence.h
src/SplatExtension.cpp
src/SplatExtension.h
src/Statement.cpp
src/Statement.h
src/StatementArrayOp.cpp
src/StatementArrayOp.h
src/StatementAssign.cpp
src/StatementAssign.h
src/StatementBreak.cpp
src/StatementBreak.h
src/StatementContinue.cpp
src/StatementContinue.h
src/StatementExpr.cpp
src/StatementExpr.h
src/StatementFor.cpp
src/StatementFor.h
src/StatementGoto.cpp
src/StatementGoto.h
src/StatementIf.cpp
src/StatementIf.h
src/StatementReturn.cpp
src/StatementReturn.h
src/StringUtils.cpp
src/StringUtils.h
src/Type.cpp
src/Type.h
src/Variable.cpp
src/Variable.h
src/VariableSelector.cpp
src/VariableSelector.h
src/VectorFilter.cpp
src/VectorFilter.h
src/platform.cpp
src/platform.h
src/random.cpp
src/random.h
src/util.cpp
src/util.h
#CLSmith files
src/CLSmith/CLOutputMgr.cpp
src/CLSmith/CLOutputMgr.h
src/CLSmith/CLProgramGenerator.cpp
src/CLSmith/CLProgramGenerator.h
src/CLSmith/Globals.cpp
src/CLSmith/Globals.h
src/CLSmith/CLRandomProgramGenerator.cpp
src/CLSmith/Walker.cpp
src/CLSmith/Walker.h
src/CLSmith/Divergence.cpp
src/CLSmith/Divergence.h
src/CLSmith/CLExpression.cpp
src/CLSmith/CLExpression.h
src/CLSmith/CLStatement.cpp
src/CLSmith/CLStatement.h
src/CLSmith/CLVariable.cpp
src/CLSmith/CLVariable.h
src/CLSmith/StatementBarrier.cpp
src/CLSmith/StatementBarrier.h
src/CLSmith/MemoryBuffer.cpp
src/CLSmith/MemoryBuffer.h
src/CLSmith/Vector.cpp
src/CLSmith/Vector.h
src/CLSmith/CLOptions.cpp
src/CLSmith/CLOptions.h
src/CLSmith/ExpressionVector.cpp
src/CLSmith/ExpressionVector.h
src/CLSmith/ExpressionAtomic.cpp
src/CLSmith/ExpressionAtomic.h
src/CLSmith/StatementEMI.cpp
src/CLSmith/StatementEMI.h
src/CLSmith/StatementAtomicResult.cpp
src/CLSmith/StatementAtomicResult.h
src/CLSmith/FunctionInvocationBuiltIn.cpp
src/CLSmith/FunctionInvocationBuiltIn.h
src/CLSmith/ExpressionID.cpp
src/CLSmith/ExpressionID.h
src/CLSmith/StatementComm.cpp
src/CLSmith/StatementComm.h
src/CLSmith/StatementAtomicReduction.cpp
src/CLSmith/StatementAtomicReduction.h
src/CLSmith/StatementMessage.cpp
src/CLSmith/StatementMessage.h
)
find_program(M4_EXECUTABLE m4 DOC "The M4 macro processor")
if(M4_EXECUTABLE)
set(SAFE_MATH_HEADERS
${CMAKE_BINARY_DIR}/safe_math_macros.h
${CMAKE_BINARY_DIR}/cl_safe_math_macros.h
)
add_custom_target(SAFE_MATH_HEADERS ALL
DEPENDS ${SAFE_MATH_HEADERS}
)
add_custom_command(
OUTPUT safe_math_macros.h
COMMAND ${M4_EXECUTABLE} ${CMAKE_SOURCE_DIR}/runtime/safe_math_macros.m4 > safe_math_macros.h
DEPENDS ${CMAKE_SOURCE_DIR}/runtime/safe_math_macros.m4
VERBATIM
)
add_custom_command(
OUTPUT cl_safe_math_macros.h
COMMAND ${M4_EXECUTABLE} ${CMAKE_SOURCE_DIR}/runtime/cl_safe_math_macros.m4 > cl_safe_math_macros.h
DEPENDS ${CMAKE_SOURCE_DIR}/runtime/cl_safe_math_macros.m4
VERBATIM
)
install(TARGETS CLSmith
RUNTIME DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install(FILES ${SAFE_MATH_HEADERS}
DESTINATION include/CLSmith
)
else()
message(WARNING "Cannot build the safe math runtime header files because m4 was not found")
endif()
install(FILES ${CMAKE_SOURCE_DIR}/runtime/CLSmith.h
DESTINATION include/CLSmith
)
find_package(OpenCL)
if(OpenCL_FOUND)
include_directories(${OpenCL_INCLUDE_DIRS})
add_executable(cl_launcher
src/CLSmith/cl_launcher.c
)
target_link_libraries(cl_launcher ${OpenCL_LIBRARIES})
install(TARGETS cl_launcher
RUNTIME DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
else()
message(WARNING "Cannot build cl_launcher because OpenCL was not found")
endif()