-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (114 loc) · 3.68 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
cmake_minimum_required(VERSION 3.8)
project(CROWMerge)
set(CMAKE_MACOSX_RPATH NEW)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
if (NOT LLVM_BUILD_TYPE)
set(LLVM_BUILD_TYPE Release)
endif()
set(LLVM_CONFIG_EXECUTABLE /usr/local/opt/llvm/bin/llvm-config)
if(NOT EXISTS ${LLVM_CONFIG_EXECUTABLE})
message(FATAL_ERROR "llvm-config could not be found!")
endif()
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
OUTPUT_VARIABLE LLVM_INCLUDEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags
OUTPUT_VARIABLE LLVM_CXXFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-exceptions -fno-rtti")
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs all
OUTPUT_VARIABLE LLVM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
OUTPUT_VARIABLE LLVM_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs all
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LLVM_LIBS "${LLVM_LIBS} ${LLVM_SYSTEM_LIBS}")
string(STRIP ${LLVM_LIBS} LLVM_LIBS)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
OUTPUT_VARIABLE LLVM_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PASS_LDFLAGS "${LLVM_LDFLAGS}")
message(${LLVM_LDFLAGS})
# string(REPLACE -llibxml2.tbd "" NEW_LLVM_LIBS ${LLVM_LIBS} )
message(${LLVM_LIBS})
#string(STRIP ${NEW_LLVM_LIBS} NEW_LLVM_LIBS )
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --bindir
OUTPUT_VARIABLE LLVM_BINDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --src-root
OUTPUT_VARIABLE LLVM_SRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --obj-root
OUTPUT_VARIABLE LLVM_BUILD
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fexceptions -std=c++17")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fvisibility-inlines-hidden")
set(PASS_LDFLAGS "-Wl,-undefined,dynamic_lookup") # Apple
endif()
include_directories(include "${CMAKE_BINARY_DIR}/include")
include_directories(include "${LLVM_INCLUDEDIR}")
# variable_watch(LLVM_LIBRARY_DIRS)
link_directories(${LLVM_LIBRARY_DIRS})
set(CLANG_CXXFLAGS "")
set(CLANG_INCLUDEDIR "${LLVM_SRC}/../clang/include" "${LLVM_BUILD}/tools/clang/include")
# variable_watch(LLVM_LDFLAGS)
add_definitions(${LLVM_DEFINITIONS})
set(COMMON_FILES
include/common/Common.h
lib/common/Common.cpp
)
set(DISCRIMINATOR_FILES
include/discriminator/Discriminator.h
lib/discriminator/Discriminator.cpp
)
set(INSTRUMENTOR_FILES
include/instrumentor/Instrumentor.h
lib/instrumentor/Instrumentor.cpp
)
set(CROW_MERGE_SOURCES
${COMMON_FILES}
${INSTRUMENTOR_FILES}
${DISCRIMINATOR_FILES}
)
add_executable(crow-linker
${CROW_MERGE_SOURCES}
tools/crow-linker.cpp)
add_executable(static-mapper
${CROW_MERGE_SOURCES}
tools/static_mapper.cpp)
set(LLVM_LDFLAGS "${LLVM_LDFLAGS}")
#VARIABLE_WATCH(LLVM_LIB_DIR)
target_link_libraries(crow-linker ${LLVM_LIBS} ${LLVM_LDFLAGS})
target_link_libraries(static-mapper ${LLVM_LIBS} ${LLVM_LDFLAGS})
foreach(target crow-linker static-mapper )
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${LLVM_CXXFLAGS}")
target_include_directories(${target} PRIVATE "${LLVM_INCLUDEDIR}")
endforeach()
# dynamic
#target_link_libraries(souperCodegen ${PASS_LDFLAGS})