porting hh_naming_table_builder to rust
[hiphop-php.git] / CMake / FindLibDL.cmake
blobb304c780134af64fc852daacb169c47c8f8e6148
1 # - Try to find libdl
2 # Once done this will define
4 #  LIBDL_FOUND - system has libdl
5 #  LIBDL_INCLUDE_DIRS - the libdl include directory
6 #  LIBDL_LIBRARIES - Link these to use libdl
7 #  LIBDL_NEEDS_UNDERSCORE - If extern "C" symbols are prefixed (BSD/Apple)
10 find_path (LIBDL_INCLUDE_DIRS NAMES dlfcn.h)
11 find_library (LIBDL_LIBRARIES NAMES dl)
12 include (FindPackageHandleStandardArgs)
14 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG
15   LIBDL_LIBRARIES
16   LIBDL_INCLUDE_DIRS)
18 SET(CMAKE_REQUIRED_LIBRARIES dl)
19 INCLUDE(CheckCSourceRuns)
20 CHECK_C_SOURCE_RUNS("#include <dlfcn.h>
21 #include <stdlib.h>
22 void testfunc() {}
23 int main() {
24   testfunc();
25   if (dlsym(0, \"_testfunc\") != (void*)0) {
26     return EXIT_SUCCESS;
27   } else {
28     return EXIT_FAILURE;
29   }
30 }" LIBDL_NEEDS_UNDERSCORE)
32 mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES LIBDL_NEEDS_UNDERSCORE)