CMake modernization: add Backward::Interface and Backward::Object targets#310
Merged
bombela merged 3 commits intobombela:masterfrom Nov 23, 2023
Merged
CMake modernization: add Backward::Interface and Backward::Object targets#310bombela merged 3 commits intobombela:masterfrom
bombela merged 3 commits intobombela:masterfrom
Conversation
The BACKWARD_TESTS option does not make sense when Backward is used via find_package() so it does not belong to the BackwardConfig.cmake file.
…e in applications
Owner
|
Thank you for the fine work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR should make it easier to use the
backward.cppfile in downstream projects. As documented in the README, with this PR there are now three targets:Backward::Interfaceis an interface target that brings compiler definitionflags, include directory, and external libraries. This is all you need to use
the
backward.hppheader library.Backward::ObjectbringsBackward::Interfaceandbackward.cppas anOBJECTCMake library. This target cannot be exported, so it is notavailable when Backward is used via
find_package.Backward::BackwardbringsBackward::Interfaceandbackward.cppaseither
STATICorSHAREDlibrary (depending on theBACKWARD_SHAREDoption). 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-archiveoption (or similar) is used.This PR marks the
add_backwardtarget as deprecated and removes the${BACKWARD_ENABLE}variable.Before this PR, using the
Backward::Backwardtarget was not easy and consistent:BackwardConfig.cmakedefined the target such that its interface had only the things needed to usebackward.hpp(i.e.BACKWARD_INCLUDE_DIRS,BACKWARD_DEFINITIONS,BACKWARD_LIBRARIES)CMakeLists.txtfile defined the target such that it contained evenbackward.cppas either STATIC or SHARED librarylibbackward.adoes not have the desired effect, unless the-Wl,--whole-archiveoption (or similar) is used (the linker discards unused objects from a static library)