Right now, the BPatch_deref and BPatch_regExpr do not specify the size.
[dyninst.git] / CMakeLists.txt
1 cmake_minimum_required (VERSION 3.4.0)
2 project (Dyninst)
3
4 set (DYNINST_ROOT ${PROJECT_SOURCE_DIR})
5 set (CMAKE_SKIP_BUILD_RPATH FALSE)
6 set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
7 set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
8 set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
9 LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES 
10           "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
11 IF("${isSystemDir}" STREQUAL "-1")
12                     set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
13 ENDIF()
14
15 set(RT_SOURCE_DIR ${DYNINST_ROOT}/dyninstAPI_RT)
16 set(RT_BINARY_DIR ${PROJECT_BINARY_DIR}/dyninstAPI_RT)
17
18 set (CMAKE_MODULE_PATH "${DYNINST_ROOT}/cmake" "${DYNINST_ROOT}/cmake/Modules" ${CMAKE_MODULE_PATH})
19
20 find_package(Threads)
21 include(Boost)
22 include(ThreadingBuildingBlocks)
23 include(ElfUtils)
24 include (${DYNINST_ROOT}/cmake/shared.cmake)
25
26 configure_file(cmake/version.h.in common/h/dyninstversion.h)
27 include_directories(${PROJECT_BINARY_DIR})
28 include_directories(${PROJECT_BINARY_DIR}/common/h)
29 set (HEADER_DIRS common
30     dataflowAPI
31     dyninstAPI
32     instructionAPI
33     parseAPI
34     patchAPI
35     proccontrol
36     stackwalk
37     symtabAPI
38     )
39 if(NOT ${PLATFORM} MATCHES nt)
40   set (HEADER_DIRS ${HEADER_DIRS}
41     dwarf
42     elf
43     symlite
44     )
45 endif()
46
47
48
49 foreach (dir ${HEADER_DIRS})
50   include_directories ( ${DYNINST_ROOT}/${dir}/h )
51 endforeach()
52
53
54 include_directories (
55   ${DYNINST_ROOT}
56   ${DYNINST_ROOT}/external
57   ${CILKSCREEN_INCLUDES}
58       ${TBB_INCLUDE_DIRS}
59   )
60
61 # Component time
62 add_subdirectory (common)
63 if(NOT ${PLATFORM} MATCHES nt)
64   add_subdirectory (elf)
65   add_subdirectory (dwarf)
66   add_subdirectory (symlite)
67   add_subdirectory (parseThat)
68 endif()
69 add_subdirectory (instructionAPI)
70 add_subdirectory (symtabAPI)
71 add_subdirectory (parseAPI)
72 add_subdirectory (proccontrol)
73 add_subdirectory (stackwalk)
74 add_subdirectory (patchAPI)
75 add_subdirectory(examples)
76 if(${SYMREADER} MATCHES symtabAPI)
77   add_subdirectory (dyninstAPI)
78   add_subdirectory (dynC_API)
79 endif()
80
81 if(BUILD_RTLIB)
82   # Build the RT library as a separate project so we can change compilers
83   message(STATUS "Configuring DyninstAPI_RT in ${RT_BINARY_DIR}")
84   file(REMOVE_RECURSE ${RT_BINARY_DIR}/CMakeCache.txt ${RT_BINARY_DIR}/CMakeFiles ${RT_BINARY_DIR}/Makefile)
85   file(MAKE_DIRECTORY ${RT_BINARY_DIR})
86   if (PLATFORM MATCHES bgq)
87     set (RT_C_COMPILER mpicc CACHE STRING "Compiler for runtime library")
88   else()
89     set (RT_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "Compiler for runtime library")
90   endif()
91   set (ENABLE_STATIC_LIBS NO CACHE STRING "Build static libraries as well?")
92   message(STATUS "Configuring RT library")
93
94   execute_process(WORKING_DIRECTORY ${RT_BINARY_DIR}
95     COMMAND ${CMAKE_COMMAND}
96     -DCMAKE_C_COMPILER=${RT_C_COMPILER}
97     -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
98     -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
99     -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
100     -DINSTALL_LIB_DIR=${INSTALL_LIB_DIR}
101     -DINSTALL_INCLUDE_DIR=${INSTALL_INCLUDE_DIR}
102     -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
103     -DBUILD_RTLIB_32=${BUILD_RTLIB_32}
104     -DPLATFORM=${PLATFORM}
105     -G ${CMAKE_GENERATOR}
106     ${RT_SOURCE_DIR})
107   find_file(${RT_MAKEFILE} Makefile PATHS ${RT_BINARY_DIR} NO_DEFAULT_PATH)
108   message(STATUS "RTlib Makefile: ${RT_MAKEFILE}")
109   if(MSVC)
110       include_external_msproject(DyninstAPI_RT dyninstAPI_RT/dyninstAPI_RT.vcxproj)
111           include_external_msproject(DyninstAPI_RT_static dyninstAPI_RT/dyninstAPI_RT_static.vcxproj)
112   else()
113     add_custom_target(DyninstRT
114       ALL
115       $(MAKE)
116       WORKING_DIRECTORY ${RT_BINARY_DIR}
117       COMMENT "Building DyninstRT")
118     if(TARGET TBB)
119       add_dependencies(DyninstRT TBB)
120     endif()
121     add_dependencies(dyninstAPI DyninstRT)
122     if(TARGET dyninstAPI-static)
123       add_dependencies(dyninstAPI-static DyninstRT)
124     endif()
125     if(TARGET boost)
126       add_dependencies(DyninstRT boost)
127     endif()
128   endif()
129
130   install(SCRIPT "${RT_BINARY_DIR}/cmake_install.cmake")
131
132 else()
133   message(STATUS "Skipping DyninstAPI_RT. Be sure to build this library if you're using instrumentation.")
134 endif()
135 set (VERSION_STRING "${DYNINST_MAJOR_VERSION}.${DYNINST_MINOR_VERSION}.${DYNINST_PATCH_VERSION}")
136 set (DYNINST_NAME "DyninstAPI-${VERSION_STRING}")
137
138 if(BUILD_TARBALLS)
139   find_package(Git)
140   if(GIT_FOUND)
141     if(EXISTS "${DYNINST_ROOT}/.git/")
142       message(STATUS "Source tree is repository, building archive target")
143       add_custom_target(package ALL)
144       add_custom_command(TARGET package
145         COMMAND ${GIT_EXECUTABLE} archive --prefix="${DYNINST_NAME}/" --format=tar.gz -o "${CMAKE_BINARY_DIR}/${DYNINST_NAME}.tgz" HEAD
146         WORKING_DIRECTORY ${DYNINST_ROOT}
147         COMMENT "Packaging Dyninst")
148     endif()
149   endif()
150 endif()
151 if(BUILD_DOCS)
152   add_custom_target(doc)
153   set(LATEX_DOCS dynC_API dataflowAPI instructionAPI parseAPI patchAPI symtabAPI stackwalk)
154   set(WORD_DOCS proccontrol dyninstAPI)
155   add_custom_target(proccontrol-doc
156     DEPENDS ${CMAKE_SOURCE_DIR}/proccontrol/doc/proccontrol.pdf)
157   add_custom_target(dyninstAPI-doc
158     DEPENDS ${CMAKE_SOURCE_DIR}/dyninstAPI/doc/dyninstAPI.pdf)
159   foreach(COMPONENT ${WORD_DOCS})
160     add_dependencies(doc ${COMPONENT}-doc)
161     set_target_properties(${COMPONENT}-doc PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
162     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.pdf
163       DESTINATION ${INSTALL_DOC_DIR}
164       RENAME ${COMPONENT}-${VERSION_STRING}.pdf
165       OPTIONAL
166       )
167   endforeach()
168
169   find_package(LATEX)
170   if(PDFLATEX_COMPILER)
171     file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/common/doc
172       DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/common)
173     foreach(COMPONENT ${LATEX_DOCS})
174       file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${COMPONENT}/doc
175         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT})
176       set (DEPS "")
177       file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/${COMPONENT}/doc/*.tex ${CMAKE_CURRENT_SOURCE_DIR}/common/doc/*.tex)
178       add_custom_command(
179         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.aux
180         DEPENDS ${DEPS}
181         COMMAND ${PDFLATEX_COMPILER}
182         ARGS -interaction=batchmode ${COMPONENT}.tex
183         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc
184         COMMENT "Latex (first pass)"
185         )
186       add_custom_command(
187         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.log
188         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.aux
189         COMMAND ${PDFLATEX_COMPILER}
190         ARGS -interaction=batchmode ${COMPONENT}.tex
191         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc
192         COMMENT "Latex (second pass)"
193         )
194       add_custom_target(${COMPONENT}-doc echo
195         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.log
196         )
197       add_dependencies(doc ${COMPONENT}-doc)
198       set_target_properties(${COMPONENT}-doc PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
199       install(FILES  ${CMAKE_CURRENT_BINARY_DIR}/${COMPONENT}/doc/${COMPONENT}.pdf
200         DESTINATION ${INSTALL_DOC_DIR}
201         RENAME ${COMPONENT}-${VERSION_STRING}.pdf
202         OPTIONAL
203         )
204     endforeach()
205   else()
206     message(STATUS "LaTeX not found")
207   endif()
208 endif()
209
210 if(UNIX)
211   message(STATUS "Adding Unix-specific dependencies")
212   if(NOT USE_GNU_DEMANGLER)
213     add_dependencies(common libiberty_imp)
214   endif()
215 endif()
216
217 if(TARGET boost)
218     add_dependencies(common boost)
219 endif()
220
221 #add_subdirectory(testsuite)
222
223 # Copy out all of the cmake files so they can be used by the Testsuite
224 install(DIRECTORY ${DYNINST_ROOT}/cmake/ DESTINATION ${INSTALL_CMAKE_DIR})
225 install(FILES ${PROJECT_BINARY_DIR}/CMakeCache.txt DESTINATION ${INSTALL_CMAKE_DIR})