1b99b2ba364ec592b0c09df891208c93fc640db8
[vlc.git] / extras / buildsystem / cmake / include / FindDlopen.cmake
1 # From licq www.licq.org (GPL)
2 # - Find library containing dlopen()
3 # The following variables are set if dlopen is found. If dlopen is not
4 # found, Dlopen_FOUND is set to false.
5 #  Dlopen_FOUND     - System has dlopen.
6 #  Dlopen_LIBRARIES - Link these to use dlopen.
7 #
8 # Copyright (c) 2007 Erik Johansson <erik@ejohansson.se>
9 # Redistribution and use is allowed according to the terms of the BSD license.
10
11
12 # Assume dlopen is not found.
13 if (Dlopen_SEARCHED)
14     include(CheckLibraryExists)
15
16     set(Dlopen_SEARCHED TRUE)
17     set(Dlopen_FOUND FALSE)
18
19     foreach (library c c_r dl)
20       if (NOT Dlopen_FOUND)
21         check_library_exists(${library} dlopen "" Dlopen_IN_${library})
22
23         if (Dlopen_IN_${library})
24           set(Dlopen_LIBRARIES ${library} CACHE STRING "Library containing dlopen")
25           set(Dlopen_FOUND TRUE)
26         endif (Dlopen_IN_${library})
27
28       endif (NOT Dlopen_FOUND)
29     endforeach (library)
30
31     if (Dlopen_FOUND)
32       if (NOT Dlopen_FIND_QUIETLY)
33         message(STATUS "Found dlopen in: ${Dlopen_LIBRARIES}")
34       endif (NOT Dlopen_FIND_QUIETLY)
35     else (Dlopen_FOUND)
36       if (Dlopen_FIND_REQUIRED)
37         message(FATAL_ERROR "Could not find the library containing dlopen")
38       endif (Dlopen_FIND_REQUIRED)
39     endif (Dlopen_FOUND)
40
41     mark_as_advanced(Dlopen_LIBRARIES)
42 endif(Dlopen_SEARCHED)