Skip to content

Commit

Permalink
Find dependencies for statically-linked libdw
Browse files Browse the repository at this point in the history
BackwardConfig.cmake was not explicitly pulling in the
dependencies (libelf, libz, etc.) of libdw, which made it fail to link
when libdw was built as a static library (and therefore didn't
explicitly encode those dependencies).
  • Loading branch information
csw committed Dec 17, 2021
1 parent 4924389 commit d2564c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion BackwardConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,21 @@ if (${STACK_DETAILS_AUTO_DETECT})
# find libdw
find_path(LIBDW_INCLUDE_DIR NAMES "elfutils/libdw.h" "elfutils/libdwfl.h")
find_library(LIBDW_LIBRARY dw)
# in case it's statically linked, look for all the possible dependencies
find_library(LIBELF_LIBRARY elf)
find_library(LIBPTHREAD_LIBRARY pthread)
find_library(LIBZ_LIBRARY z)
find_library(LIBBZ2_LIBRARY bz2)
find_library(LIBLZMA_LIBRARY lzma)
find_library(LIBZSTD_LIBRARY zstd)
set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} )
set(LIBDW_LIBRARIES ${LIBDW_LIBRARY} )
set(LIBDW_LIBRARIES ${LIBDW_LIBRARY}
$<$<BOOL:${LIBELF_LIBRARY}>:${LIBELF_LIBRARY}>
$<$<BOOL:${LIBPTHREAD_LIBRARY}>:${LIBPTHREAD_LIBRARY}>
$<$<BOOL:${LIBZ_LIBRARY}>:${LIBZ_LIBRARY}>
$<$<BOOL:${LIBBZ2_LIBRARY}>:${LIBBZ2_LIBRARY}>
$<$<BOOL:${LIBLZMA_LIBRARY}>:${LIBLZMA_LIBRARY}>
$<$<BOOL:${LIBZSTD_LIBRARY}>:${LIBZSTD_LIBRARY}>)
find_package_handle_standard_args(libdw ${_name_mismatched_arg}
REQUIRED_VARS LIBDW_LIBRARY LIBDW_INCLUDE_DIR)
mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY)
Expand Down

0 comments on commit d2564c7

Please sign in to comment.