-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
124 lines (110 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
cmake_minimum_required(VERSION 3.1.3)
project(prism)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
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(NOT CMAKE_BUILD_TYPE)
################################
# Testing Framework uses Catch #
################################
enable_testing(true)
include(CTest)
######################
# Include everything #
# TODO(cleanup) #
######################
get_filename_component(SRC_CORE src/Core ABSOLUTE)
get_filename_component(SRC_UTILS src/Utils ABSOLUTE)
get_filename_component(SRC_FRONTENDS src/Frontends ABSOLUTE)
get_filename_component(SRC_BACKENDS src/Backends ABSOLUTE)
get_filename_component(THIRD_PARTY third_party ABSOLUTE)
execute_process(
COMMAND git submodule update --init ${THIRD_PARTY}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# Apply patch, or check if already applied
execute_process(
COMMAND git apply --check ${CMAKE_SOURCE_DIR}/gitpatches/spdlog.patch
WORKING_DIRECTORY ${THIRD_PARTY}/spdlog
RESULT_VARIABLE PATCH_RESULT
OUTPUT_QUIET
ERROR_QUIET)
if (${PATCH_RESULT} EQUAL 0)
execute_process(
COMMAND git apply --whitespace=nowarn ${CMAKE_SOURCE_DIR}/gitpatches/spdlog.patch
WORKING_DIRECTORY ${THIRD_PARTY}/spdlog)
else()
execute_process(
COMMAND git apply --check -R ${CMAKE_SOURCE_DIR}/gitpatches/spdlog.patch
WORKING_DIRECTORY ${THIRD_PARTY}/spdlog
RESULT_VARIABLE PATCH_RESULT)
if (NOT ${PATCH_RESULT} EQUAL 0)
message(FATAL_ERROR "could not git patch spdlog library")
endif()
endif()
include_directories(${THIRD_PARTY}/Catch/include)
include_directories(${THIRD_PARTY}/whereami/src)
include_directories(${THIRD_PARTY}/spdlog/include)
include_directories(${THIRD_PARTY}/spdlog/include/spdlog)
include_directories(${THIRD_PARTY}/elfio-3.1)
include_directories(${THIRD_PARTY}/zlib/contrib/iostream3)
include_directories(${THIRD_PARTY}/capnproto/include)
include_directories(src)
include_directories(src/Utils)
include_directories(${SRC_FRONTENDS})
include_directories(${SRC_BACKENDS})
######################
# Optional Frontends #
######################
if(NOT DYNAMORIO_ENABLE)
set(DYNAMORIO_ENABLE FALSE CACHE BOOL
"Enable DynamoRIO frontend"
FORCE)
endif(NOT DYNAMORIO_ENABLE)
if(NOT PERF_ENABLE)
set(PERF_ENABLE FALSE CACHE BOOL
"Enable perf frontend"
FORCE)
endif(NOT PERF_ENABLE)
###############
# Build Prism #
###############
set(SOURCES
${THIRD_PARTY}/whereami/src/whereami.c
${SRC_UTILS}/PrismLog.cpp
${SRC_CORE}/Backends.cpp
${SRC_CORE}/Frontends.cpp
${SRC_CORE}/Parser.cpp
${SRC_CORE}/Config.cpp
${SRC_CORE}/main.cpp)
add_executable(prism ${SOURCES})
target_link_libraries(prism pthread rt)
set_target_properties(prism
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
###################
# Plugin Backends #
###################
file(GLOB subdirs "src/Backends/*")
foreach(dir ${subdirs})
set(PRISM_TOOL_LINK_LIBS "")
# In the backend CMakeLists, set this to a list of libraries that need to be linked with prism.
# This can be a <target> name created with add_library(),
# in which case setting PRISM_TOOL_DEPENDENCIES is not required.
set(PRISM_TOOL_DEPENDENCIES "")
# In the backend CMakeLists, set this to a list of CMake <targets> so prism will build them
add_subdirectory(${dir})
foreach(dep ${PRISM_TOOL_DEPENDENCIES})
add_dependencies(prism ${dep})
endforeach()
foreach(lib ${PRISM_TOOL_LINK_LIBS})
target_link_libraries(prism ${lib})
endforeach()
endforeach()
##########################
# Interface to Frontends #
##########################
add_subdirectory(${SRC_FRONTENDS})
target_link_libraries(prism frontends)