-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (65 loc) · 2.6 KB
/
CMakeLists.txt
File metadata and controls
75 lines (65 loc) · 2.6 KB
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
cmake_minimum_required(VERSION 3.25)
project(cpptrace_th CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# ---------- options ----------
option(CPPTRACE_TH_BUILD_EXAMPLE "Build examples" OFF)
option(CPPTRACE_TH_PRINT_SNIPPETS "Print code snippets in trace" ON)
option(CPPTRACE_TH_ENABLE_SKIP "Enable skip regex" ON)
set(CPPTRACE_TH_SKIP_REGEX
[=[
\bstd::terminate\b]=]
CACHE STRING "Frames before matched regex (included) will be omitted")
option(CPPTRACE_TH_NO_ZSTD "Remove ZSTD support (speedup build)" ON)
# ---------- libdwarf and cpptrace ----------
include(FetchContent)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # allow setting options with `set`
if(CPPTRACE_TH_NO_ZSTD)
set(ENABLE_DECOMPRESSION FALSE)
set(BUILD_DWARFDUMP FALSE)
FetchContent_Declare(
libdwarf
GIT_REPOSITORY https://github.com/jeremy-rifkin/libdwarf-lite.git
GIT_TAG v0.11.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE TRUE SYSTEM)
FetchContent_MakeAvailable(libdwarf)
set(CPPTRACE_USE_EXTERNAL_LIBDWARF TRUE)
endif()
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v0.7.1
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
SYSTEM)
FetchContent_MakeAvailable(cpptrace)
# ---------- build ----------
add_library(cpptrace_th_options INTERFACE)
target_compile_definitions(
cpptrace_th_options
INTERFACE CPPTRACE_TH_PRINT_SNIPPETS="$<BOOL:${CPPTRACE_TH_PRINT_SNIPPETS}>"
CPPTRACE_TH_ENABLE_SKIP="$<BOOL:${CPPTRACE_TH_ENABLE_SKIP}>"
"CPPTRACE_TH_SKIP_REGEX=R\"regex(${CPPTRACE_TH_SKIP_REGEX})regex\"")
target_link_libraries(cpptrace_th_options INTERFACE cpptrace::cpptrace)
add_library(cpptrace_th_static STATIC register.cpp)
target_link_libraries(cpptrace_th_static PRIVATE cpptrace_th_options)
add_library(cpptrace_th_static_whole_archive INTERFACE)
target_link_libraries(
cpptrace_th_static_whole_archive
INTERFACE -Wl,--whole-archive cpptrace_th_static -Wl,--no-whole-archive)
add_library(cpptrace_th_shared SHARED register.cpp)
target_link_libraries(cpptrace_th_shared PRIVATE cpptrace_th_options)
add_library(cpptrace_th_shared_no_as_needed INTERFACE)
target_link_libraries(
cpptrace_th_shared_no_as_needed INTERFACE -Wl,--no-as-needed
cpptrace_th_shared -Wl,--as-needed)
if(CPPTRACE_TH_BUILD_EXAMPLE)
add_subdirectory(examples)
endif()
# ---------- export ----------
add_library(cpptrace_th::static ALIAS cpptrace_th_static_whole_archive)
add_library(cpptrace_th::shared ALIAS cpptrace_th_shared_no_as_needed)