2 # Once done this will define
4 # LIBELF_FOUND - system has libelf
5 # LIBELF_INCLUDE_DIRS - the libelf include directory
6 # LIBELF_LIBRARIES - Link these to use libelf
7 # LIBELF_DEFINITIONS - Compiler switches required for using libelf
9 # Copyright (c) 2008 Bernhard Walle <bernhard.walle@gmx.de>
11 # Redistribution and use is allowed according to the terms of the New
13 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
17 if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
18 set (LibElf_FIND_QUIETLY TRUE)
19 endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
21 find_path (LIBELF_INCLUDE_DIRS
28 /usr/local/include/libelf
30 /opt/local/include/libelf
35 find_library (LIBELF_LIBRARIES
46 include (FindPackageHandleStandardArgs)
49 # handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE
50 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG
54 SET(CMAKE_REQUIRED_LIBRARIES elf)
55 INCLUDE(CheckCXXSourceCompiles)
56 CHECK_CXX_SOURCE_COMPILES("#include <libelf.h>
60 elf_getshdrstrndx(e, &sz);
63 SET(CMAKE_REQUIRED_LIBRARIES)
65 mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)