Force shared library under libbacktrace, allow shared or static otherwise (#22)
This commit is contained in:
parent
144ab89871
commit
02dda255d2
4
.github/workflows/cmake-integration.yml
vendored
4
.github/workflows/cmake-integration.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
tag=$(git rev-parse --abbrev-ref HEAD)
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=On
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug
|
||||
sudo make -j install
|
||||
cd ../..
|
||||
cp -rv cpptrace/test/findpackage-integration .
|
||||
@ -64,7 +64,7 @@ jobs:
|
||||
tag=$(git rev-parse --abbrev-ref HEAD)
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=On
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug
|
||||
sudo make -j install
|
||||
cd ../..
|
||||
cp -rv cpptrace/test/findpackage-integration .
|
||||
|
||||
8
.github/workflows/performance-tests.yml
vendored
8
.github/workflows/performance-tests.yml
vendored
@ -35,13 +35,12 @@ jobs:
|
||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||
${{matrix.config}} \
|
||||
-DCPPTRACE_BACKTRACE_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/include/backtrace.h \
|
||||
-DCPPTRACE_BUILD_SPEEDTEST=On \
|
||||
-DBUILD_SHARED_LIBS=On
|
||||
-DCPPTRACE_BUILD_SPEEDTEST=On
|
||||
make -j
|
||||
- name: test
|
||||
working-directory: build
|
||||
run: |
|
||||
./speedtest | python3 ../ci/speedtest.py ${{matrix.config}}
|
||||
./speedtest | python3 ../ci/speedtest.py ${{matrix.compiler}} ${{matrix.config}}
|
||||
# TODO: For some reason this is slow on github's runner
|
||||
#performancetest-windows:
|
||||
# runs-on: windows-2019
|
||||
@ -67,8 +66,7 @@ jobs:
|
||||
# -DCMAKE_CXX_COMPILER=${{matrix.compiler}} `
|
||||
# -DCMAKE_CXX_STANDARD=${{matrix.std}} `
|
||||
# ${{matrix.config}} `
|
||||
# -DCPPTRACE_BUILD_SPEEDTEST=On `
|
||||
# -DBUILD_SHARED_LIBS=On
|
||||
# -DCPPTRACE_BUILD_SPEEDTEST=On
|
||||
# msbuild .\cpptrace.sln
|
||||
# - name: test
|
||||
# working-directory: build
|
||||
|
||||
@ -10,46 +10,10 @@ project(
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
file(GLOB_RECURSE sources src/*.cpp)
|
||||
add_library(cpptrace ${sources} include/cpptrace/cpptrace.hpp)
|
||||
|
||||
target_include_directories(
|
||||
cpptrace
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/>
|
||||
)
|
||||
|
||||
# TODO
|
||||
target_compile_features(
|
||||
cpptrace
|
||||
PUBLIC
|
||||
cxx_std_11
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
cpptrace
|
||||
PROPERTIES
|
||||
CXX_STANDARD_REQUIRED TRUE
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
target_compile_options(
|
||||
cpptrace
|
||||
PRIVATE
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Werror=return-type -Wshadow -Wundef>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wuseless-cast -Wnonnull-compare>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /permissive->
|
||||
)
|
||||
|
||||
option(CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE "" OFF)
|
||||
option(CPPTRACE_FULL_TRACE_WITH_STACKTRACE "" OFF)
|
||||
|
||||
@ -252,6 +216,50 @@ else()
|
||||
#message(STATUS "Manual demangling back-end specified")
|
||||
endif()
|
||||
|
||||
# =============================================== Now define the library ===============================================
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
file(GLOB_RECURSE sources src/*.cpp)
|
||||
|
||||
# TODO: This feels like a hack.
|
||||
if(CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE OR CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
|
||||
add_library(cpptrace SHARED ${sources} include/cpptrace/cpptrace.hpp)
|
||||
else()
|
||||
add_library(cpptrace ${sources} include/cpptrace/cpptrace.hpp)
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
cpptrace
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/>
|
||||
)
|
||||
|
||||
# TODO
|
||||
target_compile_features(
|
||||
cpptrace
|
||||
PUBLIC
|
||||
cxx_std_11
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
cpptrace
|
||||
PROPERTIES
|
||||
CXX_STANDARD_REQUIRED TRUE
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
target_compile_options(
|
||||
cpptrace
|
||||
PRIVATE
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Werror=return-type -Wshadow -Wundef>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wuseless-cast -Wnonnull-compare>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /permissive->
|
||||
)
|
||||
|
||||
# =============================================== Apply options to build ===============================================
|
||||
|
||||
function(check_backtrace_error)
|
||||
@ -369,13 +377,6 @@ endif()
|
||||
|
||||
# ======================================================================================================================
|
||||
|
||||
#target_link_libraries(
|
||||
# cpptrace
|
||||
# PRIVATE
|
||||
# #$<$<CXX_COMPILER_ID:MSVC>:dbghelp>
|
||||
# #${CMAKE_DL_LIBS}
|
||||
#)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "")
|
||||
message(FATAL_ERROR "Setting CMAKE_BUILD_TYPE is required")
|
||||
endif()
|
||||
|
||||
@ -62,7 +62,7 @@ git clone https://github.com/jeremy-rifkin/cpptrace.git
|
||||
# optional: git checkout <HASH or TAG>
|
||||
mkdir cpptrace/build
|
||||
cd cpptrace/build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||
make -j
|
||||
sudo make install
|
||||
```
|
||||
@ -95,7 +95,7 @@ git clone https://github.com/jeremy-rifkin/cpptrace.git
|
||||
# optional: git checkout <HASH or TAG>
|
||||
mkdir cpptrace/build
|
||||
cd cpptrace/build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||
msbuild cpptrace.sln
|
||||
msbuild INSTALL.vcxproj
|
||||
```
|
||||
@ -113,7 +113,7 @@ git clone https://github.com/jeremy-rifkin/cpptrace.git
|
||||
# optional: git checkout <HASH or TAG>
|
||||
mkdir cpptrace/build
|
||||
cd cpptrace/build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DCMAKE_INSTALL_PREFIX=$HOME/wherever
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/wherever
|
||||
make -j
|
||||
sudo make install
|
||||
```
|
||||
|
||||
@ -12,7 +12,10 @@ def main():
|
||||
|
||||
dwarf4 = any(["DWARF4" in arg for arg in sys.argv[1:]])
|
||||
dwarf5 = any(["DWARF5" in arg for arg in sys.argv[1:]])
|
||||
expect_slow = dwarf4
|
||||
clang = any(["clang" in arg for arg in sys.argv[1:]])
|
||||
# Somehow -gdwarf-4 clang is fast after a completely unrelated PR? Weird. Something to do with static linking...?
|
||||
# https://github.com/jeremy-rifkin/cpptrace/pull/22
|
||||
expect_slow = dwarf4 and not clang
|
||||
|
||||
threshold = 100 # ms
|
||||
|
||||
|
||||
@ -157,8 +157,7 @@ def build(matrix):
|
||||
f"-D{matrix['symbols']}=On",
|
||||
f"-D{matrix['demangle']}=On",
|
||||
"-DCPPTRACE_BACKTRACE_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/include/backtrace.h",
|
||||
"-DCPPTRACE_BUILD_TEST=On",
|
||||
"-DBUILD_SHARED_LIBS=On"
|
||||
"-DCPPTRACE_BUILD_TEST=On"
|
||||
]
|
||||
if matrix['symbols'] == "CPPTRACE_GET_SYMBOLS_WITH_LIBDL":
|
||||
args.append("-DCPPTRACE_BUILD_TEST_RDYNAMIC=On")
|
||||
@ -175,8 +174,7 @@ def build(matrix):
|
||||
f"-D{matrix['unwind']}=On",
|
||||
f"-D{matrix['symbols']}=On",
|
||||
f"-D{matrix['demangle']}=On",
|
||||
"-DCPPTRACE_BUILD_TEST=On",
|
||||
"-DBUILD_SHARED_LIBS=On"
|
||||
"-DCPPTRACE_BUILD_TEST=On"
|
||||
]
|
||||
if matrix["compiler"] == "g++":
|
||||
args.append("-GUnix Makefiles")
|
||||
@ -196,8 +194,7 @@ def build_full_or_auto(matrix):
|
||||
f"-DCMAKE_CXX_COMPILER={matrix['compiler']}",
|
||||
f"-DCMAKE_CXX_STANDARD={matrix['std']}",
|
||||
f"-DCPPTRACE_BACKTRACE_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/include/backtrace.h",
|
||||
"-DCPPTRACE_BUILD_TEST=On",
|
||||
"-DBUILD_SHARED_LIBS=On"
|
||||
"-DCPPTRACE_BUILD_TEST=On"
|
||||
]
|
||||
if matrix["config"] != "":
|
||||
args.append(f"{matrix['config']}")
|
||||
@ -211,8 +208,7 @@ def build_full_or_auto(matrix):
|
||||
f"-DCMAKE_BUILD_TYPE={matrix['target']}",
|
||||
f"-DCMAKE_CXX_COMPILER={matrix['compiler']}",
|
||||
f"-DCMAKE_CXX_STANDARD={matrix['std']}",
|
||||
"-DCPPTRACE_BUILD_TEST=On",
|
||||
"-DBUILD_SHARED_LIBS=On"
|
||||
"-DCPPTRACE_BUILD_TEST=On"
|
||||
]
|
||||
if matrix["config"] != "":
|
||||
args.append(f"{matrix['config']}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user