-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
179 lines (147 loc) · 4.89 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
169
170
171
172
173
174
175
176
177
178
179
cmake_minimum_required(VERSION 3.13)
project(noelle)
include(FetchContent)
include(config.default.cmake)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)
include(config.cmake)
endif()
if(DEFINED NOELLE_INSTALL_DIR)
set(CMAKE_INSTALL_PREFIX ${NOELLE_INSTALL_DIR})
endif()
if(NOT DEFINED NOELLE_BUILD_TYPE)
set(NOELLE_BUILD_TYPE "Debug")
endif()
if(NOT DEFINED SVF_BUILD_TYPE)
set(SVF_BUILD_TYPE "Release")
endif()
if(NOT DEFINED SCAF_BUILD_TYPE)
set(SCAF_BUILD_TYPE "Release")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(LLVM 14 REQUIRED CONFIG)
FetchContent_Declare(
svf
GIT_REPOSITORY "https://github.com/arcana-lab/SVF.git"
GIT_TAG noelle-14
)
FetchContent_Declare(
scaf
GIT_REPOSITORY "https://github.com/PrincetonUniversity/SCAF.git"
GIT_TAG llvm14
)
FetchContent_Declare(
rapidjson
GIT_REPOSITORY "https://github.com/Tencent/rapidjson.git"
)
FetchContent_GetProperties(rapidjson)
if(NOT rapidjson_POPULATED)
FetchContent_Populate(rapidjson)
endif()
set(NOELLE_CMAKE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
get_filename_component(
CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} REALPATH
)
get_filename_component(
NOELLE_CMAKE_ROOT ${NOELLE_CMAKE_ROOT} REALPATH
)
string(ASCII 27 Esc)
set(Purple "${Esc}[35m")
set(Green "${Esc}[32m")
set(Red "${Esc}[31m")
set(ColorReset "${Esc}[m")
function(noelle_acquire_option OPT)
if(${OPT} MATCHES "ON|On|on|1")
set(${OPT} ON PARENT_SCOPE)
message(STATUS "${Purple}Option${ColorReset} ${OPT} ${Green}ON${ColorReset}")
elseif(${OPT} MATCHES "OFF|Off|off|0")
set(${OPT} OFF PARENT_SCOPE)
message(STATUS "${Purple}Option${ColorReset} ${OPT} ${Red}OFF${ColorReset}")
elseif(${OPT} MATCHES "OFF|Off|off|0")
else()
message(FATAL_ERROR "${OPT} must be either ON or OFF")
endif()
endfunction()
message(STATUS "${Purple}Install directory${ColorReset} is ${CMAKE_INSTALL_PREFIX}")
message(STATUS "${Purple}NOELLE build type${ColorReset} is ${NOELLE_BUILD_TYPE}")
message(STATUS "${Purple}SVF build type${ColorReset} is ${SVF_BUILD_TYPE}")
message(STATUS "${Purple}SCAF build type${ColorReset} is ${SCAF_BUILD_TYPE}")
noelle_acquire_option(NOELLE_SVF)
noelle_acquire_option(NOELLE_SCAF)
noelle_acquire_option(NOELLE_AUTOTUNER)
noelle_acquire_option(NOELLE_REPL)
noelle_acquire_option(NOELLE_TOOLS)
if(NOELLE_SVF STREQUAL ON)
set(NOELLE_SVF ON)
list(APPEND NOELLE_CXX_FLAGS "-DNOELLE_ENABLE_SVF")
set(CMAKE_BUILD_TYPE ${SVF_BUILD_TYPE})
FetchContent_MakeAvailable(svf)
FetchContent_GetProperties(svf)
include_directories(${svf_BINARY_DIR}/include)
include_directories(${svf_SOURCE_DIR}/svf/include)
include_directories(${svf_SOURCE_DIR}/svf-llvm/include)
endif()
if(NOELLE_SCAF STREQUAL ON)
list(APPEND NOELLE_CXX_FLAGS "-DNOELLE_ENABLE_SCAF")
option(ENABLE_SPECULATION "SCAF speculation" OFF)
set(CMAKE_BUILD_TYPE ${SCAF_BUILD_TYPE})
FetchContent_MakeAvailable(scaf)
FetchContent_GetProperties(scaf)
include_directories(${scaf_SOURCE_DIR}/include)
endif()
set(CMAKE_BUILD_TYPE ${NOELLE_BUILD_TYPE})
set(
NOELLE_LUMBERJACK_JSON_DEFAULT_DIR
${CMAKE_INSTALL_PREFIX}/share/noelle
)
set(
NOELLE_LUMBERJACK_JSON_DEFAULT_PATH
${NOELLE_LUMBERJACK_JSON_DEFAULT_DIR}/Lumberjack.json
)
file(READ ${NOELLE_CMAKE_ROOT}/VERSION NOELLE_VERSION)
string(STRIP ${NOELLE_VERSION} NOELLE_VERSION)
set(NOELLE_EXTERNAL_DIR ${NOELLE_CMAKE_ROOT}/external)
configure_file(enable.in enable @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/enable
DESTINATION ${NOELLE_CMAKE_ROOT}
)
install(
PROGRAMS ${NOELLE_CMAKE_ROOT}/.githooks/pre-commit
DESTINATION ${NOELLE_CMAKE_ROOT}/.git/hooks
)
enable_language(C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_INSTALL_PREFIX}")
# prepare the pass to be included in the source tree
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include_directories(
${rapidjson_SOURCE_DIR}/include
${LLVM_INCLUDE_DIRS}
)
add_compile_options(${NOELLE_CXX_FLAGS})
add_custom_target(
CompileCommands ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${NOELLE_CMAKE_ROOT}/compile_commands.json
)
add_custom_target(noelle_libraries)
add_custom_target(noelle_tool_libraries)
set_target_properties(noelle_libraries PROPERTIES NAMES "")
set_target_properties(noelle_tool_libraries PROPERTIES NAMES "")
function(noelle_component_declare name)
add_llvm_library(${name} MODULE)
get_target_property(names noelle_libraries NAMES)
list(APPEND names ${name})
set_target_properties(noelle_libraries PROPERTIES NAMES "${names}")
endfunction()
function(noelle_tool_declare name)
add_llvm_library(${name} MODULE)
get_target_property(names noelle_tool_libraries NAMES)
list(APPEND names ${name})
set_target_properties(noelle_tool_libraries PROPERTIES NAMES "${names}")
endfunction()
add_subdirectory(src)
add_subdirectory(bin)