Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmake/BackwardConfigAment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ foreach(lib ${backward_ros_forced_LIBRARIES})
set(backward_ros_full_path_LIBRARIES "${backward_ros_full_path_LIBRARIES} ${lib}")
endif()
endforeach()
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed ${backward_ros_full_path_LIBRARIES} -Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")

# --no-as-needed and --as-needed only make sense on ELF platforms, so let's try to only set there
set(no_as_needed)
set(as_needed)
# CMake does not provide any way to directly check if platform is ELF, but UNIX AND NOT APPLE should work fine at
# least in ROS context
if(UNIX AND NOT APPLE)
set(no_as_needed "-Wl,--no-as-needed")
set(as_needed "-Wl,--as-needed")
endif()
SET(CMAKE_EXE_LINKER_FLAGS "${no_as_needed} ${backward_ros_full_path_LIBRARIES} ${as_needed} ${CMAKE_EXE_LINKER_FLAGS}")