Debian Codegraph @

cmake/FindLibElf.cmake

raw
1 # Note: copied from https://github.com/facebook/hhvm/blob/master/CMake/FindLibElf.cmake
2
3 # - Try to find libelf
4 # Once done this will define
5 #
6 # LIBELF_FOUND - system has libelf
7 # LIBELF_INCLUDE_DIRS - the libelf include directory
8 # LIBELF_LIBRARIES - Link these to use libelf
9 # LIBELF_DEFINITIONS - Compiler switches required for using libelf
10 #
11 # Copyright (c) 2008 Bernhard Walle <[email protected]>
12 #
13 # Redistribution and use is allowed according to the terms of the New
14 # BSD license.
15 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
16 #
17
18
19 if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
20 set (LibElf_FIND_QUIETLY TRUE)
21 endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
22
23 find_path (LIBELF_INCLUDE_DIRS
24 NAMES
25 libelf.h
26 PATHS
27 /usr/include
28 /usr/include/libelf
29 /usr/local/include
30 /usr/local/include/libelf
31 /opt/local/include
32 /opt/local/include/libelf
33 /sw/include
34 /sw/include/libelf
35 ENV CPATH)
36
37 find_library (LIBELF_LIBRARIES
38 NAMES
39 elf
40 PATHS
41 /usr/lib
42 /usr/local/lib
43 /opt/local/lib
44 /sw/lib
45 ENV LIBRARY_PATH
46 ENV LD_LIBRARY_PATH)
47
48 include (FindPackageHandleStandardArgs)
49
50
51 # handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE
52 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG
53 LIBELF_LIBRARIES
54 LIBELF_INCLUDE_DIRS)
55
56 if ( 0 ) #not needed in dynamips
57 SET(CMAKE_REQUIRED_LIBRARIES elf)
58 INCLUDE(CheckCXXSourceCompiles)
59 CHECK_CXX_SOURCE_COMPILES("#include <libelf.h>
60 int main() {
61 Elf *e = (Elf*)0;
62 size_t sz;
63 elf_getshdrstrndx(e, &sz);
64 return 0;
65 }" ELF_GETSHDRSTRNDX)
66 endif ()
67
68 mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)