-
Notifications
You must be signed in to change notification settings - Fork 342
backwards-cpp support for gz-sim-main and gz-sim-gui #2919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5913812
Import backwards version 1.6
j-rivero 965d463
Rename the backwards vendor dir
j-rivero fd0edc9
Use backwards in gz-sim-gui and gz-sim-main
j-rivero 42383a5
Use backwards header and signal handler
j-rivero 255dd43
Revert "Use backwards header and signal handler"
j-rivero 454f13a
Use backwards.cpp instead of backwards.hpp
j-rivero 5d531b2
Update backwards to 0bfd0a07a61551413ccd2ab9a9099af3bad40681
j-rivero 0109512
Change backwards use to relay on Object
j-rivero cf010b1
Minor style related issues
arjo129 fe76420
Merge branch 'main' into jrivero/backwards_standalone_2
arjo129 c5ba370
Merge branch 'main' into jrivero/backwards_standalone_2
arjo129 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
cmake_minimum_required(VERSION 3.14) | ||
cmake_minimum_required(VERSION 3.0) | ||
project(backward CXX) | ||
|
||
# Introduce variables: | ||
|
@@ -31,22 +31,6 @@ include(GNUInstallDirs) | |
|
||
include(BackwardConfig.cmake) | ||
|
||
############################################################################### | ||
# OPTIONS | ||
############################################################################### | ||
|
||
option(BACKWARD_SHARED "Build backward as a shared library" OFF) | ||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT DEFINED BACKWARD_TESTS) | ||
# If this is a top level CMake project, we most lixely want the tests | ||
set(BACKWARD_TESTS ON CACHE BOOL "Enable tests") | ||
else() | ||
set(BACKWARD_TESTS OFF CACHE BOOL "Enable tests") | ||
endif() | ||
|
||
############################################################################### | ||
# COMPILER FLAGS | ||
############################################################################### | ||
|
||
# check if compiler is nvcc or nvcc_wrapper | ||
set(COMPILER_IS_NVCC false) | ||
get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME) | ||
|
@@ -68,6 +52,10 @@ if (${COMPILER_IS_NVCC}) | |
set(CMAKE_CXX_EXTENSIONS OFF) | ||
endif() | ||
|
||
############################################################################### | ||
# COMPILER FLAGS | ||
############################################################################### | ||
|
||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
if (NOT ${COMPILER_IS_NVCC}) | ||
|
@@ -77,58 +65,75 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) | |
endif() | ||
|
||
############################################################################### | ||
# BACKWARD INTERFACE | ||
############################################################################### | ||
|
||
add_library(backward_interface INTERFACE) | ||
set_target_properties(backward_interface PROPERTIES EXPORT_NAME Interface) | ||
target_compile_definitions(backward_interface INTERFACE ${BACKWARD_DEFINITIONS}) | ||
target_include_directories(backward_interface INTERFACE ${BACKWARD_INCLUDE_DIRS}) | ||
if(BACKWARD_HAS_EXTERNAL_LIBRARIES) | ||
target_link_libraries(backward_interface INTERFACE ${BACKWARD_LIBRARIES}) | ||
endif() | ||
add_library(Backward::Interface ALIAS backward_interface) | ||
|
||
############################################################################### | ||
# BACKWARD OBJECT (Includes backward.cpp) | ||
# (Note that this target is not exported, since CMake currently does not allow | ||
# exporting an OBJECT library.) | ||
# BACKWARD OBJECT | ||
############################################################################### | ||
|
||
add_library(backward_object OBJECT backward.cpp) | ||
set_target_properties(backward_object PROPERTIES EXPORT_NAME Object) | ||
target_link_libraries(backward_object PUBLIC Backward::Interface) | ||
add_library(Backward::Object ALIAS backward_object) | ||
target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS}) | ||
arjo129 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS}) | ||
set(BACKWARD_ENABLE $<TARGET_OBJECTS:backward_object> CACHE STRING | ||
"Link with this object to setup backward automatically") | ||
|
||
|
||
############################################################################### | ||
# BACKWARD LIBRARY (Includes backward.cpp) | ||
# (Note that the linker will not include unused objects from a static library, | ||
# unless the -Wl,--whole-archive option (or similar) is used.) | ||
############################################################################### | ||
option(BACKWARD_SHARED "Build dynamic backward-cpp shared lib" OFF) | ||
|
||
set(libtype STATIC) | ||
if(BACKWARD_SHARED) | ||
set(libtype SHARED) | ||
endif() | ||
add_library(backward ${libtype} backward.cpp) | ||
set_target_properties(backward PROPERTIES EXPORT_NAME Backward) | ||
target_link_libraries(backward PUBLIC Backward::Interface) | ||
add_library(Backward::Backward ALIAS backward) | ||
|
||
# check if Backward is being used as a top-level project or included as a subproject | ||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) | ||
install( | ||
FILES "backward.hpp" | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
install( | ||
FILES "BackwardConfig.cmake" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this reverted #2838, and @j-rivero predicted this fragility in #2838 (comment) for now the debbuild is unstable due to these installed files since BackwardConfig.cmake is not included in any package install rules |
||
# export the targets (note that exporting backward_object does not make sense) | ||
install(TARGETS backward_interface backward EXPORT BackwardTargets) | ||
# install a CMake file for the exported targets | ||
install(EXPORT BackwardTargets | ||
NAMESPACE Backward:: | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") | ||
target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS}) | ||
target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS}) | ||
|
||
############################################################################### | ||
# TESTS | ||
############################################################################### | ||
|
||
if(BACKWARD_TESTS) | ||
enable_testing() | ||
|
||
add_library(test_main OBJECT test/_test_main.cpp) | ||
|
||
macro(backward_add_test src) | ||
get_filename_component(name ${src} NAME_WE) | ||
set(test_name "test_${name}") | ||
|
||
add_executable(${test_name} ${src} ${ARGN} $<TARGET_OBJECTS:test_main>) | ||
|
||
target_link_libraries(${test_name} PRIVATE Backward::Backward) | ||
|
||
add_test(NAME ${name} COMMAND ${test_name}) | ||
endmacro() | ||
|
||
# Tests without backward.cpp | ||
set(TESTS | ||
test | ||
stacktrace | ||
rectrace | ||
select_signals | ||
) | ||
|
||
foreach(test ${TESTS}) | ||
backward_add_test(test/${test}.cpp) | ||
endforeach() | ||
|
||
# Tests with backward.cpp | ||
set(TESTS | ||
suicide | ||
) | ||
|
||
foreach(test ${TESTS}) | ||
backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE}) | ||
endforeach() | ||
endif() | ||
|
||
install( | ||
FILES "backward.hpp" | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
install( | ||
FILES "BackwardConfig.cmake" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/backward | ||
) |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, this won't work for the tests, perhaps
Backward::Object
? Or linking tests with whole-archive options enabled.