This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
168 lines (138 loc) · 4.23 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
cmake_minimum_required(VERSION 3.1)
find_package(LLVM REQUIRED CONFIG)
add_definitions(${LLVM_DEFINITIONS})
add_library(InstantiateHarness MODULE
src/lib/instantiate-harness.cpp
src/lib/utils.cpp
src/lib/read-inputs.cpp
)
add_library(InstrumentMonitors MODULE
src/lib/instrument-monitors.cpp
)
add_library(GenerateSeeds MODULE
src/lib/generate-seeds.cpp
)
add_library(xxHash SHARED
xxHash/xxhash.c)
target_include_directories(InstrumentMonitors PUBLIC
${LLVM_INCLUDE_DIRS}
src/include
)
target_include_directories(InstantiateHarness PUBLIC
${LLVM_INCLUDE_DIRS}
src/include
)
target_include_directories(GenerateSeeds PUBLIC
${LLVM_INCLUDE_DIRS}
src/include
)
target_include_directories(xxHash PRIVATE
xxHash
)
link_directories(${LLVM_LIBRARY_DIRS})
find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-3.9 llvm-config PATHS ${LLVM_CONFIG} DOC "llvm-config")
find_program(MAKE make)
if (LLVM_CONFIG_EXECUTABLE STREQUAL "LLVM_CONFIG_EXECUTABLE-NOTFOUND")
message(FATAL_ERROR "llvm-config could not be found!")
endif()
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --cxxflags
OUTPUT_VARIABLE CMAKE_CXX_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE LLVM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
OUTPUT_VARIABLE LLVM_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_dependencies(InstrumentMonitors compile-afl)
add_custom_target(
compile-afl
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-llvm-pass.so
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-llvm-pass.so
COMMAND ${MAKE}
COMMAND ${MAKE} -C llvm_mode
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/afl
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-llvm-pass.so
PROPERTIES GENERATED TRUE
)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# Use C++11 to compile our pass (i.e., supply -std=c++11).
#target_compile_features(ExtractPass PRIVATE cxx_range_for cxx_auto_type)
# LLVM is (typically) built with no C++ RTTI. We need to match that;
# otherwise, we'll get linker errors about missing RTTI data.
#set_target_properties(ExtractPass PROPERTIES
# COMPILE_FLAGS "-fno-rtti"
#)
set_target_properties(InstrumentMonitors InstantiateHarness GenerateSeeds
PROPERTIES COMPILE_FLAGS "-fno-rtti"
)
# Get proper shared-library behavior (where symbols are not necessarily
# resolved when the shared library is linked) on OS X.
if(APPLE)
set_target_properties(InstrumentMonitors InstantiateHarness GenerateSeeds
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup"
)
endif(APPLE)
INSTALL(TARGETS InstrumentMonitors InstantiateHarness xxHash GenerateSeeds
LIBRARY DESTINATION lib/ct-fuzz
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/bin/ct-fuzz
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION bin
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-clang-fast
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION bin
RENAME ct-fuzz-afl-clang-fast
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-fuzz
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION bin
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-clang-fast++
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION bin
RENAME ct-fuzz-afl-clang-fast++
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-llvm-pass.so
${CMAKE_CURRENT_SOURCE_DIR}/afl/afl-llvm-rt.o
PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_READ WORLD_READ
DESTINATION lib/ct-fuzz
)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/xxHash/xxhash.h
PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_READ WORLD_READ
DESTINATION share/xxHash/include
)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/share/ct-fuzz
DESTINATION share
USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN "*.py" PATTERN "*.h" PATTERN "*.c"
)