Commit 48d6f314 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

cmake: fix detection of dwarf.h

Summary:
Ubuntu 18.04 (and presumably other Debian-based distributions) install
dwarf.h at /usr/include/libdwarf/dwarf.h.  However other platforms like Mac
typically install dwarf.h directly inside include/ without a libdwarf
subdirectory.

Commit e66fb34c previously changed the code to look only for "dwarf.h" to
support Homebrew installations of dwarfutils on Mac, but accidentally broke
finding dwarf.h on Ubuntu in the process.  This change should hopefully work
on both platforms.

Fixes: #905

Reviewed By: yfeldblum

Differential Revision: D9212428

fbshipit-source-id: a4520a47718a2da25e597ac7350344931ba21634
parent 4fcdaf5c
find_path(LIBDWARF_INCLUDE_DIR NAMES libdwarf/dwarf.h)
# dwarf.h is typically installed in a libdwarf/ subdirectory on Debian-style
# Linux distributions. It is not installed in a libdwarf/ subdirectory on Mac
# systems when installed with Homebrew. Search for it in both locations.
find_path(LIBDWARF_INCLUDE_DIR NAMES dwarf.h PATH_SUFFIXES libdwarf)
mark_as_advanced(LIBDWARF_INCLUDE_DIR)
find_library(LIBDWARF_LIBRARY NAMES dwarf)
......
......@@ -67,7 +67,6 @@
#cmakedefine FOLLY_HAVE_XSI_STRERROR_R 1
#cmakedefine HAVE_VSNPRINTF_ERRORS 1
#cmakedefine FOLLY_HAVE_LIBDWARF_DWARF_H 1
#cmakedefine FOLLY_USE_SYMBOLIZER 1
#define FOLLY_DEMANGLE_MAX_SYMBOL_SIZE 1024
......
......@@ -128,7 +128,6 @@ endif()
find_package(LibDwarf)
list(APPEND FOLLY_LINK_LIBRARIES ${LIBDWARF_LIBRARIES})
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBDWARF_INCLUDE_DIRS})
CHECK_INCLUDE_FILE_CXX(libdwarf/dwarf.h FOLLY_HAVE_LIBDWARF_DWARF_H)
find_package(Libiberty)
list(APPEND FOLLY_LINK_LIBRARIES ${LIBIBERTY_LIBRARIES})
......
......@@ -18,6 +18,9 @@
#include <type_traits>
// FOLLY_HAVE_LIBDWARF_DWARF_H is only ever set for autoconf-based builds.
// We can delete this #if check once we completely deprecate and remove
// the autoconf build.
#if FOLLY_HAVE_LIBDWARF_DWARF_H
#include <libdwarf/dwarf.h>
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment