You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/06/03 21:46:21 UTC

[arrow] branch master updated: ARROW-5477: [C++] Check required RapidJSON version

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new b6f5979  ARROW-5477: [C++] Check required RapidJSON version
b6f5979 is described below

commit b6f597999f7682dd903e71a93c68eef0f39014ce
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Mon Jun 3 16:46:10 2019 -0500

    ARROW-5477: [C++] Check required RapidJSON version
    
    Author: Sutou Kouhei <ko...@clear-code.com>
    
    Closes #4447 from kou/cpp-rapidjson-version-check and squashes the following commits:
    
    3271d8769 <Sutou Kouhei>  Check required RapidJSON version
---
 cpp/cmake_modules/FindRapidJSONAlt.cmake    | 34 ++++++++++++++++++++++++++++-
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 14 +++++++-----
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/cpp/cmake_modules/FindRapidJSONAlt.cmake b/cpp/cmake_modules/FindRapidJSONAlt.cmake
index b0b99d5..088dd1a 100644
--- a/cpp/cmake_modules/FindRapidJSONAlt.cmake
+++ b/cpp/cmake_modules/FindRapidJSONAlt.cmake
@@ -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)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 5f249c3..bc70912 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -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()