Uploaded image for project: 'ORC'
  1. ORC
  2. ORC-1732

[C++] Can't detect Protobuf installed by Homebrew on macOS

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1.0, 2.0.2
    • C++
    • None

    Description

      Downstream issue: https://github.com/apache/arrow/issues/42149

      We can use system Protobuf if we specify one of them:

      • PROTOBUF_HOME environment variable
      • Protobuf_ROOT CMake variable
      • Protobuf_ROOT environment variable
      • PROTOBUF_ROOT CMake variable
      • PROTOBUF_ROOT environment variable

      See also:

      If system Protobuf CMake package is found, we extract include directory from libprotobuf::protoc CMake target:
      https://github.com/apache/orc/blob/8003801e78ff6156a1f18ec62b631d6ba4768b00/cmake_modules/FindProtobuf.cmake#L66

      But libprotobuf::protoc CMake target doesn't have include directory configuration:
      https://github.com/protocolbuffers/protobuf/blob/0302c4c43821ac893e8f1071576f80edef5c6398/cmake/libprotoc.cmake#L19-L20

      If we can't extract include directory, system Protobuf detection is failed:
      https://github.com/apache/orc/blob/8003801e78ff6156a1f18ec62b631d6ba4768b00/cmake_modules/FindProtobuf.cmake#L101-L107

      So we never detect system Protobuf by system Protobuf CMake package.

      FYI: We can extract include directory from protobuf::libprotobuf (not ...::libprotoc) CMake target:

      diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake
      index 82429a23..ab73195c 100644
      --- a/cmake_modules/FindProtobuf.cmake
      +++ b/cmake_modules/FindProtobuf.cmake
      @@ -63,7 +63,7 @@ if (Protobuf_FOUND)
               set (PROTOC_STATIC_LIB protobuf::libprotoc)
           endif ()
       
      -    get_target_property (PROTOBUF_INCLUDE_DIR protobuf::libprotoc INTERFACE_INCLUDE_DIRECTORIES)
      +    get_target_property (PROTOBUF_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
       
       else()
           find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/zero_copy_stream.h HINTS
      

      But there is a test failure with Protobuf 27.1:

      [ RUN      ] TestFileScan.testErrorHandling
      /Users/runner/work/orc/orc/tools/test/TestFileScan.cc:211: Failure
      Expected: (std::string::npos) != (error.find(errorMsg)), actual: 18446744073709551615 vs 18446744073709551615
      Caught exception in /Users/runner/work/orc/orc/examples/corrupt/stripe_footer_bad_column_encodings.orc: bad StripeFooter from zlib(/Users/runner/work/orc/orc/examples/corrupt/stripe_footer_bad_column_encodings.orc from 336 for 79)
      
      [  FAILED  ] TestFileScan.testErrorHandling (126 ms)
      

      See also:

      Attachments

        Issue Links

          Activity

            People

              luffyZ Hao Zou
              kou Kouhei Sutou
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: