This allows using each definition (resulting from BackwardConfig.cmake)
separately, e.g., in conjunction with cmake's configure_file() command
and thus can be defined in a cmake-generated source file before a build.
Example:
Config.h.in
===========
#cmakedefine01 BACKWARD_HAS_UNWIND
#cmakedefine01 BACKWARD_HAS_BACKTRACE
#cmakedefine01 BACKWARD_HAS_BACKTRACE_SYMBOL
#cmakedefine01 BACKWARD_HAS_DW
#cmakedefine01 BACKWARD_HAS_BFD
#cmakedefine01 BACKWARD_HAS_DWARF
CMakeLists.txt:
===============
include(BackwardConfig)
configure_file( "${PROJECT_SOURCE_DIR}/Config.h.in"
"${PROJECT_BINARY_DIR}/Config.h" )
SomeProjectFile.C:
==================
#include "Config.h" // generated by cmake based on Config.h.in
#include "backward.hpp" // backward-cpp now configured based on BackwardConfig.cmake
using namespace backward;
StackTrace st; st.load_here(32);
Printer p; p.print(st);
On some distributions, libbfd is only available as static library. E.g.
on OpenSuse Leap 42.2, there are these two files:
libbfd.a
libbfd-2.28-system.so
backward-cpp, when attempting to link to bfd, will select the static
library and fail b/c there are undefined references to symbols from
libiberty/libz:
```
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/libbfd.a(elflink.o):
In function `elf_link_add_object_symbols':
/home/abuild/rpmbuild/BUILD/binutils-2.26.1/build-dir/bfd/../../bfd/elflink.c:4733:
undefined reference to `objalloc_free_block'
/home/abuild/rpmbuild/BUILD/binutils-2.26.1/build-dir/bfd/../../bfd/elflink.c:5027:
undefined reference to `_sch_istable'
...
```
After this patch we also link against the direct dependencies of libbfd.a, namely libiberty and libz
Also see: https://github.com/KDAB/GammaRay/issues/386