-
-
Notifications
You must be signed in to change notification settings - Fork 203
/
CMakeLists.txt
181 lines (148 loc) · 5.42 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
if (CMAKE_VERSION VERSION_LESS "2.8.12")
cmake_minimum_required(VERSION 2.8.9)
set(HEAPTRACK_BUILD_GUI OFF)
elseif (CMAKE_VERSION VERSION_LESS "3.16.0")
cmake_minimum_required(VERSION 2.8.12)
else()
cmake_minimum_required(VERSION 3.16.0)
endif()
project(heaptrack)
enable_testing()
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
endif()
set(HEAPTRACK_VERSION_MAJOR 1)
set(HEAPTRACK_VERSION_MINOR 5)
set(HEAPTRACK_VERSION_PATCH 80)
set(HEAPTRACK_LIB_VERSION 1.5.80)
set(HEAPTRACK_LIB_SOVERSION 2)
set(HEAPTRACK_FILE_FORMAT_VERSION 3)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(APPIMAGE_BUILD "configure build for bundling in an appimage" OFF)
set(REQUIRED_IN_APPIMAGE "")
if (APPIMAGE_BUILD)
set(REQUIRED_IN_APPIMAGE REQUIRED)
endif()
include(FeatureSummary)
find_package(Boost 1.60.0 ${REQUIRED_IN_APPIMAGE} COMPONENTS system filesystem iostreams container)
set_package_properties(Boost PROPERTIES TYPE RECOMMENDED PURPOSE "Boost container libraries can greatly improve performance (via pmr allocators)")
find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)
if (${Boost_IOSTREAMS_FOUND})
find_package(ZSTD ${REQUIRED_IN_APPIMAGE})
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${Boost_LIBRARIES})
check_cxx_source_compiles("#include <boost/iostreams/filter/zstd.hpp>
int main() { boost::iostreams::zstd_decompressor(); return 0; }"
BOOST_IOSTREAMS_HAS_ZSTD
)
cmake_pop_check_state()
endif()
set_package_properties(ZSTD PROPERTIES TYPE RECOMMENDED PURPOSE "Zstandard offers better (de)compression performance compared with gzip/zlib, making heaptrack faster and datafiles smaller.")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(HEAPTRACK_BUILD_TRACK_DEFAULT ON)
set(HEAPTRACK_BUILD_INTERPRET_DEFAULT ON)
else()
set(HEAPTRACK_BUILD_TRACK_DEFAULT OFF)
set(HEAPTRACK_BUILD_INTERPRET_DEFAULT OFF)
endif()
option(
HEAPTRACK_BUILD_TRACK
"Disable this option to skip building the tracker part for heaptrack, e.g. to only build the GUI."
${HEAPTRACK_BUILD_TRACK_DEFAULT}
)
option(
HEAPTRACK_BUILD_INTERPRET
"Disable this option to skip building the interpret part for heaptrack."
${HEAPTRACK_BUILD_INTERPRET_DEFAULT}
)
if (CMAKE_CROSSCOMPILING)
set(HEAPTRACK_BUILD_ANALYZE_DEFAULT OFF)
else()
set(HEAPTRACK_BUILD_ANALYZE_DEFAULT ON)
endif()
option(
HEAPTRACK_BUILD_PRINT
"Disable this option to skip building heaptrack_print, e.g. when you're cross-compiling."
${HEAPTRACK_BUILD_ANALYZE_DEFAULT}
)
option(
HEAPTRACK_BUILD_GUI
"Disable this option to skip building the Qt / KDE Frameworks based GUI for heaptrack."
${HEAPTRACK_BUILD_ANALYZE_DEFAULT}
)
option(
HEAPTRACK_USE_QT6
"Use Qt6/KF6 when building the Qt / KDE Frameworks based GUI for heaptrack."
OFF
)
if(HEAPTRACK_USE_QT6)
set(QT_VERSION_MAJOR 6)
# possibly works with older Qt6, but I didn't test that yet
set(QT_MIN_VERSION 6.5.0)
else()
set(QT_VERSION_MAJOR 5)
set(QT_MIN_VERSION 5.10.0)
endif()
option(
HEAPTRACK_USE_LIBUNWIND
"Define preferred unwind functionality - Libunwind as ON and unwind_tables as OFF."
ON
)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror=undef -Werror=return-type")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
include (CheckCXXSourceCompiles)
# cfree() does not exist in glibc 2.26+.
# See: https://bugs.kde.org/show_bug.cgi?id=383889
include(CheckSymbolExists)
check_symbol_exists(cfree malloc.h HAVE_CFREE)
check_symbol_exists(valloc stdlib.h HAVE_VALLOC)
set(BIN_INSTALL_DIR "bin")
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
set(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/heaptrack/libexec")
file(RELATIVE_PATH LIBEXEC_REL_PATH
"${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}")
file(RELATIVE_PATH LIB_REL_PATH
"${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/heaptrack")
set(ECM_ENABLE_SANITIZERS "" CACHE STRING "semicolon-separated list of sanitizers to enable for code that is not injected into client applications")
if (ECM_ENABLE_SANITIZERS)
find_package(ECM 1.0.0 NO_MODULE)
if (ECM_FOUND)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
endif()
endif()
if (HEAPTRACK_BUILD_TRACK)
if (HEAPTRACK_USE_LIBUNWIND)
find_package(Libunwind REQUIRED)
endif()
check_cxx_source_compiles(
"#ifdef __linux__
#include <stdio_ext.h>
#endif
#include <fcntl.h>
#include <dlfcn.h>
#include <link.h>
int main() { return 0; }"
HAVE_LINUX_HEADERS)
if (NOT HAVE_LINUX_HEADERS)
message(FATAL_ERROR "You are missing some Linux/BSD headers required to compile heaptrack.")
endif()
endif()
add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(tests)
# Let releaseme know about this:
# SKIP_PO_INSTALL
# (KF5I18n is optional in src/analyze/CMakeLists.txt...)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)