FindLibUUID.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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(MSYS)
  32. # Note: on current version of MSYS2, 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. find_library(LibUUID_LIBRARY
  36. NAMES msys-uuid-1.dll
  37. )
  38. elseif(CYGWIN)
  39. # Note: on current version of Cygwin, linking to libuuid.dll.a doesn't
  40. # import the right symbols sometimes. Fix this by linking directly
  41. # to the DLL that provides the symbols, instead.
  42. set(old_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
  43. set(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
  44. find_library(LibUUID_LIBRARY
  45. NAMES cyguuid-1.dll
  46. )
  47. set(CMAKE_FIND_LIBRARY_SUFFIXES ${old_suffixes})
  48. else()
  49. find_library(LibUUID_LIBRARY
  50. NAMES uuid
  51. )
  52. endif()
  53. mark_as_advanced(LibUUID_LIBRARY)
  54. find_path(LibUUID_INCLUDE_DIR
  55. NAMES uuid/uuid.h
  56. )
  57. mark_as_advanced(LibUUID_INCLUDE_DIR)
  58. #-----------------------------------------------------------------------------
  59. include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
  60. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUUID
  61. REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR
  62. )
  63. #-----------------------------------------------------------------------------
  64. # Provide documented result variables and targets.
  65. if(LibUUID_FOUND)
  66. set(LibUUID_INCLUDE_DIRS ${LibUUID_INCLUDE_DIR})
  67. set(LibUUID_LIBRARIES ${LibUUID_LIBRARY})
  68. if(NOT TARGET LibUUID::LibUUID)
  69. add_library(LibUUID::LibUUID UNKNOWN IMPORTED)
  70. set_target_properties(LibUUID::LibUUID PROPERTIES
  71. IMPORTED_LOCATION "${LibUUID_LIBRARY}"
  72. INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIRS}"
  73. )
  74. endif()
  75. endif()