Debian Codegraph @

cmake/FindGroongamsgpackc.cmake

raw
1 # Copyright(C) 2023-2024 Sutou Kouhei <[email protected]>
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 if(Groongamsgpackc_FOUND)
18 return()
19 endif()
20
21 set(find_package_args "")
22 set(pkg_check_modules_version "")
23 if(Groongamsgpackc_FIND_VERSION)
24 list(APPEND find_package_args ${Groongamsgpackc_FIND_VERSION})
25 set(pkg_check_modules_version ">=${Groongamsgpackc_FIND_VERSION}")
26 endif()
27 if(Groongamsgpackc_FIND_QUIETLY)
28 list(APPEND find_package_args QUIET)
29 endif()
30
31 find_package(msgpack-c ${find_package_args})
32 set(Groongamsgpackc_FOUND ${msgpack-c_FOUND})
33 if(Groongamsgpackc_FOUND)
34 if(TARGET msgpack-c)
35 add_library(Groonga::msgpackc ALIAS msgpack-c)
36 else()
37 add_library(Groonga::msgpackc ALIAS msgpack-c-static)
38 endif()
39 endif()
40
41 if(NOT Groongamsgpackc_FOUND)
42 find_package(msgpackc ${find_package_args})
43 set(Groongamsgpackc_FOUND ${msgpackc_FOUND})
44 if(Groongamsgpackc_FOUND)
45 if(TARGET msgpackc)
46 add_library(Groonga::msgpackc ALIAS msgpackc)
47 else()
48 add_library(Groonga::msgpackc ALIAS msgpackc-static)
49 endif()
50 endif()
51 endif()
52
53 if(NOT Groongamsgpackc_FOUND AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
54 find_package(msgpack ${find_package_args})
55 set(Groongamsgpackc_FOUND ${msgpack_FOUND})
56 if(Groongamsgpackc_FOUND)
57 if(TARGET msgpackc)
58 add_library(Groonga::msgpackc ALIAS msgpackc)
59 elseif(TARGET msgpackc-static)
60 add_library(Groonga::msgpackc ALIAS msgpackc-static)
61 else()
62 # msgpackc-cxx's msgpack CMake package is found...
63 set(Groongamsgpackc_FOUND FALSE)
64 endif()
65 endif()
66 endif()
67
68 if(NOT Groongamsgpackc_FOUND)
69 find_package(PkgConfig)
70 if(PkgConfig_FOUND)
71 if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
72 pkg_check_modules(Groongamsgpack_pkg_msgpack-c IMPORTED_TARGET
73 "msgpack-c${pkg_check_modules_version}")
74 else()
75 pkg_check_modules(Groongamsgpack_pkg_msgpack-c IMPORTED_TARGET GLOBAL
76 "msgpack-c${pkg_check_modules_version}")
77 endif()
78 set(Groongamsgpackc_FOUND ${Groongamsgpack_pkg_msgpack-c_FOUND})
79 if(Groongamsgpackc_FOUND)
80 add_library(Groonga::msgpackc ALIAS
81 PkgConfig::Groongamsgpack_pkg_msgpack-c)
82 else()
83 if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
84 pkg_check_modules(Groongamsgpack_pkg_msgpack IMPORTED_TARGET
85 "msgpack${pkg_check_modules_version}")
86 else()
87 pkg_check_modules(Groongamsgpack_pkg_msgpack IMPORTED_TARGET GLOBAL
88 "msgpack${pkg_check_modules_version}")
89 endif()
90 set(Groongamsgpackc_FOUND ${Groongamsgpack_pkg_msgpack_FOUND})
91 if(Groongamsgpackc_FOUND)
92 add_library(Groonga::msgpackc ALIAS
93 PkgConfig::Groongamsgpack_pkg_msgpack)
94 endif()
95 endif()
96 endif()
97 endif()
98
99 include(FindPackageHandleStandardArgs)
100 find_package_handle_standard_args(Groongamsgpackc
101 REQUIRED_VARS Groongamsgpackc_FOUND)