forked from bloomberg/clangmetatool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
110 lines (96 loc) · 2.98 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
cmake_minimum_required(VERSION 3.6)
project(clangmetatool C CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Clang REQUIRED)
find_package(LLVM REQUIRED)
# Install in the clang install directory. Also, use relative paths when
# installing the module. This way the installation will be relocatable.
set(CMAKE_INSTALL_PREFIX ${CLANG_INSTALL_PREFIX})
file(RELATIVE_PATH LLVM_INCLUDE_RELATIVE_DIR ${CMAKE_INSTALL_PREFIX}
${LLVM_INCLUDE_DIR})
file(RELATIVE_PATH LLVM_LIBRARY_RELATIVE_DIR ${CMAKE_INSTALL_PREFIX}
${LLVM_LIBRARY_DIR})
file(RELATIVE_PATH CLANG_CMAKE_RELATIVE_DIR ${CMAKE_INSTALL_PREFIX}
${CLANG_CMAKE_DIR})
add_library(
clangmetatool
src/include_graph_dependencies.cpp
src/source_util.cpp
src/tool_application_support.cpp
src/collectors/definitions.cpp
src/collectors/find_calls.cpp
src/collectors/find_cxx_member_calls.cpp
src/collectors/find_functions.cpp
src/collectors/include_graph/find_decl_match_callback.cpp
src/collectors/include_graph/find_decl_ref_match_callback.cpp
src/collectors/include_graph/find_type_match_callback.cpp
src/collectors/include_graph/include_finder.cpp
src/collectors/include_graph/include_graph.cpp
src/collectors/include_graph/include_graph_util.cpp
src/collectors/member_method_decls.cpp
src/collectors/references.cpp
src/collectors/variable_refs.cpp
src/propagation/constant_cstring_propagator.cpp
src/propagation/constant_integer_propagator.cpp
src/propagation/strongly_connected_blocks.cpp
src/propagation/types/value_context_ordering.cpp
src/propagation/util/get_stmt_from_cfg_element.cpp
)
# Use the same flags that LLVM used to compile
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
llvm_update_compile_flags(clangmetatool)
target_compile_definitions(
clangmetatool
PRIVATE
-DCLANG_INSTALL_LOCATION="${LLVM_TOOLS_BINARY_DIR}/clang"
)
target_include_directories(
clangmetatool
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${LLVM_INCLUDE_RELATIVE_DIR}>
)
target_include_directories(
clangmetatool
SYSTEM PRIVATE
${CLANG_INCLUDE_DIRS}
)
target_link_libraries(
clangmetatool
clangTooling
)
install(
TARGETS clangmetatool EXPORT clangmetatool
LIBRARY DESTINATION ${LLVM_LIBRARY_RELATIVE_DIR}
ARCHIVE DESTINATION ${LLVM_LIBRARY_RELATIVE_DIR}
PUBLIC_HEADER DESTINATION ${LLVM_INCLUDE_RELATIVE_DIR}
)
install(
DIRECTORY include/
DESTINATION ${LLVM_INCLUDE_RELATIVE_DIR}
)
install(
EXPORT clangmetatool
DESTINATION ${CLANG_CMAKE_RELATIVE_DIR}
)
install(
FILES
cmake/clangmetatool-find-clang-include-dir.pl
DESTINATION ${CLANG_CMAKE_RELATIVE_DIR}
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
install(
FILES
cmake/clangmetatool-config.cmake
DESTINATION ${CLANG_CMAKE_RELATIVE_DIR}
)
include(CTest)
if (BUILD_TESTING)
enable_testing()
add_subdirectory(t)
endif()