File: FindGroongaRapidJSON.cmake

package info (click to toggle)
groonga 15.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 171,500 kB
  • sloc: ansic: 772,536; cpp: 51,530; ruby: 40,538; javascript: 10,250; yacc: 7,045; sh: 5,622; python: 2,821; makefile: 1,677
file content (72 lines) | stat: -rw-r--r-- 2,904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright(C) 2023  Sutou Kouhei <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

if(GroongaRapidJSON_FOUND)
  return()
endif()

set(find_package_args "")
set(pkg_check_modules_version "")
if(GroongaRapidJSON_FIND_VERSION)
  list(APPEND find_package_args ${GroongaRapidJSON_FIND_VERSION})
  set(pkg_check_modules_version ">=${GroongaRapidJSON_FIND_VERSION}")
endif()
if(GroongaRapidJSON_FIND_QUIETLY)
  list(APPEND find_package_args QUIET)
endif()
find_package(RapidJSON ${find_package_args})
set(GroongaRapidJSON_FOUND ${RapidJSON_FOUND})
if(GroongaRapidJSON_FOUND)
  add_library(Groonga::RapidJSON INTERFACE IMPORTED)
  target_include_directories(Groonga::RapidJSON
                             INTERFACE "${RAPIDJSON_INCLUDE_DIRS}")
endif()

if(NOT GroongaRapidJSON_FOUND)
  find_package(PkgConfig)
  if(PkgConfig_FOUND)
    if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
      pkg_check_modules(GroongaRapidJSON_pkg_RapidJSON IMPORTED_TARGET
                        "RapidJSON${pkg_check_modules_version}")
    else()
      pkg_check_modules(GroongaRapidJSON_pkg_RapidJSON IMPORTED_TARGET GLOBAL
                        "RapidJSON${pkg_check_modules_version}")
    endif()
    set(GroongaRapidJSON_FOUND ${GroongaRapidJSON_pkg_RapidJSON_FOUND})
    if(GroongaRapidJSON_FOUND)
      add_library(Groonga::RapidJSON ALIAS
                  PkgConfig::GroongaRapidJSON_pkg_RapidJSON)
    endif()
  endif()
endif()

if(NOT GroongaRapidJSON_FOUND)
  find_file(GroongaRapidJSON_rapidjson_h rapidjson/rapidjson.h)
  if(GroongaRapidJSON_rapidjson_h)
    add_library(Groonga::RapidJSON INTERFACE IMPORTED)
    get_filename_component(GroongaRapidJSON_INCLUDE_DIR
                           "${GroongaRapidJSON_rapidjson_h}" DIRECTORY)
    get_filename_component(GroongaRapidJSON_INCLUDE_DIR
                           "${GroongaRapidJSON_INCLUDE_DIR}" DIRECTORY)
    target_include_directories(Groonga::RapidJSON
                               INTERFACE "${GroongaRapidJSON_INCLUDE_DIR}")
    set(GroongaRapidJSON_FOUND TRUE)
  endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GroongaRapidJSON
                                  REQUIRED_VARS GroongaRapidJSON_FOUND)