forked from dyninst/dyninst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
236 lines (209 loc) · 7.64 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
cmake_minimum_required (VERSION 3.4.0)
project (Dyninst)
set (DYNINST_ROOT ${PROJECT_SOURCE_DIR})
set (CMAKE_SKIP_BUILD_RPATH FALSE)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(STERILE_BUILD OFF CACHE BOOL "Do not download/build any third-party dependencies from source")
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF()
set(RT_SOURCE_DIR ${DYNINST_ROOT}/dyninstAPI_RT)
set(RT_BINARY_DIR ${PROJECT_BINARY_DIR}/dyninstAPI_RT)
set (CMAKE_MODULE_PATH "${DYNINST_ROOT}/cmake" "${DYNINST_ROOT}/cmake/Modules" ${CMAKE_MODULE_PATH})
# Set the C and C++ language standards
include(LanguageStandards)
# Find the necessary third-party libraries
find_package(ThreadDB)
find_package(Threads)
include(Boost)
include(ThreadingBuildingBlocks)
include(ElfUtils)
if(UNIX)
include(LibIberty REQUIRED)
endif()
include(shared)
if(USE_OpenMP)
find_package(OpenMP REQUIRED)
endif()
configure_file(cmake/version.h.in common/h/dyninstversion.h)
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_BINARY_DIR}/common/h)
set (HEADER_DIRS common
dataflowAPI
dyninstAPI
instructionAPI
parseAPI
patchAPI
proccontrol
stackwalk
symtabAPI
)
if(NOT ${PLATFORM} MATCHES nt)
set (HEADER_DIRS ${HEADER_DIRS}
dwarf
elf
symlite
)
endif()
foreach (dir ${HEADER_DIRS})
include_directories ( ${DYNINST_ROOT}/${dir}/h )
endforeach()
set(ADD_VALGRIND_ANNOTATIONS OFF CACHE BOOL "Enable annotations for Valgrind analysis")
if(ADD_VALGRIND_ANNOTATIONS)
find_package(Valgrind REQUIRED)
include_directories(${Valgrind_INCLUDE_DIRS})
add_definitions(-DENABLE_VG_ANNOTATIONS)
endif()
include_directories (
${DYNINST_ROOT}
${DYNINST_ROOT}/external
${TBB_INCLUDE_DIRS}
)
# Component time
add_subdirectory (common)
if(NOT ${PLATFORM} MATCHES nt)
add_subdirectory (elf)
add_subdirectory (dwarf)
add_subdirectory (symlite)
add_subdirectory (parseThat)
endif()
add_subdirectory (instructionAPI)
add_subdirectory (symtabAPI)
add_subdirectory (parseAPI)
add_subdirectory (proccontrol)
add_subdirectory (stackwalk)
add_subdirectory (patchAPI)
if(${SYMREADER} MATCHES symtabAPI)
add_subdirectory (dyninstAPI)
add_subdirectory (dynC_API)
endif()
if(BUILD_RTLIB)
# Build the RT library as a separate project so we can change compilers
message(STATUS "Configuring DyninstAPI_RT in ${RT_BINARY_DIR}")
file(REMOVE_RECURSE ${RT_BINARY_DIR}/CMakeCache.txt ${RT_BINARY_DIR}/CMakeFiles ${RT_BINARY_DIR}/Makefile)
file(MAKE_DIRECTORY ${RT_BINARY_DIR})
set (RT_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "Compiler for runtime library")
set (ENABLE_STATIC_LIBS NO CACHE STRING "Build static libraries as well?")
message(STATUS "Configuring RT library")
execute_process(WORKING_DIRECTORY ${RT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND}
-DCMAKE_C_COMPILER=${RT_C_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DINSTALL_LIB_DIR=${INSTALL_LIB_DIR}
-DINSTALL_INCLUDE_DIR=${INSTALL_INCLUDE_DIR}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DBUILD_RTLIB_32=${BUILD_RTLIB_32}
-DPLATFORM=${PLATFORM}
-G ${CMAKE_GENERATOR}
${RT_SOURCE_DIR})
find_file(${RT_MAKEFILE} Makefile PATHS ${RT_BINARY_DIR} NO_DEFAULT_PATH)
message(STATUS "RTlib Makefile: ${RT_MAKEFILE}")
if(MSVC)
include_external_msproject(DyninstAPI_RT dyninstAPI_RT/dyninstAPI_RT.vcxproj)
include_external_msproject(DyninstAPI_RT_static dyninstAPI_RT/dyninstAPI_RT_static.vcxproj)
else()
add_custom_target(DyninstRT
ALL
$(MAKE)
WORKING_DIRECTORY ${RT_BINARY_DIR}
COMMENT "Building DyninstRT")
if(TARGET TBB)
add_dependencies(DyninstRT TBB)
endif()
add_dependencies(dyninstAPI DyninstRT)
if(TARGET dyninstAPI-static)
add_dependencies(dyninstAPI-static DyninstRT)
endif()
if(TARGET boost)
add_dependencies(DyninstRT boost)
endif()
endif()
install(SCRIPT "${RT_BINARY_DIR}/cmake_install.cmake")
else()
message(STATUS "Skipping DyninstAPI_RT. Be sure to build this library if you're using instrumentation.")
endif()
set (VERSION_STRING "${DYNINST_MAJOR_VERSION}.${DYNINST_MINOR_VERSION}.${DYNINST_PATCH_VERSION}")
set (DYNINST_NAME "DyninstAPI-${VERSION_STRING}")
if(BUILD_TARBALLS)
find_package(Git)
if(GIT_FOUND)
if(EXISTS "${DYNINST_ROOT}/.git/")
message(STATUS "Source tree is repository, building archive target")
add_custom_target(package ALL)
add_custom_command(TARGET package
COMMAND ${GIT_EXECUTABLE} archive --prefix="${DYNINST_NAME}/" --format=tar.gz -o "${CMAKE_BINARY_DIR}/${DYNINST_NAME}.tgz" HEAD
WORKING_DIRECTORY ${DYNINST_ROOT}
COMMENT "Packaging Dyninst")
endif()
endif()
endif()
if(BUILD_DOCS)
add_custom_target(doc)
set(LATEX_DOCS dynC_API dataflowAPI instructionAPI parseAPI patchAPI symtabAPI stackwalk)
set(WORD_DOCS proccontrol dyninstAPI)
add_custom_target(proccontrol-doc
DEPENDS ${CMAKE_SOURCE_DIR}/proccontrol/doc/proccontrol.pdf)
add_custom_target(dyninstAPI-doc
DEPENDS ${CMAKE_SOURCE_DIR}/dyninstAPI/doc/dyninstAPI.pdf)
foreach(COMPONENT ${WORD_DOCS})
add_dependencies(doc ${COMPONENT}-doc)
set_target_properties(${COMPONENT}-doc PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.pdf
DESTINATION ${INSTALL_DOC_DIR}
RENAME ${COMPONENT}-${VERSION_STRING}.pdf
OPTIONAL
)
endforeach()
find_package(LATEX)
if(PDFLATEX_COMPILER)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/common/doc
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/common)
foreach(COMPONENT ${LATEX_DOCS})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${COMPONENT}/doc
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT})
set (DEPS "")
file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/${COMPONENT}/doc/*.tex ${CMAKE_CURRENT_SOURCE_DIR}/common/doc/*.tex)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.aux
DEPENDS ${DEPS}
COMMAND ${PDFLATEX_COMPILER}
ARGS -interaction=batchmode ${COMPONENT}.tex
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc
COMMENT "Latex (first pass)"
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.log
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.aux
COMMAND ${PDFLATEX_COMPILER}
ARGS -interaction=batchmode ${COMPONENT}.tex
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc
COMMENT "Latex (second pass)"
)
add_custom_target(${COMPONENT}-doc echo
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.log
)
add_dependencies(doc ${COMPONENT}-doc)
set_target_properties(${COMPONENT}-doc PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.pdf
DESTINATION ${INSTALL_DOC_DIR}
RENAME ${COMPONENT}-${VERSION_STRING}.pdf
OPTIONAL
)
endforeach()
else()
message(STATUS "LaTeX not found")
endif()
endif()
if(TARGET boost)
add_dependencies(common boost)
endif()
#add_subdirectory(testsuite)
# Copy out all of the cmake files so they can be used by the Testsuite
install(DIRECTORY ${DYNINST_ROOT}/cmake/ DESTINATION ${INSTALL_CMAKE_DIR})
install(FILES ${PROJECT_BINARY_DIR}/CMakeCache.txt DESTINATION ${INSTALL_CMAKE_DIR})