Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ option(BUILD_ENABLE_AVX512
"Enable build with AVX512 at compile time"
OFF)

option(ORC_PACKAGE_KIND
"Arbitrary string that identifies the kind of package"
"")

# Make sure that a build type is selected
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to ReleaseWithDebugInfo")
Expand Down
59 changes: 44 additions & 15 deletions cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ExternalProject_Add (orc-format_ep
# ----------------------------------------------------------------------
# Snappy

if (NOT "${SNAPPY_HOME}" STREQUAL "")
if (NOT "${SNAPPY_HOME}" STREQUAL "" OR ORC_PACKAGE_KIND STREQUAL "conan")
find_package (Snappy REQUIRED)
set(SNAPPY_VENDORED FALSE)
else ()
Expand All @@ -109,12 +109,18 @@ endif ()

add_library (orc_snappy INTERFACE)
add_library (orc::snappy ALIAS orc_snappy)
if (ORC_PREFER_STATIC_SNAPPY AND ${SNAPPY_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_link_libraries(orc_snappy INTERFACE ${Snappy_LIBRARIES})
elseif (ORC_PREFER_STATIC_SNAPPY AND ${SNAPPY_STATIC_LIB})
target_link_libraries(orc_snappy INTERFACE ${SNAPPY_STATIC_LIB})
else ()
target_link_libraries(orc_snappy INTERFACE ${SNAPPY_LIBRARY})
endif ()
target_include_directories (orc_snappy SYSTEM INTERFACE ${SNAPPY_INCLUDE_DIR})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_include_directories (orc_snappy SYSTEM INTERFACE ${Snappy_INCLUDE_DIR})
else()
target_include_directories (orc_snappy SYSTEM INTERFACE ${SNAPPY_INCLUDE_DIR})
endif ()

if (SNAPPY_VENDORED)
add_dependencies (orc_snappy snappy_ep)
Expand All @@ -127,7 +133,7 @@ endif ()
# ----------------------------------------------------------------------
# ZLIB

if (NOT "${ZLIB_HOME}" STREQUAL "")
if (NOT "${ZLIB_HOME}" STREQUAL "" OR ORC_PACKAGE_KIND STREQUAL "conan")
find_package (ZLIB REQUIRED)
set(ZLIB_VENDORED FALSE)
else ()
Expand Down Expand Up @@ -161,7 +167,9 @@ endif ()

add_library (orc_zlib INTERFACE)
add_library (orc::zlib ALIAS orc_zlib)
if (ORC_PREFER_STATIC_ZLIB AND ${ZLIB_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_link_libraries (orc_zlib INTERFACE ${ZLIB_LIBRARIES})
elseif (ORC_PREFER_STATIC_ZLIB AND ${ZLIB_STATIC_LIB})
target_link_libraries (orc_zlib INTERFACE ${ZLIB_STATIC_LIB})
else ()
target_link_libraries (orc_zlib INTERFACE ${ZLIB_LIBRARY})
Expand All @@ -179,7 +187,7 @@ endif ()
# ----------------------------------------------------------------------
# Zstd

if (NOT "${ZSTD_HOME}" STREQUAL "")
if (NOT "${ZSTD_HOME}" STREQUAL "" OR ORC_PACKAGE_KIND STREQUAL "conan")
find_package (ZSTD REQUIRED)
set(ZSTD_VENDORED FALSE)
else ()
Expand Down Expand Up @@ -220,12 +228,18 @@ endif ()

add_library (orc_zstd INTERFACE)
add_library (orc::zstd ALIAS orc_zstd)
if (ORC_PREFER_STATIC_ZSTD AND ${ZSTD_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_link_libraries (orc_zstd INTERFACE ${zstd_LIBRARIES})
elseif (ORC_PREFER_STATIC_ZSTD AND ${ZSTD_STATIC_LIB})
target_link_libraries (orc_zstd INTERFACE ${ZSTD_STATIC_LIB})
else ()
target_link_libraries (orc_zstd INTERFACE ${ZSTD_LIBRARY})
endif ()
target_include_directories (orc_zstd SYSTEM INTERFACE ${ZSTD_INCLUDE_DIR})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_include_directories (orc_zstd SYSTEM INTERFACE ${zstd_INCLUDE_DIR})
else()
target_include_directories (orc_zstd SYSTEM INTERFACE ${ZSTD_INCLUDE_DIR})
endif ()

if (ZSTD_VENDORED)
add_dependencies (orc_zstd zstd_ep)
Expand All @@ -238,7 +252,7 @@ endif ()
# ----------------------------------------------------------------------
# LZ4

if (NOT "${LZ4_HOME}" STREQUAL "")
if (NOT "${LZ4_HOME}" STREQUAL "" OR ORC_PACKAGE_KIND STREQUAL "conan")
find_package (LZ4 REQUIRED)
set(LZ4_VENDORED FALSE)
else ()
Expand Down Expand Up @@ -272,12 +286,18 @@ endif ()

add_library (orc_lz4 INTERFACE)
add_library (orc::lz4 ALIAS orc_lz4)
if (ORC_PREFER_STATIC_LZ4 AND ${LZ4_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_link_libraries (orc_lz4 INTERFACE ${lz4_LIBRARIES})
elseif (ORC_PREFER_STATIC_LZ4 AND ${LZ4_STATIC_LIB})
target_link_libraries (orc_lz4 INTERFACE ${LZ4_STATIC_LIB})
else ()
target_link_libraries (orc_lz4 INTERFACE ${LZ4_LIBRARY})
endif ()
target_include_directories (orc_lz4 SYSTEM INTERFACE ${LZ4_INCLUDE_DIR})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_include_directories (orc_lz4 SYSTEM INTERFACE ${lz4_INCLUDE_DIR})
else()
target_include_directories (orc_lz4 SYSTEM INTERFACE ${LZ4_INCLUDE_DIR})
endif ()

if (LZ4_VENDORED)
add_dependencies (orc_lz4 lz4_ep)
Expand Down Expand Up @@ -393,7 +413,7 @@ endif ()
# ----------------------------------------------------------------------
# Protobuf

if (NOT "${PROTOBUF_HOME}" STREQUAL "")
if (NOT "${PROTOBUF_HOME}" STREQUAL "" OR ORC_PACKAGE_KIND STREQUAL "conan")
find_package (Protobuf REQUIRED)
set(PROTOBUF_VENDORED FALSE)
else ()
Expand Down Expand Up @@ -442,14 +462,23 @@ add_library (orc::protobuf ALIAS orc_protobuf)
add_library (orc_protoc INTERFACE)
add_library (orc::protoc ALIAS orc_protoc)

if (ORC_PREFER_STATIC_PROTOBUF AND ${PROTOBUF_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_link_libraries (orc_protobuf INTERFACE ${protobuf_LIBRARIES})
elseif (ORC_PREFER_STATIC_PROTOBUF AND ${PROTOBUF_STATIC_LIB})
target_link_libraries (orc_protobuf INTERFACE ${PROTOBUF_STATIC_LIB})
else ()
target_link_libraries (orc_protobuf INTERFACE ${PROTOBUF_LIBRARY})
endif()
target_include_directories (orc_protobuf SYSTEM INTERFACE ${PROTOBUF_INCLUDE_DIR})
if (ORC_PACKAGE_KIND STREQUAL "conan")
target_include_directories (orc_protobuf SYSTEM INTERFACE ${protobuf_INCLUDE_DIR})
else ()
target_include_directories (orc_protobuf SYSTEM INTERFACE ${PROTOBUF_INCLUDE_DIR})
endif ()

if (ORC_PREFER_STATIC_PROTOBUF AND ${PROTOC_STATIC_LIB})
if (ORC_PACKAGE_KIND STREQUAL "conan")
cmake_path(GET protobuf_INCLUDE_DIR PARENT_PATH PROTOBUF_HOME)
set(PROTOBUF_EXECUTABLE ${PROTOBUF_HOME}/bin/protoc)
elseif (ORC_PREFER_STATIC_PROTOBUF AND ${PROTOC_STATIC_LIB})
target_link_libraries (orc_protoc INTERFACE ${PROTOC_STATIC_LIB})
else ()
target_link_libraries (orc_protoc INTERFACE ${PROTOC_LIBRARY})
Expand Down
34 changes: 34 additions & 0 deletions conan/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

sources:
"1.9.2":
url: "https://dlcdn.apache.org/orc/orc-1.9.2/orc-1.9.2.tar.gz"
sha256: "7f46f2c184ecefd6791f1a53fb062286818bd8710c3f08b94dd3cac365e240ee"
"1.8.6":
url: "https://dlcdn.apache.org/orc/orc-1.8.6/orc-1.8.6.tar.gz"
sha256: "5675b18118df4dd7f86cc6ba859ed75b425ea1b7ddff805e1d671a17fd57d7f7"
"1.7.10":
url: "https://dlcdn.apache.org/orc/orc-1.7.10/orc-1.7.10.tar.gz"
sha256: "85aef9368dc9bcdffaaf10010b66dfe053ce22f30b64854f63852248164686a3"
patches:
"1.9.2":
- patch_file: "patches/0001-thirdparty-toolchain-1.9.x.patch"
"1.8.6":
- patch_file: "patches/0001-thirdparty-toolchain-1.8.x.patch"
"1.7.10":
- patch_file: "patches/0001-thirdparty-toolchain-1.7.x.patch"
120 changes: 120 additions & 0 deletions conan/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
from conan.tools.scm import Version

import os

required_conan_version = ">=1.54.0"

class OrcRecipe(ConanFile):
name = "orc"
description = "The smallest, fastest columnar storage for Hadoop workloads"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://orc.apache.org/"
topics = ("orc", "columnar-storage", "hadoop")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _minimum_cpp_standard(self):
return 11 if Version(self.version) < "1.9.0" else 17

def source(self):
if not self.version in self.conan_data.get("sources", {}):
import shutil
top_level = os.environ.get("ORC_HOME")
shutil.copytree(os.path.join(top_level, "c++"),
os.path.join(self.source_folder, "c++"))
shutil.copytree(os.path.join(top_level, "cmake_modules"),
os.path.join(self.source_folder, "cmake_modules"))
top_level_files = [
"CMakeLists.txt",
"LICENSE",
"NOTICE",
]
for top_level_file in top_level_files:
shutil.copy(os.path.join(top_level, top_level_file),
self.source_folder)
return
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def export_sources(self):
export_conandata_patches(self)

def requirements(self):
self.requires("protobuf/3.19.4")
self.requires("zlib/1.3")
self.requires("snappy/1.1.9")
self.requires("lz4/1.9.4")
self.requires("zstd/1.5.5")

def layout(self):
cmake_layout(self, src_folder="src", build_folder="build")

def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["ORC_PACKAGE_KIND"] = "conan"
tc.variables["BUILD_JAVA"] = "OFF"
tc.variables["BUILD_CPP_TESTS"] = "OFF"
tc.variables["BUILD_TOOLS"] = "OFF"
tc.variables["BUILD_LIBHDFSPP"] = "OFF"
tc.variables["BUILD_POSITION_INDEPENDENT_LIB"] = bool(self.options.get_safe("fPIC", True))
tc.variables["INSTALL_VENDORED_LIBS"] = "OFF"
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(self, pattern="NOTICE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "orc")
self.cpp_info.set_property("cmake_target_name", "orc::orc")
self.cpp_info.set_property("pkg_config_name", "liborc")
self.cpp_info.libs = ["orc"]
Loading