1- Backward-cpp [ ![ badge ] ( https://img.shields.io/badge/ conan.io-backward%2F1.3.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC )] ( http ://www. conan.io/source/backward/1.3.0/Manu343726/testing )
1+ Backward-cpp [ ![ Conan Center ] ( https://img.shields.io/conan/v/backward-cpp )] ( https ://conan.io/center/recipes/backward-cpp )
22============
33
44Backward is a beautiful stack trace pretty printer for C++.
@@ -45,10 +45,26 @@ Note for [folly](https://github.com/facebook/folly) library users: must define `
4545
4646### Integration with CMake
4747
48- If you are using CMake and want to use its configuration abilities to save
49- you the trouble, you can easily integrate Backward, depending on how you obtained
48+ If you are using CMake and want to use its configuration abilities to save you
49+ the trouble, you can easily integrate Backward, depending on how you obtained
5050the library.
5151
52+ Notice that all approaches are equivalent in the way Backward is added to a
53+ CMake target, the difference is in how CMake is pointed to the Backward
54+ sources. Backward defines three targets:
55+
56+ - ` Backward::Interface ` is an interface target that brings compiler definition
57+ flags, include directory, and external libraries. This is all you need to use
58+ the ` backward.hpp ` header library.
59+ - ` Backward::Object ` brings ` Backward::Interface ` and ` backward.cpp ` as an
60+ ` OBJECT ` CMake library. This target cannot be exported, so it is not
61+ available when Backward is used via ` find_package ` .
62+ - ` Backward::Backward ` brings ` Backward::Interface ` and ` backward.cpp ` as
63+ either ` STATIC ` or ` SHARED ` library (depending on the ` BACKWARD_SHARED `
64+ option). This target is exported and always available, however note that the
65+ linker will not include unused objects from a static library, unless the
66+ ` -Wl,--whole-archive ` option (or similar) is used.
67+
5268#### With ` FetchContent() ` :
5369
5470If you are using a recent version of CMake, you can integrate ` backward ` via ` FetchContent ` like below:
@@ -58,47 +74,41 @@ include(FetchContent)
5874
5975# Also requires one of: libbfd (gnu binutils), libdwarf, libdw (elfutils)
6076FetchContent_Declare(backward
61- GIT_REPOSITORY https://github.com/bombela/backward-cpp
62- GIT_TAG v1.6)
77+ GIT_REPOSITORY https://github.com/bombela/backward-cpp
78+ GIT_TAG master # or a version tag, such as v1.6
79+ SYSTEM # optional, the Backward include directory will be treated as system directory
80+ )
6381FetchContent_MakeAvailable(backward)
6482
65- file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
66- add_executable(example ${SOURCES} ${BACKWARD_ENABLE}) # Notice the "BACKWARD_ENABLE" here
67- add_backward(example)
83+ # Add Backward to your target (either Backward::Interface, Backward::Object, or Backward::Backward)
84+ target_link_libraries(mytarget PUBLIC Backward::Interface)
6885```
6986
7087#### As a subdirectory:
7188
7289In this case you have a subdirectory containing the whole repository of Backward
73- (eg.: using git-submodules), in this case you can do:
90+ (e.g. using [ git-submodule] ( https://git-scm.com/book/en/v2/Git-Tools-Submodules ) ),
91+ in this case you can do:
7492
75- ```
93+ ``` cmake
7694add_subdirectory(/path/to/backward-cpp)
7795
78- # This will add backward.cpp to your target
79- add_executable(mytarget mysource.cpp ${BACKWARD_ENABLE})
80-
81- # This will add libraries, definitions and include directories needed by backward
82- # by setting each property on the target.
83- add_backward(mytarget)
96+ # Add Backward to your target (either Backward::Interface, Backward::Object, or Backward::Backward)
97+ target_link_libraries(mytarget PUBLIC Backward::Interface)
8498```
8599
86- #### Modifying CMAKE_MODULE_PATH
100+ #### Modifying ` CMAKE_MODULE_PATH ` :
87101
88102In this case you can have Backward installed as a subdirectory:
89103
90104```
91105list(APPEND CMAKE_MODULE_PATH /path/to/backward-cpp)
92106find_package(Backward)
93107
94- # This will add libraries, definitions and include directories needed by backward
95- # through an IMPORTED target.
96- target_link_libraries(mytarget PUBLIC Backward::Backward)
108+ # Add Backward to your target (either Backward::Interface or Backward::Backward)
109+ target_link_libraries(mytarget PUBLIC Backward::Interface)
97110```
98111
99- Notice that this is equivalent to using the the approach that uses ` add_subdirectory() ` ,
100- however it uses cmake's [ imported target] ( https://cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets ) mechanism.
101-
102112#### Installation through a regular package manager
103113
104114In this case you have obtained Backward through a package manager.
@@ -109,10 +119,10 @@ Packages currently available:
109119```
110120find_package(Backward)
111121
112- # This will add libraries, definitions and include directories needed by backward
113- # through an IMPORTED target.
114- target_link_libraries(mytarget PUBLIC Backward::Backward)
122+ # Add Backward to your target (either Backward::Interface or Backward::Backward)
123+ target_link_libraries(mytarget PUBLIC Backward::Interface)
115124```
125+
116126### Libraries to unwind the stack
117127
118128On Linux and macOS, backtrace can back-trace or "walk" the stack using the
@@ -422,8 +432,8 @@ struct ResolvedTrace: public Trace {
422432 struct SourceLoc {
423433 std::string function;
424434 std::string filename;
425- size_t line;
426- size_t col;
435+ unsigned line;
436+ unsigned col;
427437 };
428438
429439 // In which binary object this trace is located.
0 commit comments