Warning, /sdk/heaptrack/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 if (CMAKE_VERSION VERSION_LESS "2.8.12")
0002     cmake_minimum_required(VERSION 2.8.9)
0003     set(HEAPTRACK_BUILD_GUI OFF)
0004 elseif (CMAKE_VERSION VERSION_LESS "3.16.0")
0005     cmake_minimum_required(VERSION 2.8.12)
0006 else()
0007     cmake_minimum_required(VERSION 3.16.0)
0008 endif()
0009 
0010 project(heaptrack)
0011 enable_testing()
0012 
0013 if(NOT CMAKE_BUILD_TYPE)
0014   message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
0015   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
0016 endif()
0017 
0018 set(HEAPTRACK_VERSION_MAJOR 1)
0019 set(HEAPTRACK_VERSION_MINOR 4)
0020 set(HEAPTRACK_VERSION_PATCH 80)
0021 set(HEAPTRACK_LIB_VERSION 1.4.80)
0022 set(HEAPTRACK_LIB_SOVERSION 2)
0023 set(HEAPTRACK_FILE_FORMAT_VERSION 3)
0024 
0025 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
0026 
0027 option(APPIMAGE_BUILD "configure build for bundling in an appimage" OFF)
0028 
0029 set(REQUIRED_IN_APPIMAGE "")
0030 if (APPIMAGE_BUILD)
0031     set(REQUIRED_IN_APPIMAGE REQUIRED)
0032 endif()
0033 
0034 include(FeatureSummary)
0035 find_package(Boost 1.60.0 ${REQUIRED_IN_APPIMAGE} COMPONENTS system filesystem iostreams container)
0036 set_package_properties(Boost PROPERTIES TYPE RECOMMENDED PURPOSE "Boost container libraries can greatly improve performance (via pmr allocators)")
0037 find_package(Threads REQUIRED)
0038 find_package(ZLIB REQUIRED)
0039 
0040 if (${Boost_IOSTREAMS_FOUND})
0041     find_package(ZSTD ${REQUIRED_IN_APPIMAGE})
0042 
0043     include(CheckCXXSourceCompiles)
0044     include(CMakePushCheckState)
0045     cmake_push_check_state()
0046     set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS})
0047     set(CMAKE_REQUIRED_LIBRARIES ${Boost_LIBRARIES})
0048     check_cxx_source_compiles("#include <boost/iostreams/filter/zstd.hpp>
0049         int main() { boost::iostreams::zstd_decompressor(); return 0; }"
0050         BOOST_IOSTREAMS_HAS_ZSTD
0051     )
0052     cmake_pop_check_state()
0053 endif()
0054 set_package_properties(ZSTD PROPERTIES TYPE RECOMMENDED PURPOSE "Zstandard offers better (de)compression performance compared with gzip/zlib, making heaptrack faster and datafiles smaller.")
0055 
0056 if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
0057     set(HEAPTRACK_BUILD_TRACK_DEFAULT ON)
0058     set(HEAPTRACK_BUILD_INTERPRET_DEFAULT ON)
0059 else()
0060     set(HEAPTRACK_BUILD_TRACK_DEFAULT OFF)
0061     set(HEAPTRACK_BUILD_INTERPRET_DEFAULT OFF)
0062 endif()
0063 
0064 option(
0065   HEAPTRACK_BUILD_TRACK
0066   "Disable this option to skip building the tracker part for heaptrack, e.g. to only build the GUI."
0067   ${HEAPTRACK_BUILD_TRACK_DEFAULT}
0068 )
0069 
0070 option(
0071   HEAPTRACK_BUILD_BACKTRACE
0072   "Enable this option to build libbacktrace. It will be enabled implicitly if HEAPTRACK_BUILD_INTERPRET is enabled."
0073   OFF
0074 )
0075 
0076 option(
0077   HEAPTRACK_BUILD_INTERPRET
0078   "Disable this option to skip building the interpret part for heaptrack."
0079   ${HEAPTRACK_BUILD_INTERPRET_DEFAULT}
0080 )
0081 
0082 if (HEAPTRACK_BUILD_INTERPRET)
0083     set(HEAPTRACK_BUILD_BACKTRACE ON)
0084 endif()
0085 
0086 if (CMAKE_CROSSCOMPILING)
0087     set(HEAPTRACK_BUILD_ANALYZE_DEFAULT OFF)
0088 else()
0089     set(HEAPTRACK_BUILD_ANALYZE_DEFAULT ON)
0090 endif()
0091 
0092 option(
0093   HEAPTRACK_BUILD_PRINT
0094   "Disable this option to skip building heaptrack_print, e.g. when you're cross-compiling."
0095   ${HEAPTRACK_BUILD_ANALYZE_DEFAULT}
0096 )
0097 
0098 option(
0099   HEAPTRACK_BUILD_GUI
0100   "Disable this option to skip building the Qt5 / KF5 based GUI for heaptrack."
0101   ${HEAPTRACK_BUILD_ANALYZE_DEFAULT}
0102 )
0103 
0104 option(
0105   HEAPTRACK_USE_LIBUNWIND
0106   "Define preferred unwind functionality - Libunwind as ON and unwind_tables as OFF."
0107   ON
0108 )
0109 
0110 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
0111 
0112 if (NOT MSVC)
0113     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic")
0114 endif()
0115 
0116 set(CMAKE_CXX_STANDARD 14)
0117 set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
0118 
0119 include (CheckCXXSourceCompiles)
0120 
0121 # cfree() does not exist in glibc 2.26+.
0122 # See: https://bugs.kde.org/show_bug.cgi?id=383889
0123 include(CheckSymbolExists)
0124 check_symbol_exists(cfree malloc.h HAVE_CFREE)
0125 check_symbol_exists(valloc stdlib.h HAVE_VALLOC)
0126 
0127 set(BIN_INSTALL_DIR "bin")
0128 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
0129 set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
0130 set(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/heaptrack/libexec")
0131 
0132 file(RELATIVE_PATH LIBEXEC_REL_PATH
0133     "${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
0134     "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}")
0135 
0136 file(RELATIVE_PATH LIB_REL_PATH
0137     "${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}"
0138     "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/heaptrack")
0139 
0140 set(ECM_ENABLE_SANITIZERS "" CACHE STRING "semicolon-separated list of sanitizers to enable for code that is not injected into client applications")
0141 
0142 if (ECM_ENABLE_SANITIZERS)
0143     find_package(ECM 1.0.0 NO_MODULE)
0144     if (ECM_FOUND)
0145         set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
0146     endif()
0147 endif()
0148 
0149 if (HEAPTRACK_BUILD_TRACK)
0150     if (HEAPTRACK_USE_LIBUNWIND)
0151         find_package(Libunwind REQUIRED)
0152     endif()
0153 
0154     check_cxx_source_compiles(
0155         "#ifdef __linux__
0156         #include <stdio_ext.h>
0157         #endif
0158         #include <fcntl.h>
0159         #include <dlfcn.h>
0160         #include <link.h>
0161         int main() { return 0; }"
0162         HAVE_LINUX_HEADERS)
0163 
0164     if (NOT HAVE_LINUX_HEADERS)
0165         message(FATAL_ERROR "You are missing some Linux/BSD headers required to compile heaptrack.")
0166     endif()
0167 endif()
0168 
0169 add_subdirectory(3rdparty)
0170 include_directories(3rdparty/robin-map/include)
0171 add_subdirectory(src)
0172 add_subdirectory(tests)
0173 
0174 # Let releaseme know about this:
0175 # SKIP_PO_INSTALL
0176 # (KF5I18n is optional in src/analyze/CMakeLists.txt...)
0177 
0178 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)