FindLibUUID.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. FOUND_VAR LibUUID_FOUND
  62. REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR
  63. )
  64. set(LIBUUID_FOUND ${LibUUID_FOUND})
  65. #-----------------------------------------------------------------------------
  66. # Provide documented result variables and targets.
  67. if(LibUUID_FOUND)
  68. set(LibUUID_INCLUDE_DIRS ${LibUUID_INCLUDE_DIR})
  69. set(LibUUID_LIBRARIES ${LibUUID_LIBRARY})
  70. if(NOT TARGET LibUUID::LibUUID)
  71. add_library(LibUUID::LibUUID UNKNOWN IMPORTED)
  72. set_target_properties(LibUUID::LibUUID PROPERTIES
  73. IMPORTED_LOCATION "${LibUUID_LIBRARY}"
  74. INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIRS}"
  75. )
  76. endif()
  77. endif()