Skip to content

Installation is not relocatable #287

@j-jorge

Description

@j-jorge

Hello, I built and installed cpptrace (1.0.2) with a command like this:

$ cmake path/to/source \
  -DCMAKE_INSTALL_PREFIX=/path/to/install/ \
  -DCPPTRACE_UNWIND_WITH_LIBUNWIND=ON \
  -DENABLE_DECOMPRESSION=OFF
$ ninja install

I have libunwind available, the build goes smoothly as well as the installation. But when I check the installed CMake scripts I see:

# cpp-trace-targets.cmake
set_target_properties(cpptrace::cpptrace PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "CPPTRACE_STATIC_DEFINE"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:libdwarf::dwarf>;\$<LINK_ONLY:dl>;-L/path/to/install/lib;\$<LINK_ONLY:-lunwind>"
)

As you can see the path to the directory where I have installed libunwind is passed in INTERFACE_LINK_LIBRARIES. Consequently if I copy my installation to another directory, I can use find_package(cpptrace) to find cpptrace but it will fail to find libunwind.

I would have expected to see something like find_library(libunwind_lib unwind REQUIRED) before the set_target_properties, then to link with ${libunwind_lib}, or something similar. I'm not sure it would be the best solution though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions