Debian Codegraph @

cmake/FindGroongalz4.cmake

raw
1 # Copyright(C) 2023 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(Groongalz4_FOUND)
18 return()
19 endif()
20
21 set(find_package_args "")
22 set(pkg_check_modules_version "")
23 if(Groongalz4_FIND_VERSION)
24 list(APPEND find_package_args ${Groongalz4_FIND_VERSION})
25 set(pkg_check_modules_version ">=${Groongalz4_FIND_VERSION}")
26 endif()
27 if(Groongalz4_FIND_QUIETLY)
28 list(APPEND find_package_args QUIET)
29 endif()
30 find_package(lz4 ${find_package_args})
31 set(Groongalz4_FOUND ${lz4_FOUND})
32 if(Groongalz4_FOUND)
33 if(TARGET LZ4::lz4_shared)
34 set(GRN_LZ4_TARGET LZ4::lz4_shared)
35 else()
36 set(GRN_LZ4_TARGET LZ4::lz4_static)
37 endif()
38 return()
39 endif()
40
41 if(NOT Groongalz4_FOUND)
42 find_package(PkgConfig)
43 if(PkgConfig_FOUND)
44 if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
45 pkg_check_modules(Groongalz4_pkg_liblz4 IMPORTED_TARGET
46 "liblz4${pkg_check_modules_version}")
47 else()
48 pkg_check_modules(Groongalz4_pkg_liblz4 IMPORTED_TARGET GLOBAL
49 "liblz4${pkg_check_modules_version}")
50 endif()
51 set(Groongalz4_FOUND ${Groongalz4_pkg_liblz4_FOUND})
52 if(Groongalz4_pkg_liblz4_FOUND)
53 set(GRN_LZ4_TARGET PkgConfig::Groongalz4_pkg_liblz4)
54 endif()
55 endif()
56 endif()
57
58 include(FindPackageHandleStandardArgs)
59 find_package_handle_standard_args(Groongalz4 REQUIRED_VARS Groongalz4_FOUND)