Skip to content

Commit

Permalink
Fix wrong ORC package
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 24, 2023
1 parent ab34fb0 commit 1cea145
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ci/docker/fedora-38-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ RUN dnf update -y && \
java-latest-openjdk-devel \
java-latest-openjdk-headless \
json-devel \
liborc-devel \
libzstd-devel \
llvm-devel \
lz4-devel \
make \
ninja-build \
openssl-devel \
orc-devel \
protobuf-devel \
python \
python-devel \
Expand Down
6 changes: 3 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,10 @@ if(ARROW_WITH_ZSTD)
endif()

if(ARROW_ORC)
list(APPEND ARROW_SHARED_LINK_LIBS orc::liborc ${ARROW_PROTOBUF_LIBPROTOBUF})
list(APPEND ARROW_STATIC_LINK_LIBS orc::liborc ${ARROW_PROTOBUF_LIBPROTOBUF})
list(APPEND ARROW_SHARED_LINK_LIBS orc::orc ${ARROW_PROTOBUF_LIBPROTOBUF})
list(APPEND ARROW_STATIC_LINK_LIBS orc::orc ${ARROW_PROTOBUF_LIBPROTOBUF})
if(ORC_SOURCE STREQUAL "SYSTEM")
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS orc::liborc
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS orc::orc
${ARROW_PROTOBUF_LIBPROTOBUF})
endif()
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
# specific language governing permissions and limitations
# under the License.

# - Find Apache ORC C++ (orc/orc-config.h, liborc.a)
# This module defines
# ORC_INCLUDE_DIR, directory containing headers
# ORC_STATIC_LIB, path to liborc.a
# ORC_FOUND, whether orc has been found
if(orcAlt_FOUND)
return()
endif()

if(ORC_FOUND)
set(find_package_args)
if(orcAlt_FIND_VERSION)
list(APPEND find_package_args ${orcAlt_FIND_VERSION})
endif()
if(orcAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
find_package(orc ${find_package_args})
if(orc_FOUND)
set(orcAlt_FOUND TRUE)
return()
endif()

Expand All @@ -45,15 +52,13 @@ else()
PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES})
endif()

if(ORC_STATIC_LIB AND ORC_INCLUDE_DIR)
set(ORC_FOUND TRUE)
add_library(orc::liborc STATIC IMPORTED)
set_target_properties(orc::liborc
PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${ORC_INCLUDE_DIR}")
else()
if(ORC_FIND_REQUIRED)
message(FATAL_ERROR "ORC library was required in toolchain and unable to locate")
find_package_handle_standard_args(orcAlt REQUIRED_VARS ORC_STATIC_LIB ORC_INCLUDE_DIR)

if(orcAlt_FOUND)
if(NOT TARGET orc::orc)
add_library(orc::orc STATIC IMPORTED)
set_target_properties(orc::orc
PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${ORC_INCLUDE_DIR}")
endif()
set(ORC_FOUND FALSE)
endif()
34 changes: 21 additions & 13 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ set(ARROW_THIRDPARTY_DEPENDENCIES
lz4
nlohmann_json
opentelemetry-cpp
ORC
orc
re2
Protobuf
RapidJSON
Expand Down Expand Up @@ -94,6 +94,14 @@ if("${re2_SOURCE}" STREQUAL "" AND NOT "${RE2_SOURCE}" STREQUAL "")
set(re2_SOURCE ${RE2_SOURCE})
endif()

# For backward compatibility. We use "ORC_SOURCE" if "orc_SOURCE"
# isn't specified and "ORC_SOURCE" is specified.
# We renamed "ORC" dependency name to "orc" in 15.0.0 because
# upstream uses "orc" not "ORC" as package name.
if("${orc_SOURCE}" STREQUAL "" AND NOT "${ORC_SOURCE}" STREQUAL "")
set(orc_SOURCE ${ORC_SOURCE})
endif()

# For backward compatibility. We use "RE2_ROOT" if "re2_ROOT"
# isn't specified and "RE2_ROOT" is specified.
if("${re2_ROOT}" STREQUAL "" AND NOT "${RE2_ROOT}" STREQUAL "")
Expand Down Expand Up @@ -193,7 +201,7 @@ macro(build_dependency DEPENDENCY_NAME)
build_nlohmann_json()
elseif("${DEPENDENCY_NAME}" STREQUAL "opentelemetry-cpp")
build_opentelemetry()
elseif("${DEPENDENCY_NAME}" STREQUAL "ORC")
elseif("${DEPENDENCY_NAME}" STREQUAL "orc")
build_orc()
elseif("${DEPENDENCY_NAME}" STREQUAL "Protobuf")
build_protobuf()
Expand Down Expand Up @@ -4423,31 +4431,31 @@ macro(build_orc)

set(ORC_VENDORED 1)

add_library(orc::liborc STATIC IMPORTED)
set_target_properties(orc::liborc PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}")
target_include_directories(orc::liborc BEFORE INTERFACE "${ORC_INCLUDE_DIR}")
set(ORC_LINK_LIBRARIES LZ4::lz4 ZLIB::ZLIB ${ARROW_ZSTD_LIBZSTD} ${Snappy_TARGET})
add_library(orc::orc STATIC IMPORTED)
set_target_properties(orc::orc PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}")
target_include_directories(orc::orc BEFORE INTERFACE "${ORC_INCLUDE_DIR}")
target_link_libraries(orc::orc INTERFACE LZ4::lz4 ZLIB::ZLIB ${ARROW_ZSTD_LIBZSTD}
${Snappy_TARGET})
# Protobuf generated files may use ABSL_DCHECK*() and
# absl::log_internal_check_op is needed for them.
if(TARGET absl::log_internal_check_op)
list(APPEND ORC_LINK_LIBRARIES absl::log_internal_check_op)
target_link_libraries(orc::orc INTERFACE absl::log_internal_check_op)
endif()
if(NOT MSVC)
if(NOT APPLE AND ARROW_ENABLE_THREADING)
list(APPEND ORC_LINK_LIBRARIES Threads::Threads)
target_link_libraries(orc::orc INTERFACE Threads::Threads)
endif()
list(APPEND ORC_LINK_LIBRARIES ${CMAKE_DL_LIBS})
target_link_libraries(orc::orc INTERFACE ${CMAKE_DL_LIBS})
endif()
target_link_libraries(orc::liborc INTERFACE ${ORC_LINK_LIBRARIES})

add_dependencies(toolchain orc_ep)
add_dependencies(orc::liborc orc_ep)
add_dependencies(orc::orc orc_ep)

list(APPEND ARROW_BUNDLED_STATIC_LIBS orc::liborc)
list(APPEND ARROW_BUNDLED_STATIC_LIBS orc::orc)
endmacro()

if(ARROW_ORC)
resolve_dependency(ORC)
resolve_dependency(orc HAVE_ALT TRUE)
message(STATUS "Found ORC static library: ${ORC_STATIC_LIB}")
message(STATUS "Found ORC headers: ${ORC_INCLUDE_DIR}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
set(ORC_STATIC_TEST_LINK_LIBS orc::orc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
Expand Down

0 comments on commit 1cea145

Please sign in to comment.