You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by la...@apache.org on 2023/07/05 17:15:54 UTC

[impala] 01/02: IMPALA-12263: Build with C++ Avro library when USE_AVRO_CPP is true

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

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

commit 736b508e75378dc5ec117c10c79b1333ac4cfee7
Author: Tamas Mate <tm...@cloudera.com>
AuthorDate: Mon Jul 3 16:39:40 2023 +0200

    IMPALA-12263: Build with C++ Avro library when USE_AVRO_CPP is true
    
    This change updates the AVRO CMake module to use the C++ Avro library
    when USE_AVRO_CPP is set to true. This is the next step towards Avro
    backend update.
    
    Building with the C++ library fails at this point.
    
    Testing:
     - Manually tested configuring the project with USE_AVRO_CPP
    
    Change-Id: I0a81c3f7ab5a6651d507d8d9fac77ea17b8bb1a1
    Reviewed-on: http://gerrit.cloudera.org:8080/20156
    Reviewed-by: Daniel Becker <da...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 CMakeLists.txt               |  1 +
 cmake_modules/FindAvro.cmake | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f91ae26a..a0f7a210f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -346,6 +346,7 @@ message(STATUS "RapidJson include dir: " ${RAPIDJSON_INCLUDE_DIR})
 # find Avro headers and libs
 find_package(Avro REQUIRED)
 IMPALA_ADD_THIRDPARTY_LIB(avro ${AVRO_INCLUDE_DIR} ${AVRO_STATIC_LIB} "")
+message(STATUS "Use C++ AVRO library: " $ENV{USE_AVRO_CPP})
 
 # find ORC headers and libs
 find_package(Orc REQUIRED)
diff --git a/cmake_modules/FindAvro.cmake b/cmake_modules/FindAvro.cmake
index 48f5b38f3..0b4e8fe92 100644
--- a/cmake_modules/FindAvro.cmake
+++ b/cmake_modules/FindAvro.cmake
@@ -26,12 +26,24 @@ set(AVRO_SEARCH_HEADER_PATHS ${AVRO_ROOT}/include)
 
 set(AVRO_SEARCH_LIB_PATH ${AVRO_ROOT}/lib)
 
-find_path(AVRO_INCLUDE_DIR NAMES avro/schema.h schema.h PATHS
-  ${AVRO_SEARCH_HEADER_PATHS}
+set(AVRO_LIB_NAME "libavro.a")
+set(AVRO_PROBE_INCLUDE_NAME_1 "avro/schema.h")
+set(AVRO_PROBE_INCLUDE_NAME_2 "schema.h")
+
+# Search for the AVRO C++ library when USE_AVRO_CPP environment variable is true.
+string(TOUPPER $ENV{USE_AVRO_CPP} USE_AVRO_CPP)
+if (USE_AVRO_CPP)
+  set(AVRO_LIB_NAME "libavrocpp_s.a")
+  set(AVRO_PROBE_INCLUDE_NAME_1 "avro/Schema.hh")
+  set(AVRO_PROBE_INCLUDE_NAME_2 "Schema.hh")
+endif()
+
+find_path(AVRO_INCLUDE_DIR NAMES ${AVRO_PROBE_INCLUDE_NAME_1} ${AVRO_PROBE_INCLUDE_NAME_2}
+  PATHS ${AVRO_SEARCH_HEADER_PATHS}
   # make sure we don't accidentally pick up a different version
   NO_DEFAULT_PATH)
 
-find_library(AVRO_STATIC_LIB NAMES libavro.a PATHS ${AVRO_SEARCH_LIB_PATH})
+find_library(AVRO_STATIC_LIB NAMES ${AVRO_LIB_NAME} PATHS ${AVRO_SEARCH_LIB_PATH})
 
 if(NOT AVRO_STATIC_LIB)
   message(FATAL_ERROR "Avro includes and libraries NOT found. "