[C++] Check required RapidJSON version

This commit is contained in:
Sutou Kouhei committed 2019-06-02 11:48:54 +09:00
1 parent aa18d257d0
commit 3271d87695
2 files changed
+42 -6

No files matched your search

+33 -1
View File
@@ -25,4 +25,36 @@ else()
find_path(RAPIDJSON_INCLUDE_DIR NAMES rapidjson/rapidjson.h PATH_SUFFIXES "include")
endif()
find_package_handle_standard_args(RapidJSONAlt REQUIRED_VARS RAPIDJSON_INCLUDE_DIR)
if(RAPIDJSON_INCLUDE_DIR)
file(READ "${RAPIDJSON_INCLUDE_DIR}/rapidjson/rapidjson.h" RAPIDJSON_H_CONTENT)
string(REGEX MATCH "#define RAPIDJSON_MAJOR_VERSION ([0-9]+)"
RAPIDJSON_MAJOR_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
string(REGEX
REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_MAJOR_VERSION
"${RAPIDJSON_MAJOR_VERSION_DEFINITION}")
string(REGEX MATCH "#define RAPIDJSON_MINOR_VERSION ([0-9]+)"
RAPIDJSON_MINOR_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
string(REGEX
REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_MINOR_VERSION
"${RAPIDJSON_MINOR_VERSION_DEFINITION}")
string(REGEX MATCH "#define RAPIDJSON_PATCH_VERSION ([0-9]+)"
RAPIDJSON_PATCH_VERSION_DEFINITION "${RAPIDJSON_H_CONTENT}")
string(REGEX
REPLACE "^.+ ([0-9]+)$" "\\1" RAPIDJSON_PATCH_VERSION
"${RAPIDJSON_PATCH_VERSION_DEFINITION}")
if("${RAPIDJSON_MAJOR_VERSION}" STREQUAL ""
OR "${RAPIDJSON_MINOR_VERSION}" STREQUAL ""
OR "${RAPIDJSON_PATCH_VERSION}" STREQUAL "")
set(RAPIDJSON_VERSION "0.0.0")
else()
set(
RAPIDJSON_VERSION
"${RAPIDJSON_MAJOR_VERSION}.${RAPIDJSON_MINOR_VERSION}.${RAPIDJSON_PATCH_VERSION}")
endif()
endif()
find_package_handle_standard_args(RapidJSONAlt
REQUIRED_VARS
RAPIDJSON_INCLUDE_DIR
VERSION_VAR
RAPIDJSON_VERSION)
+9 -5
View File
@@ -1402,15 +1402,19 @@ macro(build_rapidjson)
add_dependencies(rapidjson rapidjson_ep)
endmacro()
# TODO: Check for 1.1.0+
if(ARROW_WITH_RAPIDJSON)
set(ARROW_RAPIDJSON_REQUIRED_VERSION "1.1.0")
if(RapidJSON_SOURCE STREQUAL "AUTO")
# Fedora packages place the package information at the wrong location.
# https://bugzilla.redhat.com/show_bug.cgi?id=1680400
find_package(RapidJSON QUIET HINTS "${CMAKE_ROOT}")
find_package(RapidJSON
${ARROW_RAPIDJSON_REQUIRED_VERSION}
QUIET
HINTS
"${CMAKE_ROOT}")
if(NOT RapidJSON_FOUND)
# Ubuntu / Debian don't package the CMake config
find_package(RapidJSONAlt)
find_package(RapidJSONAlt ${ARROW_RAPIDJSON_REQUIRED_VERSION})
endif()
if(NOT RapidJSON_FOUND AND NOT RapidJSONAlt_FOUND)
build_rapidjson()
@@ -1420,10 +1424,10 @@ if(ARROW_WITH_RAPIDJSON)
elseif(RapidJSON_SOURCE STREQUAL "SYSTEM")
# Fedora packages place the package information at the wrong location.
# https://bugzilla.redhat.com/show_bug.cgi?id=1680400
find_package(RapidJSON HINTS "${CMAKE_ROOT}")
find_package(RapidJSON ${ARROW_RAPIDJSON_REQUIRED_VERSION} HINTS "${CMAKE_ROOT}")
if(NOT RapidJSON_FOUND)
# Ubuntu / Debian don't package the CMake config
find_package(RapidJSONAlt REQUIRED)
find_package(RapidJSONAlt ${ARROW_RAPIDJSON_REQUIRED_VERSION} REQUIRED)
endif()
endif()