This PR should make it easier to use the backward.cpp file in downstream projects. As documented in the README, with this PR there are now three targets:
Backward::Interface is an interface target that brings compiler definition
flags, include directory, and external libraries. This is all you need to use
the backward.hpp header library.
Backward::Object brings Backward::Interface and backward.cpp as an
OBJECT CMake library. This target cannot be exported, so it is not
available when Backward is used via find_package.
Backward::Backward brings Backward::Interface and backward.cpp as
either STATIC or SHARED library (depending on the BACKWARD_SHARED
option). This target is exported and always available, however note that the
linker will not include unused objects from a static library, unless the
-Wl,--whole-archive option (or similar) is used.
This PR marks the add_backward target as deprecated and removes the ${BACKWARD_ENABLE} variable.
Before this PR, using the Backward::Backward target was not easy and consistent:
the BackwardConfig.cmake defined the target such that its interface had only the things needed to use backward.hpp (i.e. BACKWARD_INCLUDE_DIRS, BACKWARD_DEFINITIONS, BACKWARD_LIBRARIES)
the main CMakeLists.txt file defined the target such that it contained even backward.cpp as either STATIC or SHARED library
linking to a static library libbackward.a does not have the desired effect, unless the
-Wl,--whole-archive option (or similar) is used (the linker discards unused objects from a static library)
This PR should make it easier to use the
backward.cpp
file in downstream projects. As documented in the README, with this PR there are now three targets:Backward::Interface
is an interface target that brings compiler definition flags, include directory, and external libraries. This is all you need to use thebackward.hpp
header library.Backward::Object
bringsBackward::Interface
andbackward.cpp
as anOBJECT
CMake library. This target cannot be exported, so it is not available when Backward is used viafind_package
.Backward::Backward
bringsBackward::Interface
andbackward.cpp
as eitherSTATIC
orSHARED
library (depending on theBACKWARD_SHARED
option). This target is exported and always available, however note that the linker will not include unused objects from a static library, unless the-Wl,--whole-archive
option (or similar) is used.This PR marks the
add_backward
target as deprecated and removes the${BACKWARD_ENABLE}
variable.Before this PR, using the
Backward::Backward
target was not easy and consistent:BackwardConfig.cmake
defined the target such that its interface had only the things needed to usebackward.hpp
(i.e.BACKWARD_INCLUDE_DIRS
,BACKWARD_DEFINITIONS
,BACKWARD_LIBRARIES
)CMakeLists.txt
file defined the target such that it contained evenbackward.cpp
as either STATIC or SHARED librarylibbackward.a
does not have the desired effect, unless the-Wl,--whole-archive
option (or similar) is used (the linker discards unused objects from a static library)