backward-cpp icon indicating copy to clipboard operation
backward-cpp copied to clipboard

Compilation / Integration in own program via FetchContent does not work on Ubuntu 22.04

Open firesurfer opened this issue 5 months ago • 0 comments

Hi I originally came from:

https://github.com/pal-robotics/backward_ros/issues/21 (Which btw. still doesn't work). I therefore tried to include backward-cpp directly in my program. When I followed the guide in the readme I first ran into the following issues:

  1. cmake couldn't clone the repository -> This was due to the SYSTEM argument in the Fetch call. This argument is only supported in cmake > 3.25. Ubuntu 22.04 ships 3.22.1. -> Removing SYSTEM fixes that
  2. None of the targets Backward::Interface, Backward::Object, or Backward::Backward can be found by cmake.

Solution: Directly link against backward_object

So in order to get it working on Ubuntu 22.04 I have now the following CMakeLists.txt

# Also requires one of: libbfd (gnu binutils), libdwarf, libdw (elfutils)
FetchContent_Declare(Backward    #Note: For some reason I ran into issues when the target here is called backwards with a small b at the beginning
    GIT_REPOSITORY https://github.com/bombela/backward-cpp
    GIT_TAG master  # or a version tag, such as v1.6
 
)
FetchContent_MakeAvailable(Backward)

add_executable....
target_link_libraries(my_executable backward_object)

firesurfer avatar Aug 27 '24 07:08 firesurfer