Skip to content

Commit

Permalink
Fix Findlibdw.cmake and Findlibelf.cmake (#764)
Browse files Browse the repository at this point in the history
- improve pkg-config and explicit search fallback
  • Loading branch information
jrmadsen authored Apr 15, 2024
1 parent 3ec628e commit d766034
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cmake/Modules/Findlibdw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
find_package(PkgConfig)

if(PkgConfig_FOUND)
set(ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} "")
pkg_check_modules(DW libdw)
if(DW_FOUND)

if(DW_FOUND
AND DW_INCLUDE_DIRS
AND DW_LIBRARIES)
set(libdw_INCLUDE_DIR
"${DW_INCLUDE_DIRS}"
CACHE FILEPATH "libdw include directory")
Expand All @@ -36,7 +40,7 @@ if(PkgConfig_FOUND)
endif()
endif()

if(NOT PkgConfig_FOUND OR NOT DW_FOUND)
if(NOT libdw_INCLUDE_DIR OR NOT libdw_LIBRARY)
find_path(
libdw_ROOT_DIR
NAMES include/elfutils/libdw.h
Expand Down
11 changes: 7 additions & 4 deletions cmake/Modules/Findlibelf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
find_package(PkgConfig)

if(PkgConfig_FOUND)
set(ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} "")
pkg_check_modules(ELF libelf)

if(ELF_FOUND)
if(ELF_FOUND
AND ELF_INCLUDE_DIRS
AND ELF_LIBRARIES)
set(libelf_INCLUDE_DIR
"${ELF_INCLUDE_DIRS}"
CACHE FILEPATH "libelf include directory")
Expand All @@ -37,18 +40,18 @@ if(PkgConfig_FOUND)
endif()
endif()

if(NOT PkgConfig_FOUND OR NOT ELF_FOUND)
if(NOT libelf_INCLUDE_DIR OR NOT libelf_LIBRARY)
find_path(
libelf_ROOT_DIR
NAMES include/gelf.h include/elf.h
NAMES include/elf.h
HINTS ${libelf_ROOT}
PATHS ${libelf_ROOT})

mark_as_advanced(libelf_ROOT_DIR)

find_path(
libelf_INCLUDE_DIR
NAMES gelf.h elf.h
NAMES elf.h
HINTS ${libelf_ROOT}
PATHS ${libelf_ROOT}
PATH_SUFFIXES include)
Expand Down

0 comments on commit d766034

Please sign in to comment.