Debian Codegraph @

clang_delta/CMakeLists.txt

raw
1 ## -*- mode: CMake -*-
2 ##
3 ## Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 The University of Utah
4 ## All rights reserved.
5 ##
6 ## This file is distributed under the University of Illinois Open Source
7 ## License. See the file COPYING for details.
8
9 ###############################################################################
10
11 cmake_minimum_required(VERSION 2.8.12)
12 project(clang_delta)
13
14 ###############################################################################
15
16 # find_package(LLVM) is done by the topmost "CMakeLists.txt" file.
17 # find_package(Clang) is done by the topmost "CMakeLists.txt" file.
18
19 # Generate file "git_version.cpp".
20 #
21 configure_file("git_version.cpp.in" "git_version.cpp" @ONLY)
22
23 # set values for replacing variables in lit.site.cfg.in
24 #
25 set(LLVM_BINDIR ${LLVM_TOOLS_BINARY_DIR})
26 set(abs_builddir ${CMAKE_CURRENT_BINARY_DIR})
27 set(clang_delta_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
28
29 # Generate file "lit.site.cfg".
30 #
31 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
32 ${CMAKE_CURRENT_BINARY_DIR}/tests/lit.site.cfg @ONLY)
33
34 # Generate file "remove_lit_checks.pl", which is necessary for removing
35 # "lit-functioning" lines such as "CHECK:" and "RUN:" from test output.
36 #
37 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/remove_lit_checks.in
38 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/remove_lit_checks @ONLY)
39 file(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/remove_lit_checks
40 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/tests
41 FILE_PERMISSIONS
42 OWNER_READ OWNER_WRITE OWNER_EXECUTE
43 GROUP_READ GROUP_EXECUTE
44 WORLD_READ WORLD_EXECUTE)
45
46
47 # Add flags for compiling against LLVM.
48 #
49 add_definitions(${LLVM_DEFINITIONS})
50 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
51 $<$<CONFIG:Release>:NDEBUG>)
52 # include_directories(${PROJECT_BINARY_DIR}) --- if we generated .h files here
53 include_directories(${CMAKE_BINARY_DIR})
54 include_directories(${PROJECT_SOURCE_DIR}) # needed for gen'ed .cpp files
55 include_directories(${LLVM_INCLUDE_DIRS})
56 include_directories(${CLANG_INCLUDE_DIRS}) # only works for LLVM post-4.0
57
58 link_directories(${LLVM_LIBRARY_DIRS})
59
60 # ENE: Note that LLVM_LIBS is unused.
61 #
62 # The CLANG_LIBS defined below depend on various LLVM libraries. When we do
63 # `target_link_libraries(clang_delta ${CLANG_LIBS})`, CMake's automatic library
64 # dependency tracking adds ("is expected to add") the necessary LLVM libraries
65 # and other libraries to the link set without us doing anything special.
66 #
67 # There are reports that this automatic tracking does not always work. If this
68 # is the case for you, you can try adding LLVM_LIBS to the invocation of
69 # `target_link_libraries()` later in this file. There are reports that
70 # sometimes this doesn't solve the problem, so caveat emptor.
71 #
72 # There are reports that including LLVM_LIBS in `target_link_libraries()`, when
73 # it is not needed, can cause dynamic link errors when `clang_delta` is run
74 # (multiply defined symbols). This is another reason why we don't include
75 # LLVM_LIBS in the `target_link_libraries()` call by default.
76 #
77 llvm_map_components_to_libnames(LLVM_LIBS
78 coverage
79 irreader
80 mcparser
81 objcarcopts
82 option
83 passes
84 profiledata
85 support
86 )
87
88 if (${LLVM_LINK_LLVM_DYLIB})
89 set(CLANG_LIBS
90 clang-cpp
91 LLVM
92 )
93 else()
94 set(CLANG_LIBS
95 clangAST
96 clangBasic
97 clangFrontend
98 clangParse
99 clangLex
100 clangRewrite
101 )
102 endif()
103
104 add_executable(clang_delta
105 ${CMAKE_BINARY_DIR}/config.h
106 AggregateToScalar.cpp
107 AggregateToScalar.h
108 BinOpSimplification.cpp
109 BinOpSimplification.h
110 CallExprToValue.cpp
111 CallExprToValue.h
112 ClangDelta.cpp
113 ClassTemplateToClass.cpp
114 ClassTemplateToClass.h
115 CombineGlobalVarDecl.cpp
116 CombineGlobalVarDecl.h
117 CombineLocalVarDecl.cpp
118 CombineLocalVarDecl.h
119 CommonParameterRewriteVisitor.h
120 CommonRenameClassRewriteVisitor.h
121 CommonStatementVisitor.h
122 CommonTemplateArgumentVisitor.h
123 CopyPropagation.cpp
124 CopyPropagation.h
125 EmptyStructToInt.cpp
126 EmptyStructToInt.h
127 ExpressionDetector.cpp
128 ExpressionDetector.h
129 InstantiateTemplateParam.cpp
130 InstantiateTemplateParam.h
131 InstantiateTemplateTypeParamToInt.cpp
132 InstantiateTemplateTypeParamToInt.h
133 LiftAssignmentExpr.cpp
134 LiftAssignmentExpr.h
135 LocalToGlobal.cpp
136 LocalToGlobal.h
137 MoveFunctionBody.cpp
138 MoveFunctionBody.h
139 MoveGlobalVar.cpp
140 MoveGlobalVar.h
141 ParamToGlobal.cpp
142 ParamToGlobal.h
143 ParamToLocal.cpp
144 ParamToLocal.h
145 ReduceArrayDim.cpp
146 ReduceArrayDim.h
147 ReduceArraySize.cpp
148 ReduceArraySize.h
149 ReduceClassTemplateParameter.cpp
150 ReduceClassTemplateParameter.h
151 ReducePointerLevel.cpp
152 ReducePointerLevel.h
153 ReducePointerPairs.cpp
154 ReducePointerPairs.h
155 RemoveAddrTaken.cpp
156 RemoveAddrTaken.h
157 RemoveArray.cpp
158 RemoveArray.h
159 RemoveBaseClass.cpp
160 RemoveBaseClass.h
161 RemoveCtorInitializer.cpp
162 RemoveCtorInitializer.h
163 RemoveEnumMemberValue.cpp
164 RemoveEnumMemberValue.h
165 RemoveNamespace.cpp
166 RemoveNamespace.h
167 RemoveNestedFunction.cpp
168 RemoveNestedFunction.h
169 RemovePointer.cpp
170 RemovePointer.h
171 RemoveTrivialBaseTemplate.cpp
172 RemoveTrivialBaseTemplate.h
173 RemoveUnresolvedBase.cpp
174 RemoveUnresolvedBase.h
175 RemoveUnusedEnumMember.cpp
176 RemoveUnusedEnumMember.h
177 RemoveUnusedFunction.cpp
178 RemoveUnusedFunction.h
179 RemoveUnusedOuterClass.cpp
180 RemoveUnusedOuterClass.h
181 RemoveUnusedStructField.cpp
182 RemoveUnusedStructField.h
183 RemoveUnusedVar.cpp
184 RemoveUnusedVar.h
185 RenameCXXMethod.cpp
186 RenameCXXMethod.h
187 RenameClass.cpp
188 RenameClass.h
189 RenameFun.cpp
190 RenameFun.h
191 RenameParam.cpp
192 RenameParam.h
193 RenameVar.cpp
194 RenameVar.h
195 ReplaceArrayAccessWithIndex.cpp
196 ReplaceArrayAccessWithIndex.h
197 ReplaceArrayIndexVar.cpp
198 ReplaceArrayIndexVar.h
199 ReplaceCallExpr.cpp
200 ReplaceCallExpr.h
201 ReplaceClassWithBaseTemplateSpec.cpp
202 ReplaceClassWithBaseTemplateSpec.h
203 ReplaceDependentName.cpp
204 ReplaceDependentName.h
205 ReplaceDependentTypedef.cpp
206 ReplaceDependentTypedef.h
207 ReplaceDerivedClass.cpp
208 ReplaceDerivedClass.h
209 ReplaceFunctionDefWithDecl.cpp
210 ReplaceFunctionDefWithDecl.h
211 ReplaceOneLevelTypedefType.cpp
212 ReplaceOneLevelTypedefType.h
213 ReplaceSimpleTypedef.cpp
214 ReplaceSimpleTypedef.h
215 ReplaceUndefinedFunction.cpp
216 ReplaceUndefinedFunction.h
217 ReturnVoid.cpp
218 ReturnVoid.h
219 RewriteUtils.cpp
220 RewriteUtils.h
221 SimpleInliner.cpp
222 SimpleInliner.h
223 SimplifyCallExpr.cpp
224 SimplifyCallExpr.h
225 SimplifyCommaExpr.cpp
226 SimplifyCommaExpr.h
227 SimplifyDependentTypedef.cpp
228 SimplifyDependentTypedef.h
229 SimplifyIf.cpp
230 SimplifyIf.h
231 SimplifyNestedClass.cpp
232 SimplifyNestedClass.h
233 SimplifyRecursiveTemplateInstantiation.cpp
234 SimplifyRecursiveTemplateInstantiation.h
235 SimplifyStruct.cpp
236 SimplifyStruct.h
237 SimplifyStructUnionDecl.cpp
238 SimplifyStructUnionDecl.h
239 TemplateArgToInt.cpp
240 TemplateArgToInt.h
241 TemplateNonTypeArgToInt.cpp
242 TemplateNonTypeArgToInt.h
243 Transformation.cpp
244 Transformation.h
245 TransformationManager.cpp
246 TransformationManager.h
247 UnifyFunctionDecl.cpp
248 UnifyFunctionDecl.h
249 UnionToStruct.cpp
250 UnionToStruct.h
251 VectorToArray.cpp
252 VectorToArray.h
253 ${PROJECT_BINARY_DIR}/git_version.cpp
254 git_version.h
255 )
256
257 # ENE: See comment above about why LLVM_LIBS is not included in this call.
258 target_link_libraries(clang_delta ${CLANG_LIBS})
259
260 # For cases in which the LLVM libraries are shared libraries, remember where
261 # the shared libraries are.
262 set_target_properties(clang_delta
263 PROPERTIES
264 BUILD_WITH_INSTALL_RPATH "yes"
265 INSTALL_RPATH "${LLVM_LIBRARY_DIRS}"
266 )
267
268 # On Windows, we also need to link with "Version.dll" system library.
269 # See <https://github.com/csmith-project/creduce/pull/126>.
270 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
271 target_link_libraries(clang_delta Version)
272 endif()
273
274 install(TARGETS clang_delta
275 RUNTIME DESTINATION "libexec"
276 )
277 # If binary is read-only, then installing may fail with an error:
278 # CMake Error at cmake_install.cmake:45 (FILE):
279 # file RPATH_REMOVE could not remove RPATH from file:
280 # /disk2/randtest/install/libexec/clang_delta
281 # Error opening file for update.
282 #
283 # Do I want RPATH at all? We can turn it off, by setting CMAKE_SKIP_RPATH
284 # https://cmake.org/cmake/help/v2.8.8/cmake.html#variable%3aCMAKE_SKIP_RPATH
285 # See also the stuff about RPATH for `set_target_properties', which I don't
286 # really grok:
287 # https://cmake.org/cmake/help/v2.8.8/cmake.html#command:set_target_properties
288 #
289 # PERMISSIONS
290 # OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
291
292 #####
293
294 # Custom target for running clang_delta tests
295 #
296 add_custom_target(check-clang-delta
297 COMMAND ${LLVM_TOOLS_BINARY_DIR}/llvm-lit
298 -sv ${CMAKE_CURRENT_BINARY_DIR}/tests
299 DEPENDS clang_delta)
300
301 ###############################################################################
302
303 ## End of file.