1
1
# Project
2
2
cmake_minimum_required (VERSION 3.0 FATAL_ERROR)
3
3
project (heapusage VERSION 1.0 LANGUAGES C CXX)
4
- set (COMMON_FLAGS "-funwind-tables -g -Wall -Wextra -Wpedantic -Wshadow -Wpointer-arith -Wcast-qual \
5
- -Wno-missing-braces -Wswitch-default -Wcast-align -Wunreachable-code -Wundef \
6
- -Wuninitialized" )
4
+ set (COMMON_FLAGS "-funwind-tables -g -Wall -Wextra -Wpedantic -Wshadow -Wpointer-arith \
5
+ -Wcast-qual - Wno-missing-braces -Wswitch-default -Wcast-align \
6
+ -Wunreachable-code - Wuninitialized" )
7
7
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_FLAGS} -Wstrict-prototypes \
8
8
-Wmissing-prototypes" )
9
9
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} " )
@@ -13,22 +13,19 @@ set(CMAKE_CXX_STANDARD 11)
13
13
set (CMAKE_CXX_STANDARD_REQUIRED ON )
14
14
set (CMAKE_POSITION_INDEPENDENT_CODE ON )
15
15
16
- # Optional dependency - binutils / binutils-dev - for filename/line-numbers in callstacks
17
- include (FindPackageHandleStandardArgs)
18
- find_path (BFD_INCLUDE_PATH bfd.h PATH /usr/include /usr/local/include /usr/local/opt/*/include )
19
- find_library (BFD_LIBRARIES bfd PATH /lib /usr/lib /usr/local/lib /usr/local/opt/*/lib)
20
- find_package_handle_standard_args(BFD DEFAULT_MSG BFD_LIBRARIES BFD_INCLUDE_PATH)
21
- if (BFD_FOUND)
22
- set (EXTRA_LIBRARIES "${BFD_LIBRARIES} " )
23
- include_directories ("ext/backward-cpp" ${BFD_INCLUDE_DIR} )
24
- add_definitions (-DHAS_BFD)
25
- endif ()
26
-
27
16
# Library
28
17
add_library (heapusage SHARED src/humain.cpp src/hulog.cpp src/humalloc.cpp)
29
18
target_compile_features (heapusage PRIVATE cxx_variadic_templates)
30
19
install (TARGETS heapusage LIBRARY DESTINATION lib)
31
- target_link_libraries (heapusage ${EXTRA_LIBRARIES} pthread dl)
20
+ target_link_libraries (heapusage pthread dl)
21
+
22
+ # Dependency backward-cpp providing more detailed stacktraces on Linux, when
23
+ # either of the following is present (only ONE needed):
24
+ # libbfd - sudo apt install binutils-dev
25
+ # libdw - sudo apt install libdw-dev
26
+ # libdwarf - sudo apt install libdwarf-dev
27
+ add_subdirectory (ext /backward-cpp)
28
+ add_backward(heapusage)
32
29
33
30
# Utility
34
31
configure_file (src/heapusage ${CMAKE_CURRENT_BINARY_DIR} /heapusage COPYONLY )
0 commit comments