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