Debian Codegraph @

cmake/FindHiredis.cmake

raw
1 # Copyright 2022 Timo Röhling <[email protected]>
2 # SPDX-License-Identifier: FSFAP
3 #
4 # Copying and distribution of this file, with or without modification, are
5 # permitted in any medium without royalty provided the copyright notice and
6 # this notice are preserved. This file is offered as-is, without any warranty.
7 #
8 include(FindPackageHandleStandardArgs)
9 find_package(PkgConfig QUIET)
10 if(PkgConfig_FOUND)
11 pkg_search_module(PC_HIREDIS QUIET hiredis)
12 endif()
13 find_path(
14 Hiredis_INCLUDE_DIR hiredis.h
15 PATH_SUFFIXES hiredis
16 HINTS ${PC_HIREDIS_INCLUDE_DIRS}
17 )
18 find_library(Hiredis_LIBRARY hiredis HINTS ${PC_HIREDIS_LIBRARY_DIRS})
19 find_package_handle_standard_args(
20 Hiredis
21 FOUND_VAR Hiredis_FOUND
22 REQUIRED_VARS Hiredis_INCLUDE_DIR Hiredis_LIBRARY
23 )
24 if(Hiredis_FOUND AND NOT TARGET hiredis::hiredis)
25 add_library(hiredis::hiredis UNKNOWN IMPORTED)
26 set_target_properties(
27 hiredis::hiredis
28 PROPERTIES IMPORTED_LOCATION "${Hiredis_LIBRARY}"
29 INTERFACE_INCLUDE_DIRECTORIES "${Hiredis_INCLUDE_DIR}"
30 )
31 endif()