-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
152 lines (113 loc) · 4.55 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
cmake_minimum_required(VERSION 3.16)
project(baguatool CXX C)
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message(FATAL_ERROR "Do not support non-Linux now!")
endif()
# TODO: remove it in the future
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Set build type to DEBUG" FORCE)
message(AUTHOR_WARNING "Overwrite build type to DEBUG for development")
# # output path
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# third party
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/igraph)
target_compile_options(igraph PRIVATE -fPIC)
find_package(PAPI REQUIRED)
find_package(Dyninst REQUIRED)
find_package(Boost REQUIRED)
if (Dyninst_FOUND)
message(STATUS "Found Dyninst: " ${DYNINST_INCLUDE_DIR})
endif()
#option(ENABLE_TEST "Enable test" ON)
option(ENABLE_EXAMPLE "Enable example" ON)
option(ENABLE_SANITIZE "Enable sanitize" OFF)
# explicitly list all source file
add_library(
baguatool
SHARED
include/common/common.h
include/common/tprintf.h
include/common/utils.cpp
src/core/graph.cpp
src/core/pg.cpp
src/core/pag.cpp
src/core/mpag.cpp
src/core/pcg.cpp
src/core/cfg.cpp
src/core/perf_data.cpp
src/core/graph_perf_data.cpp
src/core/bagua_type.cpp
#src/graph_perf/preprocessing/preprocess.cpp
src/collector/static/dyninst/static_analysis.cpp
src/collector/dynamic/papi/sampler.cpp
src/collector/dynamic/shared_obj_analysis.cpp
# src/hybrid_analysis/graph_perf.cpp
)
set_target_properties(
baguatool
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
set_property(TARGET baguatool PROPERTY CXX_STANDARD 17)
set_property(TARGET baguatool PROPERTY CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0.0")
message(FATAL_ERROR "Insufficient GCC version (${CMAKE_CXX_COMPILER_VERSION}), need > 7.0.0")
endif()
else()
message(FATAL_ERROR "Do not support cxx compiler for ${CMAKE_CXX_COMPILER_ID}, choose GNU please")
endif()
target_compile_options(
baguatool PRIVATE
-Wall -Wno-missing-braces
#-fno-rtti # We cannot open it because dyninst use `typeid` in header
-fno-omit-frame-pointer -fstack-protector-all
-rdynamic
)
# FIXME: how to use sanitize for subproject?
if (ENABLE_SANITIZE)
target_compile_options(
baguatool PUBLIC
$<$<CONFIG:DEBUG>:-fsanitize=address -g>
)
endif()
target_include_directories(baguatool PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(baguatool PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_include_directories(baguatool PUBLIC ${PROJECT_SOURCE_DIR}/third_party/dbg)
target_include_directories(baguatool PUBLIC ${PROJECT_SOURCE_DIR}/third_party/json)
#target_include_directories(baguatool PUBLIC ${PROJECT_SOURCE_DIR}/third_party/toml)
#target_include_directories(baguatool PUBLIC ${PROJECT_SOURCE_DIR}/third_party/pmpi_wrapper)
target_include_directories(baguatool PRIVATE igraph)
target_include_directories(baguatool PRIVATE ${DYNINST_INCLUDE_DIR})
target_include_directories(baguatool PRIVATE ${PAPI_INCLUDE_DIRS})
target_include_directories(baguatool PRIVATE ${Boost_INCLUDE_DIRS})
# if(OpenMP_CXX_FOUND)
# target_link_libraries(baguatool PUBLIC OpenMP::OpenMP_CXX)
# endif()
target_link_libraries(baguatool PRIVATE igraph)
target_link_libraries(
baguatool
PRIVATE
# TODO: we do not need all these
dyninstAPI parseAPI instructionAPI symtabAPI symLite dynDwarf dynElf common unwind)
target_link_libraries(baguatool PRIVATE ${PAPI_LIBRARIES})
target_link_libraries(baguatool PRIVATE ${Boost_LIBRARIES})
add_subdirectory(${PROJECT_SOURCE_DIR}/builtin)
if (ENABLE_EXAMPLE)
# List what we want to test
#add_subdirectory(${PROJECT_SOURCE_DIR}/test/igraph_test)
add_subdirectory(example)
endif()
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/dbg/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/json/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS baguatool DESTINATION lib)
# install(TARGETS binary_analyzer DESTINATION bin)
# install(TARGETS sequential_sampler DESTINATION lib)
# install(TARGETS pthread_sampler DESTINATION lib)
# install(TARGETS mpi_sampler DESTINATION lib)
# install(TARGETS omp_sampler DESTINATION lib)