On ArchLinux at least the bfd.h header errors out early if
PACKAGE or PACKAGE_VERSION have not been set. This patch
makes backward.hpp compile on this platform for me.
This change is needed for compatibility to Qt applications.
Qt defines a macro "signals" that expands to nothing and is used by
Qt's meta object compiler (which is kind of a C++ pre-processor) to
add signal-slot feature (http://doc.qt.io/qt-5/signalsandslots.html).
This will cause compilation of backward.hpp to fail, when used from a
Qt application, because the variable "signals" will be expanded to ""
by the cpp pre processor.
This commit seperates some of the CMake code into a
BackwardMacros.cmake file. Including the CMakeLists.txt with
add_subdirectory doesn't work, because the variables it defines won't
be available from the including CMakeLists. With a .cmake file, they
will.
This change is backward-compatible, because CMakeLists.txt includes
the BackwardMacros.cmake as well.
Previously, the "feature detection options" (STACK_DETAILS_* and STACK_WALKING_*) had to be manually set by an user, but now, we (attempt) to detect libraries based on find_library, thus we don't need those to be cache values anymore. Libraries in non-default paths can be manually added in the corresponding _PATH cache value and for testing purposes, users can also disable libraries by supplying an empty string.
Make backward easier to use for CMake users, enabling easy feature detection and integration.
We now detect presence of libdw, libbfd and libunwind directly in the script. The macro add_backward adds needed libraries, definitions and the include directory to a target. The pseudo-library enable_backward enables automatic backward processing for common failures to a target.
If BACKWARD_ENABLE_ONLY_IN_DEBUG is set to true, automatic backward processing is only added when the build type is Debug or RelWithDebInfo.
To integrate backward in an existing CMake project:
add_subdirectory(/path/to/backward-cpp)
add_executable(mytarget example.cpp ${backward_ENABLE})
add_backward(mytarget)
BACKWARD_DEFINITIONS has been renamed to backward_DEFINITIONS to have a naming convention for public variables similiar to the find modules.
When including the project from a parent directory (add_subdirectory), backward.hpp is not found by the tests because we include CMAKE_SOURCE_DIR, which is the parent's source directory. Include CMAKE_CURRENT_SOURCE_DIR instead.