Enable built-in gcc demangler rather than libiberty's
[dyninst.git] / CMakeLists.txt
1 if(UNIX)
2 cmake_minimum_required (VERSION 2.8.11)
3 else()
4 cmake_minimum_required (VERSION 2.6.4)
5 endif()
6 project (Dyninst)
7
8 set (DYNINST_MAJOR_VERSION 8)
9 set (DYNINST_MINOR_VERSION 2)
10 set (DYNINST_PATCH_VERSION 0)
11
12 # Debugging
13 set(Boost_DEBUG 1)
14
15 set (SOVERSION "${DYNINST_MAJOR_VERSION}.${DYNINST_MINOR_VERSION}")
16 set (LIBVERSION "${SOVERSION}.${DYNINST_PATCH_VERSION}")
17 set (DYNINST_VERSION "${LIBVERSION}")
18
19 #Change to revert to libiberty demangler
20 set(USE_GNU_DEMANGLER 1)
21
22 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules")
23 include (cmake/platform.cmake)
24 include (cmake/packages.cmake)
25 include (cmake/cap_arch_def.cmake)
26 include (cmake/c++11.cmake)
27 include (cmake/visibility.cmake)
28 include (cmake/warnings.cmake)
29 include (cmake/options.cmake)
30 include (cmake/optimization.cmake)
31
32 set (BUILD_SHARED_LIBS ON)
33
34 set (INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
35 set (INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
36 set (INSTALL_CMAKE_DIR lib/cmake/Dyninst CACHE PATH "Installation directory for CMake files")
37
38 # Make the above absolute paths if necessary
39 foreach (p LIB INCLUDE CMAKE)
40   set (var INSTALL_${p}_DIR)
41   if (NOT IS_ABSOLUTE "${${var}}")
42      set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
43   endif()
44 endforeach()
45
46 include_directories (
47                     ${PROJECT_SOURCE_DIR}
48                     ${PROJECT_SOURCE_DIR}/external
49   )
50
51 if(${PLATFORM} MATCHES nt)
52 set (HEADER_DIRS common
53                  dataflowAPI
54                  dyninstAPI
55                  dyninstAPI_RT
56                  dynutil
57                  instructionAPI
58                  parseAPI
59                  patchAPI
60                  proccontrol
61                  stackwalk
62                  symtabAPI
63     )
64 else()
65 set (HEADER_DIRS common
66                  dataflowAPI
67                  dwarf
68                  dyninstAPI
69                  dyninstAPI_RT
70                  dynutil
71                  elf
72                  instructionAPI
73                  parseAPI
74                  patchAPI
75                  proccontrol
76                  stackwalk
77                  symlite
78                  symtabAPI
79     )
80 endif()
81
82 foreach (dir ${HEADER_DIRS})
83   include_directories ( ${PROJECT_SOURCE_DIR}/${dir}/h )
84 endforeach()
85
86 # Component time
87 add_subdirectory (common)
88 if(NOT ${PLATFORM} MATCHES nt)
89     add_subdirectory (elf)
90     add_subdirectory (dwarf)
91     add_subdirectory (symlite)
92 endif()
93 add_subdirectory (instructionAPI)
94 add_subdirectory (symtabAPI)
95 add_subdirectory (parseAPI)
96 add_subdirectory (patchAPI)
97 add_subdirectory (proccontrol)
98 add_subdirectory (stackwalk)
99 add_subdirectory (dyninstAPI)
100 add_subdirectory (dyninstAPI_RT)
101
102 if(UNIX)
103 add_dependencies(dynDwarf libdwarf_imp)
104 add_dependencies(dynElf libelf_imp)
105 add_dependencies(common libiberty_imp)
106 add_dependencies(libdwarf_imp libelf_imp)
107 endif()
108
109 if(NOT ${PLATFORM} MATCHES nt)
110     SET_TARGET_PROPERTIES (
111         common dynElf dynDwarf instructionAPI symtabAPI symLite parseAPI
112         patchAPI pcontrol stackwalk dyninstAPI
113         PROPERTIES
114             SOVERSION ${SOVERSION}
115             VERSION ${LIBVERSION}
116     )
117 else()
118     SET_TARGET_PROPERTIES (
119         common instructionAPI symtabAPI parseAPI
120         patchAPI pcontrol stackwalk dyninstAPI
121         PROPERTIES
122             SOVERSION ${SOVERSION}
123             VERSION ${LIBVERSION}
124     )
125
126 endif()
127
128 if(PLATFORM MATCHES nt OR PLATFORM MATCHES windows)
129     add_definitions(-Dsnprintf=_snprintf)
130 endif()
131
132 # RTlib properties are set in its CMakeLists.txt; it seems
133 # like multiple set_target_properties calls override instead
134 # of accumulating
135
136
137
138
139
140 #
141 # DyninstConfig.cmake
142
143 # Not sure if needed...
144 #export (PACKAGE Dyninst)
145
146 file (RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
147
148 # For the build tree
149 # I don't think we want this; it doesn't work quite right
150 #foreach (dir ${HEADER_DIRS})
151 #    set (CONF_INCLUDE_DIRS ${CONF_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/${dir}/h)
152 #endforeach()
153 #configure_file(cmake/DyninstConfig.cmake.in "${PROJECT_BINARY_DIR}/DyninstConfig.cmake" @ONLY)
154
155
156 # For the install tree
157 set (CONF_INCLUDE_DIRS "\${DYNINST_CMAKE_DIR}/${REL_INCLUDE_DIR}")
158
159 configure_file(cmake/DyninstConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfig.cmake" @ONLY)
160
161 # And version file
162 configure_file(cmake/DyninstConfigVersion.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfigVersion.cmake" @ONLY)
163
164 if(UNIX)
165 if(SHOULD_INSTALL_LIBELF)
166 get_filename_component(ELFDIR "${LIBELF_LIBRARIES}" PATH)
167 file(GLOB LIBELF_INSTALL_FILES ${ELFDIR}/libelf.so*)
168 message(STATUS "Libelf is ${LIBELF_LIBRARIES}")
169 message(STATUS "Installing ${LIBELF_INSTALL_FILES} from ${ELFDIR}")
170 install (FILES ${LIBELF_INSTALL_FILES}
171         DESTINATION "${INSTALL_LIB_DIR}")
172 endif()
173 if(NOT LIBDWARF_FOUND)
174 message(STATUS "Installing ${LIBDWARF_LIBRARIES}")
175 install (FILES ${LIBDWARF_LIBRARIES}
176         DESTINATION "${INSTALL_LIB_DIR}")
177 endif()
178 endif()
179 install (FILES
180         "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfig.cmake"
181         "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfigVersion.cmake"
182         DESTINATION "${INSTALL_CMAKE_DIR}")
183 install (EXPORT DyninstTargets
184         DESTINATION "${INSTALL_CMAKE_DIR}")