Move dynutil/h to common/h; move common/h to common/src. Update CMakeLists.txt
[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 1)
6 set (DYNINST_PATCH_VERSION 1)
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 set (BUILD_SHARED_LIBS ON)
22
23 set (INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
24 set (INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
25 set (INSTALL_CMAKE_DIR lib/CMake/Dyninst CACHE PATH "Installation directory for CMake files")
26
27 # Make the above absolute paths if necessary
28 foreach (p LIB INCLUDE CMAKE)
29   set (var INSTALL_${p}_DIR)
30   if (NOT IS_ABSOLUTE "${${var}}")
31      set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
32   endif()
33 endforeach()
34
35 include_directories (
36                     ${PROJECT_SOURCE_DIR}
37                     ${PROJECT_SOURCE_DIR}/external
38   )
39
40 set (HEADER_DIRS common
41                  dataflowAPI
42                  dwarf
43                  dyninstAPI
44                  dyninstAPI_RT
45                  dynutil
46                  elf
47                  instructionAPI
48                  parseAPI
49                  patchAPI
50                  proccontrol
51                  stackwalk
52                  symlite
53                  symtabAPI
54     )
55
56 foreach (dir ${HEADER_DIRS})
57   include_directories ( ${PROJECT_SOURCE_DIR}/${dir}/h )
58 endforeach()
59
60 # Component time
61 add_subdirectory (common)
62 add_subdirectory (elf)
63 add_subdirectory (dwarf)
64 add_subdirectory (instructionAPI)
65 add_subdirectory (symtabAPI)
66 add_subdirectory (symlite)
67 add_subdirectory (parseAPI)
68 add_subdirectory (patchAPI)
69 add_subdirectory (proccontrol)
70 add_subdirectory (stackwalk)
71 add_subdirectory (dyninstAPI)
72 add_subdirectory (dyninstAPI_RT)
73
74 SET_TARGET_PROPERTIES (
75    common dynElf dynDwarf instructionAPI symtabAPI symLite parseAPI
76    patchAPI pcontrol stackwalker dyninstAPI dyninstAPI_RT
77    PROPERTIES
78      SOVERSION ${SOVERSION}
79      VERSION ${LIBVERSION}
80 )
81
82 # RTlib properties are set in its CMakeLists.txt; it seems
83 # like multiple set_target_properties calls override instead
84 # of accumulating
85
86
87 #
88 # DyninstConfig.cmake
89
90 export (PACKAGE Dyninst)
91
92 file (RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")
93
94 # For the build tree
95 set (CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
96 configure_file(cmake/DyninstConfig.cmake.in "${PROJECT_BINARY_DIR}/DyninstConfig.cmake" @ONLY)
97 # For the install tree
98 set (CONF_INCLUDE_DIRS "\${DYNINST_CMAKE_DIR}/${REL_INCLUDE_DIR}")
99 configure_file(cmake/DyninstConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfig.cmake" @ONLY)
100
101 # And version file
102 configure_file(cmake/DyninstConfigVersion.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfigVersion.cmake" @ONLY)
103
104 install (FILES
105         "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfig.cmake"
106         "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DyninstConfigVersion.cmake"
107         DESTINATION "${INSTALL_CMAKE_DIR}")
108
109 install (EXPORT dyninst
110         DESTINATION "${INSTALL_CMAKE_DIR}")