Debian Codegraph @

tools/cmake/Modules/FindLibuv.cmake

raw
1 #
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
17 # under the License.
18 #
19
20 #.rst
21 # FindLibuv
22 #----------
23 #
24 # Find libuv include dirs and libraries.
25 #
26 # Sets the following variables:
27 #
28 # Libuv_FOUND - True if headers and requested libraries were found
29 # Libuv_INCLUDE_DIRS - Libuv include directories
30 # Libuv_LIBRARIES - Link these to use libuv.
31 #
32 # This module reads hints about search locations from variables::
33 # LIBUV_ROOT - Preferred installation prefix
34 # LIBUV_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
35 # LIBUV_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
36
37 find_package (PkgConfig)
38 pkg_check_modules (PC_Libuv QUIET libuv)
39
40 find_library(Libuv_LIBRARY NAMES uv libuv
41 HINTS ${LIBUV_LIBRARYDIR} ${LIBUV_ROOT}/lib ${CMAKE_INSTALL_PREFIX}/lib
42 PATHS ${PC_Libuv_LIBRARY_DIRS})
43
44 find_path(Libuv_INCLUDE_DIR NAMES uv.h
45 HINTS ${LIBUV_INCLUDEDIR} ${LIBUV_ROOT}/include ${CMAKE_INSTALL_PREFIX}/include
46 PATHS /usr/include ${PC_Libuv_INCLUDE_DIRS})
47
48 set(Libuv_VERSION ${PC_Libuv_VERSION})
49
50 include(FindPackageHandleStandardArgs)
51 find_package_handle_standard_args(Libuv
52 FOUND_VAR Libuv_FOUND
53 REQUIRED_VARS Libuv_LIBRARY Libuv_INCLUDE_DIR
54 VERSION_VAR Libuv_VERSION)
55
56 if (Libuv_FOUND)
57 set(Libuv_INCLUDE_DIRS ${Libuv_INCLUDE_DIR})
58 set(Libuv_LIBRARIES ${Libuv_LIBRARY})
59
60 if (NOT TARGET Libuv::Libuv)
61 add_library(Libuv::Libuv UNKNOWN IMPORTED)
62 set_target_properties(Libuv::Libuv
63 PROPERTIES
64 IMPORTED_LOCATION "${Libuv_LIBRARY}"
65 INTERFACE_INCLUDE_DIRECTORIES "${Libuv_INCLUDE_DIR}"
66 )
67 endif ()
68
69 endif ()
70
71 mark_as_advanced (Libuv_LIBRARY Libuv_INCLUDE_DIR)