Open Hopobcn opened 5 years ago
When cmake detects dwarf library (due incorrect initialization of BACKWARD_LIBRARIES) the interface target Backward::Backward generates an empy INTERFACE_LINK_LIBRARIES which causes all tests to fail at link time.
BACKWARD_LIBRARIES
Backward::Backward
INTERFACE_LINK_LIBRARIES
Offending line: https://github.com/bombela/backward-cpp/blob/27349d0a751e8a0bc62d60c198972712020f34ac/BackwardConfig.cmake#L114
Should be: LIST(APPEND _BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES})
LIST(APPEND _BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES})
Example: (note missing -ldwarf -lelf -ldl)
cmake -DCMAKE_BUILD_TYPE=Debug -DBACKWARD_TESTS=ON -G "CodeBlocks - Unix Makefiles" /home/_/Projects/backward-cpp -- The CXX compiler identification is GNU 7.4.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Could NOT find libdw (missing: LIBDW_LIBRARY LIBDW_INCLUDE_DIR) -- Could NOT find libbfd (missing: LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR) -- Found libdwarf: /usr/lib/x86_64-linux-gnu/libdwarf.so -- Found Backward: /home/_/Projects/backward-cpp -- Configuring done -- Generating done -- Build files have been written to: /home/_/Projects/backward-cpp/cmake-build-debug ... [ 75%] Building CXX object CMakeFiles/test_stacktrace.dir/test/stacktrace.cpp.o /usr/bin/c++ -DBACKWARD_HAS_BACKTRACE=0 -DBACKWARD_HAS_BACKTRACE_SYMBOL=0 -DBACKWARD_HAS_BFD=0 -DBACKWARD_HAS_DW=0 -DBACKWARD_HAS_DWARF=1 -DBACKWARD_HAS_UNWIND=1 -isystem /usr/include/libdwarf -isystem /home/_/Projects/backward-cpp -Wall -Wextra -pedantic-errors -g -g -std=gnu++11 -o CMakeFiles/test_stacktrace.dir/test/stacktrace.cpp.o -c /home/_/Projects/backward-cpp/test/stacktrace.cpp [100%] Linking CXX executable test_stacktrace /home/_/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/192.5728.100/bin/cmake/linux/bin/cmake -E cmake_link_script CMakeFiles/test_stacktrace.dir/link.txt --verbose=1 /usr/bin/c++ -Wall -Wextra -pedantic-errors -g -g -rdynamic CMakeFiles/test_stacktrace.dir/test/stacktrace.cpp.o -o test_stacktrace -Wl,-rpath,/home/_/Projects/backward-cpp/cmake-build-debug libtest_main.so CMakeFiles/test_stacktrace.dir/test/stacktrace.cpp.o: In function `backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libdwarf>::resolve(backward::ResolvedTrace)': /home/_/Projects/backward-cpp/backward.hpp:1692: undefined reference to `dladdr1' /home/_/Projects/backward-cpp/backward.hpp:1806: undefined reference to `dwarf_linesrc' /home/_/Projects/backward-cpp/backward.hpp:1809: undefined reference to `dwarf_dealloc' /home/_/Projects/backward-cpp/backward.hpp:1813: undefined reference to `dwarf_lineno' ...
When cmake detects dwarf library (due incorrect initialization of
BACKWARD_LIBRARIES
) the interface targetBackward::Backward
generates an empyINTERFACE_LINK_LIBRARIES
which causes all tests to fail at link time.Offending line: https://github.com/bombela/backward-cpp/blob/27349d0a751e8a0bc62d60c198972712020f34ac/BackwardConfig.cmake#L114
Should be:
LIST(APPEND _BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES})
Example: (note missing -ldwarf -lelf -ldl)