FindLibUUID.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindLibUUID
  5. ------------
  6. Find LibUUID include directory and library.
  7. Imported Targets
  8. ^^^^^^^^^^^^^^^^
  9. An :ref:`imported target <Imported targets>` named
  10. ``LibUUID::LibUUID`` is provided if LibUUID has been found.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module defines the following variables:
  14. ``LibUUID_FOUND``
  15. True if LibUUID was found, false otherwise.
  16. ``LibUUID_INCLUDE_DIRS``
  17. Include directories needed to include LibUUID headers.
  18. ``LibUUID_LIBRARIES``
  19. Libraries needed to link to LibUUID.
  20. Cache Variables
  21. ^^^^^^^^^^^^^^^
  22. This module uses the following cache variables:
  23. ``LibUUID_LIBRARY``
  24. The location of the LibUUID library file.
  25. ``LibUUID_INCLUDE_DIR``
  26. The location of the LibUUID include directory containing ``uuid/uuid.h``.
  27. The cache variables should not be used by project code.
  28. They may be set by end users to point at LibUUID components.
  29. #]=======================================================================]
  30. #-----------------------------------------------------------------------------
  31. if(CYGWIN)
  32. # Note: on current version of Cygwin, linking to libuuid.dll.a doesn't
  33. # import the right symbols sometimes. Fix this by linking directly
  34. # to the DLL that provides the symbols, instead.
  35. set(old_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
  36. set(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
  37. find_library(LibUUID_LIBRARY
  38. NAMES cyguuid-1.dll
  39. )
  40. set(CMAKE_FIND_LIBRARY_SUFFIXES ${old_suffixes})
  41. else()
  42. find_library(LibUUID_LIBRARY
  43. NAMES uuid
  44. )
  45. endif()
  46. mark_as_advanced(LibUUID_LIBRARY)
  47. find_path(LibUUID_INCLUDE_DIR
  48. NAMES uuid/uuid.h
  49. )
  50. mark_as_advanced(LibUUID_INCLUDE_DIR)
  51. #-----------------------------------------------------------------------------
  52. include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
  53. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUUID
  54. FOUND_VAR LibUUID_FOUND
  55. REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR
  56. )
  57. set(LIBUUID_FOUND ${LibUUID_FOUND})
  58. #-----------------------------------------------------------------------------
  59. # Provide documented result variables and targets.
  60. if(LibUUID_FOUND)
  61. set(LibUUID_INCLUDE_DIRS ${LibUUID_INCLUDE_DIR})
  62. set(LibUUID_LIBRARIES ${LibUUID_LIBRARY})
  63. if(NOT TARGET LibUUID::LibUUID)
  64. add_library(LibUUID::LibUUID UNKNOWN IMPORTED)
  65. set_target_properties(LibUUID::LibUUID PROPERTIES
  66. IMPORTED_LOCATION "${LibUUID_LIBRARY}"
  67. INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIRS}"
  68. )
  69. endif()
  70. endif()