]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/cpp/cmake_modules/FindRapidJSONAlt.cmake
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / cmake_modules / FindRapidJSONAlt.cmake
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 set(find_package_args)
19 if(RapidJSONAlt_FIND_VERSION)
20 list(APPEND find_package_args ${RapidJSONAlt_FIND_VERSION})
21 endif()
22 if(RapidJSONAlt_FIND_QUIETLY)
23 list(APPEND find_package_args QUIET)
24 endif()
25 find_package(RapidJSON ${find_package_args})
26 if(RapidJSON_FOUND)
27 set(RapidJSONAlt_FOUND TRUE)
28 set(RAPIDJSON_INCLUDE_DIR ${RAPIDJSON_INCLUDE_DIRS})
29 return()
30 endif()
31
32 if(RapidJSON_ROOT)
33 find_path(RAPIDJSON_INCLUDE_DIR
34 NAMES rapidjson/rapidjson.h
35 PATHS ${RapidJSON_ROOT}
36 NO_DEFAULT_PATH
37 PATH_SUFFIXES "include")
38 else()
39 find_path(RAPIDJSON_INCLUDE_DIR
40 NAMES rapidjson/rapidjson.h
41 PATH_SUFFIXES "include")
42 endif()
43
44 if(RAPIDJSON_INCLUDE_DIR)
45 file(READ "${RAPIDJSON_INCLUDE_DIR}/rapidjson/rapidjson.h" RAPIDJSON_H_CONTENT)
46 string(REGEX MATCH "#define RAPIDJSON_MAJOR_VERSION ([0-9]+)"
47 RAPIDJSON_MAJOR_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
48 string(REGEX REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_MAJOR_VERSION
49 "${RAPIDJSON_MAJOR_VERSION_DEFINITION}")
50 string(REGEX MATCH "#define RAPIDJSON_MINOR_VERSION ([0-9]+)"
51 RAPIDJSON_MINOR_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
52 string(REGEX REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_MINOR_VERSION
53 "${RAPIDJSON_MINOR_VERSION_DEFINITION}")
54 string(REGEX MATCH "#define RAPIDJSON_PATCH_VERSION ([0-9]+)"
55 RAPIDJSON_PATCH_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
56 string(REGEX REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_PATCH_VERSION
57 "${RAPIDJSON_PATCH_VERSION_DEFINITION}")
58 if("${RAPIDJSON_MAJOR_VERSION}" STREQUAL ""
59 OR "${RAPIDJSON_MINOR_VERSION}" STREQUAL ""
60 OR "${RAPIDJSON_PATCH_VERSION}" STREQUAL "")
61 set(RAPIDJSON_VERSION "0.0.0")
62 else()
63 set(RAPIDJSON_VERSION
64 "${RAPIDJSON_MAJOR_VERSION}.${RAPIDJSON_MINOR_VERSION}.${RAPIDJSON_PATCH_VERSION}"
65 )
66 endif()
67 endif()
68
69 find_package_handle_standard_args(
70 RapidJSONAlt
71 REQUIRED_VARS RAPIDJSON_INCLUDE_DIR
72 VERSION_VAR RAPIDJSON_VERSION)