FindLibDl.cmake 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #.rst:
  2. # FindLibDl
  3. # --------
  4. #
  5. # Find the native realtime includes and library.
  6. #
  7. # IMPORTED Targets
  8. # ^^^^^^^^^^^^^^^^
  9. #
  10. # This module defines :prop_tgt:`IMPORTED` target ``LIBDL::LIBDL``, if
  11. # LIBDL has been found.
  12. #
  13. # Result Variables
  14. # ^^^^^^^^^^^^^^^^
  15. #
  16. # This module defines the following variables:
  17. #
  18. # ::
  19. #
  20. # LIBDL_INCLUDE_DIRS - where to find dlfcn.h, etc.
  21. # LIBDL_LIBRARIES - List of libraries when using libdl.
  22. # LIBDL_FOUND - True if dynamic linking library found.
  23. #
  24. # Hints
  25. # ^^^^^
  26. #
  27. # A user may set ``LIBDL_ROOT`` to a library installation root to tell this
  28. # module where to look.
  29. find_path(LIBDL_INCLUDE_DIRS
  30. NAMES dlfcn.h
  31. PATHS ${LIBDL_ROOT}/include/
  32. )
  33. find_library(LIBDL_LIBRARIES dl)
  34. include(FindPackageHandleStandardArgs)
  35. find_package_handle_standard_args(LibDl DEFAULT_MSG LIBDL_LIBRARIES LIBDL_INCLUDE_DIRS)
  36. mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES)
  37. if(LIBDL_FOUND)
  38. if(NOT TARGET LIBDL::LIBDL)
  39. add_library(LIBDL::LIBDL UNKNOWN IMPORTED)
  40. set_target_properties(LIBDL::LIBDL PROPERTIES
  41. IMPORTED_LOCATION "${LIBDL_LIBRARIES}"
  42. INTERFACE_INCLUDE_DIRECTORIES "${LIBDL_INCLUDE_DIRS}")
  43. endif()
  44. endif()