Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ else()
)
endif()

add_subdirectory(third_party)

# Target that we can modify (can't modify ALIAS targets)
# Target name should not be the same as ${PROJECT_NAME}, causes add_subdirectory issues
set(target_name "cpptrace-lib")
Expand Down Expand Up @@ -347,26 +349,6 @@ if(CPPTRACE_GET_SYMBOLS_WITH_LIBDWARF)
endif()
else()
include(FetchContent)
# First, dependencies: Zstd and zlib (currently relying on system zlib)
if(CPPTRACE_USE_EXTERNAL_ZSTD)
find_package(zstd)
else()
cmake_policy(SET CMP0074 NEW)
set(ZSTD_BUILD_PROGRAMS OFF)
set(ZSTD_BUILD_CONTRIB OFF)
set(ZSTD_BUILD_TESTS OFF)
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_LEGACY_SUPPORT OFF)
FetchContent_Declare(
zstd
SOURCE_SUBDIR build/cmake
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
URL "${CPPTRACE_ZSTD_URL}"
)
FetchContent_MakeAvailable(zstd)
endif()
# Libdwarf itself
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(PIC_ALWAYS TRUE)
set(BUILD_DWARFDUMP FALSE)
Expand Down
9 changes: 0 additions & 9 deletions benchmarking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ set(
${warning_options} $<$<CXX_COMPILER_ID:GNU>:-Wno-infinite-recursion>
)

include(FetchContent)
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_Declare(
googlebench
GIT_REPOSITORY "https://github.com/google/benchmark.git"
GIT_TAG 12235e24652fc7f809373e7c11a5f73c5763fc4c # v1.9.0
)
FetchContent_MakeAvailable(googlebench)

add_executable(benchmark_unwinding unwinding.cpp)
target_compile_features(benchmark_unwinding PRIVATE cxx_std_20)
target_link_libraries(benchmark_unwinding PRIVATE ${target_name} benchmark::benchmark)
13 changes: 2 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function(test_cpptrace)
)

target_compile_features("${CPPTRACE_TEST_NAME}" PRIVATE cxx_std_11)
target_link_libraries("${CPPTRACE_TEST_NAME}" PRIVATE ${target_name} GTest::gtest_main GTest::gmock_main)
target_link_libraries("${CPPTRACE_TEST_NAME}" PRIVATE ${target_name} gtest gmock gtest_main)
target_compile_definitions("${CPPTRACE_TEST_NAME}" PRIVATE ${CPPTRACE_DEFINE})

target_compile_options("${CPPTRACE_TEST_NAME}" PRIVATE ${warning_options} $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-pedantic -Wno-attributes>)
Expand All @@ -123,18 +123,9 @@ endfunction()

# primarily a workaround for github actions issue https://github.com/actions/runner-images/issues/8659
if(NOT CPPTRACE_SKIP_UNIT)
if(CPPTRACE_USE_EXTERNAL_GTEST)
find_package(GTest)
else()
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # v1.12.1, last to support C++11
)
if(NOT CPPTRACE_USE_EXTERNAL_GTEST)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()

test_cpptrace(TEST_NAME unittest)
Expand Down
13 changes: 13 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include(FetchContent)

set(CPPTRACE_THIRD_PARTY_DECLARATIONS)

function(declaration_is_unique declaration)
list(FIND "${declaration}" CPPTRACE_THIRD_PARTY_DECLARATIONS declaration_index)
if(NOT declaration_index EQUAL -1)
message(FATAL_ERROR "${declaration} was previously added to CPPTRACE_THIRD_PARTY_DECLARATIONS (index ${declaration_index})")
endif()
endfunction()

include("${CMAKE_CURRENT_SOURCE_DIR}/declare_dependencies.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/acquire_dependencies.cmake")
3 changes: 3 additions & 0 deletions third_party/acquire_dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
foreach(package IN LISTS CPPTRACE_THIRD_PARTY_DECLARATIONS)
FetchContent_MakeAvailable(${package})
endforeach()
14 changes: 14 additions & 0 deletions third_party/benchmark/declare_benchmark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if(CPPTRACE_BUILD_BENCHMARKING)
set(package_name "googlebench")
declaration_is_unique("${package_name}")
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_Declare(
"${package_name}"
GIT_REPOSITORY "https://github.com/google/benchmark.git"
GIT_TAG 12235e24652fc7f809373e7c11a5f73c5763fc4c # v1.9.0
OVERRIDE_FIND_PACKAGE
SYSTEM
)

list(APPEND CPPTRACE_THIRD_PARTY_DECLARATIONS "${package_name}")
endif()
5 changes: 5 additions & 0 deletions third_party/declare_dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include("${CMAKE_CURRENT_SOURCE_DIR}/benchmark/declare_benchmark.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/fmt/declare_fmt.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/googletest/declare_googletest.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/lyra/declare_lyra.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/zstd/declare_zstd.cmake")
14 changes: 14 additions & 0 deletions third_party/fmt/declare_fmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if(CPPTRACE_BUILD_TOOLS)
set(package_name "fmt")
declaration_is_unique("${package_name}")
FetchContent_Declare(
"${package_name}"
GIT_SHALLOW TRUE
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "e69e5f977d458f2650bb346dadf2ad30c5320281" # v10.2.1
OVERRIDE_FIND_PACKAGE
SYSTEM
)

list(APPEND CPPTRACE_THIRD_PARTY_DECLARATIONS "${package_name}")
endif()
20 changes: 20 additions & 0 deletions third_party/googletest/declare_googletest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if(CPPTRACE_SKIP_UNIT)
return()
endif()

if(CPPTRACE_USE_EXTERNAL_GTEST)
message(STATUS "Using external GoogleTest")
find_package(GTest REQUIRED)
else()
set(package_name "googletest")
declaration_is_unique("${package_name}")
FetchContent_Declare(
"${package_name}"
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG tags/release-1.12.1 # last to support C++11
OVERRIDE_FIND_PACKAGE
SYSTEM
)

list(APPEND CPPTRACE_THIRD_PARTY_DECLARATIONS googletest)
endif()
14 changes: 14 additions & 0 deletions third_party/lyra/declare_lyra.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if(CPPTRACE_BUILD_TOOLS)
set(package_name "lyra")
declaration_is_unique("${package_name}")
FetchContent_Declare(
"${package_name}"
GIT_SHALLOW TRUE
GIT_REPOSITORY "https://github.com/bfgroup/Lyra.git"
GIT_TAG "ee3c076fa6b9d64c9d249a21f5b9b5a8dae92cd8"
OVERRIDE_FIND_PACKAGE
SYSTEM
)

list(APPEND CPPTRACE_THIRD_PARTY_DECLARATIONS lyra)
endif()
32 changes: 32 additions & 0 deletions third_party/zstd/declare_zstd.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if(NOT CPPTRACE_GET_SYMBOLS_WITH_LIBDWARF OR NOT CPPTRACE_USE_EXTERNAL_LIBDWARF)
return()
endif()

if(CPPTRACE_USE_EXTERNAL_ZSTD)
message(STATUS "Using external zstd")
find_package(zstd REQUIRED)
else()
# libdwarf depends on zstd, so it's a logic error for libdwarf to already be in our declaration
# list.
declaration_is_unique(libdwarf)

cmake_policy(SET CMP0074 NEW)
set(ZSTD_BUILD_PROGRAMS OFF)
set(ZSTD_BUILD_CONTRIB OFF)
set(ZSTD_BUILD_TESTS OFF)
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_LEGACY_SUPPORT OFF)
set(package_name "zstd")
declaration_is_unique("${package_name}")
FetchContent_Declare(
"${package_name}"
SOURCE_SUBDIR build/cmake
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
URL "${CPPTRACE_ZSTD_URL}"
OVERRIDE_FIND_PACKAGE
SYSTEM
)

list(APPEND CPPTRACE_THIRD_PARTY_DECLARATIONS zstd)
endif()
18 changes: 0 additions & 18 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
include(FetchContent)

FetchContent_Declare(
lyra
GIT_SHALLOW TRUE
GIT_REPOSITORY "https://github.com/bfgroup/Lyra.git"
GIT_TAG "ee3c076fa6b9d64c9d249a21f5b9b5a8dae92cd8"
)
FetchContent_MakeAvailable(lyra)

FetchContent_Declare(
fmt
GIT_SHALLOW TRUE
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "e69e5f977d458f2650bb346dadf2ad30c5320281" # v10.2.1
)
FetchContent_MakeAvailable(fmt)

set(
COMMON_LIBS
cpptrace::cpptrace
Expand Down
Loading