Add interpret results output into custom stream.
[sdk/tools/heaptrack.git] / CMakeLists.txt
1 if (CMAKE_VERSION VERSION_LESS "2.8.12")
2     cmake_minimum_required(VERSION 2.8.9)
3     set(HEAPTRACK_BUILD_GUI OFF)
4 else()
5     cmake_minimum_required(VERSION 2.8.12)
6 endif()
7
8 project(heaptrack)
9 enable_testing()
10
11 if(NOT CMAKE_BUILD_TYPE)
12   message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
13   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
14 endif()
15
16 set(HEAPTRACK_VERSION_MAJOR 1)
17 set(HEAPTRACK_VERSION_MINOR 1)
18 set(HEAPTRACK_VERSION_PATCH 0)
19 set(HEAPTRACK_VERSION_SUFFIX 0.1)
20 set(HEAPTRACK_LIB_VERSION 1.0.0-0.1)
21 set(HEAPTRACK_LIB_SOVERSION 1)
22 set(HEAPTRACK_FILE_FORMAT_VERSION 2)
23
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
25
26 find_package(Libunwind REQUIRED)
27 find_package(Boost 1.41.0 REQUIRED COMPONENTS iostreams program_options)
28 find_package(Threads REQUIRED)
29 find_package(ZLIB REQUIRED)
30 include(FeatureSummary)
31
32 option(
33   HEAPTRACK_BUILD_GUI
34   "Disable this option to skip building the Qt5 / KF5 based GUI for heaptrack."
35   On
36 )
37
38 option(
39   TIZEN
40   "Tizen platform"
41   Off
42 )
43 add_definitions(-DTIZEN=$<BOOL:${TIZEN}>)
44
45 if(HEAPTRACK_BUILD_GUI)
46     find_package(Qt5 5.2.0 NO_MODULE OPTIONAL_COMPONENTS Widgets)
47     find_package(ECM 1.0.0 NO_MODULE)
48     if(Qt5_FOUND AND ECM_FOUND)
49         set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
50             find_package(KF5 COMPONENTS CoreAddons I18n ItemModels ThreadWeaver ConfigWidgets KIO)
51             find_package(KChart "2.6.0")
52             set_package_properties(KChart PROPERTIES TYPE RECOMMENDED PURPOSE "Required for the heaptrack_gui executable. Get it from the kdiagram module.")
53     endif()
54 endif()
55
56 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
57
58 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
59
60 include (CheckCXXSourceCompiles)
61 check_cxx_source_compiles(
62     "#include <unordered_map>
63     #include <atomic>
64     thread_local int tls;
65     int main() { return 0; }"
66     HAVE_CXX11_SUPPORT)
67
68 if (NOT HAVE_CXX11_SUPPORT)
69     message(FATAL_ERROR "Your compiler is too old and does not support the required C++11 features.")
70 endif()
71
72 check_cxx_source_compiles(
73     "#include <stdio_ext.h>
74     #include <fcntl.h>
75     #include <dlfcn.h>
76     #include <link.h>
77     int main() { return 0; }"
78     HAVE_LINUX_HEADERS)
79
80 if (NOT HAVE_LINUX_HEADERS)
81     message(FATAL_ERROR "You are missing some Linux headers required to compile heaptrack.")
82 endif()
83
84 check_cxx_source_compiles(
85     "#include <future>
86     std::future<int> f;
87     int main() { return 0; }"
88     HAVE_FUTURE_SUPPORT)
89
90 # cfree() does not exist in glibc 2.26+.
91 # See: https://bugs.kde.org/show_bug.cgi?id=383889
92 include(CheckSymbolExists)
93 check_symbol_exists(cfree malloc.h HAVE_CFREE)
94
95 set(BIN_INSTALL_DIR "bin")
96 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
97 set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
98 set(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/heaptrack/libexec")
99
100 file(RELATIVE_PATH LIBEXEC_REL_PATH
101     "${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
102     "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}")
103
104 file(RELATIVE_PATH LIB_REL_PATH
105     "${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
106     "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/heaptrack")
107
108 add_subdirectory(3rdparty)
109 add_subdirectory(src)
110 add_subdirectory(tests)
111
112 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)