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