| 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(GroongaxxHash_FOUND) |
| 18 |
return() |
| 19 |
endif() |
| 20 |
|
| 21 |
set(find_package_args "") |
| 22 |
set(pkg_check_modules_version "") |
| 23 |
if(GroongaxxHash_FIND_VERSION) |
| 24 |
list(APPEND find_package_args ${GroongaxxHash_FIND_VERSION}) |
| 25 |
set(pkg_check_modules_version ">=${GroongaxxHash_FIND_VERSION}") |
| 26 |
endif() |
| 27 |
if(GroongaxxHash_FIND_QUIETLY) |
| 28 |
list(APPEND find_package_args QUIET) |
| 29 |
endif() |
| 30 |
find_package(xxHash ${find_package_args}) |
| 31 |
set(GroongaxxHash_FOUND ${xxHash_FOUND}) |
| 32 |
if(GroongaxxHash_FOUND) |
| 33 |
add_library(Groonga::xxhash ALIAS xxHash::xxhash) |
| 34 |
return() |
| 35 |
endif() |
| 36 |
|
| 37 |
if(NOT GroongaxxHash_FOUND) |
| 38 |
find_package(PkgConfig) |
| 39 |
if(PkgConfig_FOUND) |
| 40 |
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") |
| 41 |
pkg_check_modules(GroongaxxHash_pkg_libxxhash IMPORTED_TARGET |
| 42 |
"libxxhash${pkg_check_modules_version}") |
| 43 |
else() |
| 44 |
pkg_check_modules(GroongaxxHash_pkg_libxxhash IMPORTED_TARGET GLOBAL |
| 45 |
"libxxhash${pkg_check_modules_version}") |
| 46 |
endif() |
| 47 |
set(GroongaxxHash_FOUND ${GroongaxxHash_pkg_libxxhash_FOUND}) |
| 48 |
if(GroongaxxHash_pkg_libxxhash_FOUND) |
| 49 |
if(GroongaxxHash_pkg_libxxhash_VERSION VERSION_LESS "0.8.0") |
| 50 |
target_compile_definitions(PkgConfig::GroongaxxHash_pkg_libxxhash |
| 51 |
INTERFACE XXH_INLINE_ALL) |
| 52 |
endif() |
| 53 |
add_library(Groonga::xxhash ALIAS PkgConfig::GroongaxxHash_pkg_libxxhash) |
| 54 |
endif() |
| 55 |
endif() |
| 56 |
endif() |
| 57 |
|
| 58 |
include(FindPackageHandleStandardArgs) |
| 59 |
find_package_handle_standard_args(GroongaxxHash |
| 60 |
REQUIRED_VARS GroongaxxHash_FOUND) |