-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
164 lines (129 loc) · 3.74 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
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(serialization-sanitizer)
find_program(ccache_binary ccache)
if (ccache_binary)
message(
STATUS
"Sanitizer: Found ccache binary: ${ccache_binary}; adding launch rule"
)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${ccache_binary}")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
set(CMAKE_CXX_STANDARD 14)
set(SERIALIZATION_SANITIZER_LIBRARY serialization-sanitizer)
set(SERIALIZATION_SANITIZER_LIBRARY_NS vt::lib::serialization-sanitizer)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/")
find_package(Clang REQUIRED)
# include fmt in the build
add_subdirectory(lib/fmt)
file(
GLOB
HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/sanitizer/*.h
)
file(
GLOB
SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/sanitizer/*.cc
)
add_executable(
sanitizer
${HEADER_FILES} ${SOURCE_FILES}
)
install(FILES ${HEADER_FILES} DESTINATION include)
target_compile_definitions(
sanitizer PUBLIC FMT_HEADER_ONLY=1 FMT_USE_USER_DEFINED_LITERALS=0
)
target_include_directories(
sanitizer PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt>
$<INSTALL_INTERFACE:include/fmt>
)
# target_include_directories(
# ${SERIALIZATION_SANITIZER_LIBRARY} PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
# $<INSTALL_INTERFACE:include>
# )
# target_include_directories(
# ${SERIALIZATION_SANITIZER_LIBRARY} PUBLIC ${CLANG_INCLUDE_DIRS}
# )
target_include_directories(
sanitizer PUBLIC ${CLANG_INCLUDE_DIRS}
)
set_target_properties(
sanitizer PROPERTIES COMPILE_FLAGS ${LLVM_CXXFLAGS}
)
set_target_properties(
sanitizer PROPERTIES LINK_FLAGS "${LLVM_LFLAGS} ${LLVM_SYSLIBS} ${LLVM_LIBS}"
)
target_link_libraries(
sanitizer PUBLIC ${CLANG_LIBS}
)
target_link_libraries(
sanitizer PUBLIC clangASTMatchers clangToolingCore clangLex clangParse clangSema
)
install(
TARGETS sanitizer
RUNTIME DESTINATION bin
)
install(
FILES scripts/parse-json.pl scripts/transform.sh scripts/apply-to-build.sh
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
DESTINATION scripts
)
###############################################################################
# Build for sanitizer runtime tests
###############################################################################
include(CTest)
enable_testing()
add_subdirectory(tests)
###############################################################################
# Build for sanitizer runtime that links with checkpoint
###############################################################################
file(
GLOB
RT_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/*.h
)
file(
GLOB
RT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/*.cc
)
add_library(
sanitizer_rt
SHARED
${RT_HEADER_FILES} ${RT_SOURCE_FILES}
)
add_library(vt::lib::sanitizer_rt ALIAS sanitizer_rt)
target_compile_definitions(
sanitizer_rt PUBLIC FMT_HEADER_ONLY=1 FMT_USE_USER_DEFINED_LITERALS=0
)
target_include_directories(
sanitizer_rt PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt>
$<INSTALL_INTERFACE:include/fmt>
)
install(
TARGETS sanitizer_rt
EXPORT sanitizer_rt
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
# install(
# EXPORT sanitizer_rt
# DESTINATION cmake
# FILE "checkpointTargets.cmake"
# NAMESPACE vt::lib::
# COMPONENT runtime
# )
# install(
# TARGETS sanitizer_rt
# RUNTIME DESTINATION bin
# )