Enabled backward-cpp for debug build on Linux

This commit is contained in:
Bartek Kryza
2023-02-19 00:37:15 +01:00
parent bdf9a7e18f
commit 35c4c210b1
5 changed files with 24 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ jobs:
- name: Update package database
run: sudo apt -y update
- name: Install deps
run: sudo apt -y install git make gcc-10 g++-10 ccache cmake libyaml-cpp-dev llvm-12 clang-12 libclang-12-dev libclang-cpp12-dev clang-format-12 lcov zlib1g-dev
run: sudo apt -y install git make pkg-config gcc-10 g++-10 ccache cmake libyaml-cpp-dev llvm-12 clang-12 libclang-12-dev libclang-cpp12-dev clang-format-12 lcov zlib1g-dev libunwind-dev libdw-dev
- name: Select g++ version
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10

View File

@@ -14,6 +14,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_FIND_DEBUG_MODE OFF)
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
#
# C++ setup
#
@@ -155,6 +159,17 @@ endif()
link_directories(${LLVM_LIBRARY_DIR} ${YAML_CPP_LIBRARY_DIR})
#
# Setup libdw and libunwind
#
if(LINUX AND (CMAKE_BUILD_TYPE MATCHES Debug))
find_package(PkgConfig REQUIRED)
pkg_check_modules(DW REQUIRED IMPORTED_TARGET libdw)
pkg_check_modules(UNWIND REQUIRED IMPORTED_TARGET libunwind)
set(BACKWARD_CPP_LIBRARIES PkgConfig::DW PkgConfig::UNWIND)
set(ENABLE_BACKWARD_CPP -DENABLE_BACKWARD_CPP)
endif()
#
# Setup thirdparty sources
#

View File

@@ -422,6 +422,7 @@ This project relies on the following great tools:
* [glob](https://github.com/p-ranav/glob) - Unix style path expansion for C++
* [CLI11](https://github.com/CLIUtils/CLI11) - command line parser for C++
* [inja](https://github.com/pantor/inja) - a template engine for modern C++
* [backward-cpp](https://github.com/bombela/backward-cpp) - stack trace pretty printer for C++
## Contributing

View File

@@ -43,10 +43,13 @@ target_compile_options(clang-uml PRIVATE
-Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field
-Wno-deprecated-declarations>
$<$<CXX_COMPILER_ID:MSVC>:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>)
target_compile_definitions(clang-uml PRIVATE
${ENABLE_BACKWARD_CPP})
target_link_libraries(clang-uml
${YAML_CPP_LIBRARIES}
${LIBTOOLING_LIBS}
${MSVC_LIBRARIES}
${BACKWARD_CPP_LIBRARIES}
clang-umllib
Threads::Threads)

View File

@@ -24,7 +24,9 @@
#include "util/util.h"
#include "version.h"
#ifndef NDEBUG
#ifdef ENABLE_BACKWARD_CPP
#define BACKWARD_HAS_DW 1
#define BACKWARD_HAS_LIBUNWIND 1
#include <backward-cpp/backward.hpp>
#endif
@@ -40,7 +42,7 @@
#include <iostream>
#include <util/thread_pool_executor.h>
#ifndef NDEBUG
#ifdef ENABLE_BACKWARD_CPP
namespace backward {
backward::SignalHandling sh; // NOLINT
} // namespace backward