summaryrefslogtreecommitdiffstats
path: root/FindDL.cmake
blob: 584650fcdb591fa56d1a08e0bcf233a7405d9118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# - Find dl functions
# This module finds dl libraries.
#
# It sets the following variables:
#  DL_FOUND       - Set to false, or undefined, if dl libraries aren't found.
#  DL_INCLUDE_DIR - The dl include directory.
#  DL_LIBRARY     - The dl library to link against.

INCLUDE(CheckFunctionExists)

FIND_PATH(DL_INCLUDE_DIR NAMES dlfcn.h)
FIND_LIBRARY(DL_LIBRARY NAMES dl)

IF (DL_LIBRARY)
   SET(DL_FOUND TRUE)
ELSE (DL_LIBRARY)
   # if dlopen can be found without linking in dl then,
   # dlopen is part of libc, so don't need to link extra libs.
   CHECK_FUNCTION_EXISTS(dlopen DL_FOUND)
   SET(DL_LIBRARY "")
ENDIF (DL_LIBRARY)

IF (DL_FOUND)

   # show which dl was found only if not quiet
   IF (NOT DL_FIND_QUIETLY)
      MESSAGE(STATUS "Found dl: ${DL_LIBRARY}")
   ENDIF (NOT DL_FIND_QUIETLY)

ELSE (DL_FOUND)

   # fatal error if dl is required but not found
   IF (DL_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find dl")
   ENDIF (DL_FIND_REQUIRED)

ENDIF (DL_FOUND)