From 95b592d1af867566f4b72948323416a7f339c291 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Thu, 9 Jan 2025 21:19:45 +0800 Subject: [PATCH] Add iceberg_arrow library (#6) Co-authored-by: Sutou Kouhei --- CMakeLists.txt | 24 +++-- README.md | 36 +++++-- api/CMakeLists.txt | 21 ---- cmake_modules/BuildUtils.cmake | 50 +++++++-- cmake_modules/ThirdpartyToolchain.cmake | 132 ++++++++++++++++++++++++ example/CMakeLists.txt | 7 +- example/demo_example.cc | 10 +- src/.DS_Store | Bin 0 -> 6148 bytes src/CMakeLists.txt | 3 +- src/core/icebergConfig.cmake.in | 22 ---- src/{core => iceberg}/CMakeLists.txt | 22 ++-- src/iceberg/IcebergConfig.cmake.in | 80 ++++++++++++++ src/iceberg/arrow/CMakeLists.txt | 78 ++++++++++++++ src/iceberg/arrow/demo_arrow.cc | 33 ++++++ src/iceberg/arrow/demo_arrow.h | 36 +++++++ src/{core => iceberg}/demo_table.cc | 8 +- src/{core => iceberg}/demo_table.h | 4 +- {api => src}/iceberg/puffin.h | 10 +- src/iceberg/puffin/CMakeLists.txt | 56 ++++++++++ src/{ => iceberg}/puffin/demo_puffin.cc | 10 +- src/{ => iceberg}/puffin/demo_puffin.h | 10 +- {api => src}/iceberg/table.h | 10 +- src/puffin/CMakeLists.txt | 27 ----- src/puffin/puffinConfig.cmake.in | 22 ---- 24 files changed, 550 insertions(+), 161 deletions(-) delete mode 100644 api/CMakeLists.txt create mode 100644 cmake_modules/ThirdpartyToolchain.cmake create mode 100644 src/.DS_Store delete mode 100644 src/core/icebergConfig.cmake.in rename src/{core => iceberg}/CMakeLists.txt (64%) create mode 100644 src/iceberg/IcebergConfig.cmake.in create mode 100644 src/iceberg/arrow/CMakeLists.txt create mode 100644 src/iceberg/arrow/demo_arrow.cc create mode 100644 src/iceberg/arrow/demo_arrow.h rename src/{core => iceberg}/demo_table.cc (83%) rename src/{core => iceberg}/demo_table.h (91%) rename {api => src}/iceberg/puffin.h (86%) create mode 100644 src/iceberg/puffin/CMakeLists.txt rename src/{ => iceberg}/puffin/demo_puffin.cc (78%) rename src/{ => iceberg}/puffin/demo_puffin.h (81%) rename {api => src}/iceberg/table.h (86%) delete mode 100644 src/puffin/CMakeLists.txt delete mode 100644 src/puffin/puffinConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 22e24d6..82c6045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,9 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") +list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") -project(iceberg +project(Iceberg VERSION 0.1.0 DESCRIPTION "Iceberg C++ Project" LANGUAGES CXX) @@ -36,22 +36,26 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(ICEBERG_BUILD_STATIC "Build static library" ON) option(ICEBERG_BUILD_SHARED "Build shared library" OFF) option(ICEBERG_BUILD_TESTS "Build tests" ON) +option(ICEBERG_ARROW "Build Arrow" ON) -include(CMakePackageConfigHelpers) -include(CMakeParseArguments) -include(BuildUtils) -include(ExternalProject) -include(FindPackageHandleStandardArgs) include(GNUInstallDirs) - -set(ICEBERG_API_DIR "${CMAKE_SOURCE_DIR}/api") set(ICEBERG_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}") set(ICEBERG_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}") set(ICEBERG_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}") set(ICEBERG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake") set(ICEBERG_INSTALL_DOCDIR "share/doc/${PROJECT_NAME}") -add_subdirectory(api) +if(WIN32 AND NOT MINGW) + set(MSVC_TOOLCHAIN TRUE) +else() + set(MSVC_TOOLCHAIN FALSE) +endif() + +include(CMakeParseArguments) +include(BuildUtils) +include(ThirdpartyToolchain) +include(GenerateExportHeader) + add_subdirectory(src) if(ICEBERG_BUILD_TESTS) diff --git a/README.md b/README.md index 56cedaf..7009aee 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,27 @@ C++ implementation of [Apache Iceberg™](https://iceberg.apache.org/). ```bash cd iceberg-cpp -mkdir build && cd build -cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/iceberg -DICEBERG_BUILD_STATIC=ON -DICEBERG_BUILD_SHARED=ON -cmake --build . -cmake --install . +cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_STATIC=ON -DICEBERG_BUILD_SHARED=ON +cmake --build build +cmake --install build +``` + +### Build and Install Iceberg Arrow Library + +#### Vendored Apache Arrow (default) + +```bash +cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_ARROW=ON +cmake --build build +cmake --install build +``` + +#### Provided Apache Arrow + +```bash +cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_PREFIX_PATH=/path/to/arrow -DICEBERG_ARROW=ON +cmake --build build +cmake --install build ``` ### Build Examples @@ -44,9 +61,14 @@ After installing the core libraries, you can build the examples: ```bash cd iceberg-cpp/example -mkdir build && cd build -cmake .. -DCMAKE_PREFIX_PATH=/tmp/iceberg -cmake --build . +cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/install +cmake --build build +``` + +If you are using provided Apache Arrow, you need to include `/path/to/arrow` in `CMAKE_PREFIX_PATH` as below. + +```bash +cmake -S . -B build -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow" ``` ## Contribute diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt deleted file mode 100644 index 5a481c8..0000000 --- a/api/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iceberg" - DESTINATION "${ICEBERG_INSTALL_INCLUDEDIR}" - FILES_MATCHING - PATTERN "*.h") diff --git a/cmake_modules/BuildUtils.cmake b/cmake_modules/BuildUtils.cmake index 4d6bf1d..8a30753 100644 --- a/cmake_modules/BuildUtils.cmake +++ b/cmake_modules/BuildUtils.cmake @@ -18,6 +18,8 @@ # Borrowed the file from Apache Arrow: # https://github.com/apache/arrow/blob/main/cpp/cmake_modules/BuildUtils.cmake +include(CMakePackageConfigHelpers) + function(iceberg_install_cmake_package PACKAGE_NAME EXPORT_NAME) set(CONFIG_CMAKE "${PACKAGE_NAME}Config.cmake") set(BUILT_CONFIG_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_CMAKE}") @@ -37,12 +39,11 @@ function(iceberg_install_cmake_package PACKAGE_NAME EXPORT_NAME) FILE "${TARGETS_CMAKE}") endfunction() -function(ADD_ICEBERG_LIB LIB_NAME) +function(add_iceberg_lib LIB_NAME) set(options) set(one_value_args BUILD_SHARED BUILD_STATIC - CMAKE_PACKAGE_NAME INSTALL_ARCHIVE_DIR INSTALL_LIBRARY_DIR INSTALL_RUNTIME_DIR @@ -146,8 +147,8 @@ function(ADD_ICEBERG_LIB LIB_NAME) "$" PRIVATE ${ARG_SHARED_PRIVATE_LINK_LIBS}) - install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL} - EXPORT ${LIB_NAME}_targets + install(TARGETS ${LIB_NAME}_shared + EXPORT iceberg_targets ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR} LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR} @@ -201,8 +202,8 @@ function(ADD_ICEBERG_LIB LIB_NAME) PUBLIC "$") endif() - install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL} - EXPORT ${LIB_NAME}_targets + install(TARGETS ${LIB_NAME}_static + EXPORT iceberg_targets ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR} LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR} @@ -210,8 +211,16 @@ function(ADD_ICEBERG_LIB LIB_NAME) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() - if(ARG_CMAKE_PACKAGE_NAME) - iceberg_install_cmake_package(${ARG_CMAKE_PACKAGE_NAME} ${LIB_NAME}_targets) + # generate export header file + if(BUILD_SHARED) + generate_export_header(${LIB_NAME}_shared BASE_NAME ${LIB_NAME}) + if(BUILD_STATIC) + string(TOUPPER ${LIB_NAME} LIB_NAME_UPPER) + target_compile_definitions(${LIB_NAME}_static + PUBLIC ${LIB_NAME_UPPER}_STATIC_DEFINE) + endif() + elseif(BUILD_STATIC) + generate_export_header(${LIB_NAME}_static BASE_NAME ${LIB_NAME}) endif() # Modify variable in calling scope @@ -221,3 +230,28 @@ function(ADD_ICEBERG_LIB LIB_NAME) PARENT_SCOPE) endif() endfunction() + +function(iceberg_install_all_headers PATH) + set(options) + set(one_value_args) + set(multi_value_args PATTERN) + cmake_parse_arguments(ARG + "${options}" + "${one_value_args}" + "${multi_value_args}" + ${ARGN}) + if(NOT ARG_PATTERN) + set(ARG_PATTERN "*.h" "*.hpp") + endif() + file(GLOB CURRENT_DIRECTORY_HEADERS ${ARG_PATTERN}) + + set(PUBLIC_HEADERS) + foreach(HEADER ${CURRENT_DIRECTORY_HEADERS}) + get_filename_component(HEADER_BASENAME ${HEADER} NAME) + if(HEADER_BASENAME MATCHES "internal") + continue() + endif() + list(APPEND PUBLIC_HEADERS ${HEADER}) + endforeach() + install(FILES ${PUBLIC_HEADERS} DESTINATION "${ICEBERG_INSTALL_INCLUDEDIR}/${PATH}") +endfunction() diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake new file mode 100644 index 0000000..efd587a --- /dev/null +++ b/cmake_modules/ThirdpartyToolchain.cmake @@ -0,0 +1,132 @@ +# 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. + +# Accumulate all dependencies to provide suitable static link parameters to the +# third party libraries. +set(ICEBERG_SYSTEM_DEPENDENCIES) +set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS) + +# ---------------------------------------------------------------------- +# Versions and URLs for toolchain builds + +set(ICEBERG_ARROW_BUILD_VERSION "18.1.0") +set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM + "2dc8da5f8796afe213ecc5e5aba85bb82d91520eff3cf315784a52d0fa61d7fc") + +if(DEFINED ENV{ICEBERG_ARROW_URL}) + set(ARROW_SOURCE_URL "$ENV{ICEBERG_ARROW_URL}") +else() + set(ARROW_SOURCE_URL + "https://www.apache.org/dyn/closer.lua?action=download&filename=/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz" + "https://downloads.apache.org/arrow/arrow-${ICEBERG_ARROW_BUILD_VERSION}/apache-arrow-${ICEBERG_ARROW_BUILD_VERSION}.tar.gz" + ) +endif() + +# ---------------------------------------------------------------------- +# FetchContent + +include(FetchContent) +set(FC_DECLARE_COMMON_OPTIONS) +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE) +endif() + +macro(prepare_fetchcontent) + set(BUILD_SHARED_LIBS OFF) + set(BUILD_STATIC_LIBS ON) + set(CMAKE_COMPILE_WARNING_AS_ERROR FALSE) + set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY TRUE) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endmacro() + +# ---------------------------------------------------------------------- +# Apache Arrow + +function(resolve_arrow_dependency) + prepare_fetchcontent() + + set(ARROW_BUILD_SHARED + OFF + CACHE BOOL "" FORCE) + set(ARROW_BUILD_STATIC + ON + CACHE BOOL "" FORCE) + set(ARROW_FILESYSTEM + OFF + CACHE BOOL "" FORCE) + set(ARROW_SIMD_LEVEL + "NONE" + CACHE STRING "" FORCE) + set(ARROW_RUNTIME_SIMD_LEVEL + "NONE" + CACHE STRING "" FORCE) + set(ARROW_POSITION_INDEPENDENT_CODE + ON + CACHE BOOL "" FORCE) + set(ARROW_DEPENDENCY_SOURCE + "AUTO" + CACHE STRING "" FORCE) + + fetchcontent_declare(Arrow + ${FC_DECLARE_COMMON_OPTIONS} + URL ${ARROW_SOURCE_URL} + URL_HASH "SHA256=${ICEBERG_ARROW_BUILD_SHA256_CHECKSUM}" + SOURCE_SUBDIR + cpp + FIND_PACKAGE_ARGS + NAMES + Arrow + CONFIG) + + # Add Arrow cmake modules to the search path + list(PREPEND CMAKE_MODULE_PATH + ${CMAKE_CURRENT_BINARY_DIR}/_deps/arrow-src/cpp/cmake_modules) + + fetchcontent_makeavailable(Arrow) + + if(arrow_SOURCE_DIR) + if(NOT TARGET Arrow::arrow_static) + add_library(Arrow::arrow_static INTERFACE IMPORTED) + target_link_libraries(Arrow::arrow_static INTERFACE arrow_static) + target_include_directories(Arrow::arrow_static + INTERFACE ${arrow_BINARY_DIR}/src + ${arrow_SOURCE_DIR}/cpp/src) + endif() + + set(ARROW_VENDORED TRUE) + set_target_properties(arrow_static PROPERTIES OUTPUT_NAME "iceberg_vendored_arrow") + install(TARGETS arrow_static + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") + else() + set(ARROW_VENDORED FALSE) + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Arrow) + endif() + + set(ICEBERG_SYSTEM_DEPENDENCIES + ${ICEBERG_SYSTEM_DEPENDENCIES} + PARENT_SCOPE) + set(ARROW_VENDORED + ${ARROW_VENDORED} + PARENT_SCOPE) +endfunction() + +if(ICEBERG_ARROW) + resolve_arrow_dependency() +endif() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 0d21c3a..4da20ca 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,10 +22,9 @@ project(example) set(CMAKE_CXX_STANDARD 20) -find_package(iceberg CONFIG REQUIRED) -find_package(puffin CONFIG REQUIRED) +find_package(Iceberg CONFIG REQUIRED) add_executable(demo_example demo_example.cc) -target_link_libraries(demo_example PRIVATE iceberg::iceberg_core_static - puffin::iceberg_puffin_static) +target_link_libraries(demo_example PRIVATE Iceberg::iceberg_puffin_static + Iceberg::iceberg_arrow_static) diff --git a/example/demo_example.cc b/example/demo_example.cc index 99d4bcf..f4801f1 100644 --- a/example/demo_example.cc +++ b/example/demo_example.cc @@ -19,11 +19,13 @@ #include -#include "iceberg/puffin.h" -#include "iceberg/table.h" +#include "iceberg/arrow/demo_arrow.h" +#include "iceberg/demo_table.h" +#include "iceberg/puffin/demo_puffin.h" int main() { - std::cout << iceberg::Table::create()->print() << std::endl; - std::cout << iceberg::Puffin::create()->print() << std::endl; + std::cout << iceberg::DemoTable().print() << std::endl; + std::cout << iceberg::puffin::DemoPuffin().print() << std::endl; + std::cout << iceberg::arrow::DemoArrow().print() << std::endl; return 0; } diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b27e8d87593a2d16f97f4c9919137ef9c9538fa4 GIT binary patch literal 6148 zcmeHKI|@QE5ZqNk!N$@uSMUZw^aNf&{2+oLDE6=NTprEYPoX^Rv`}VYGs$KrAyd44 zD`hPn3=z+wSl zO>6=YfoV{ILDg(AH0X$z%&Un_V9-Ug`Ov&svqMq89p@KM7p;LDsQ?vtR-hZpk=6e> z{7wJ=OyY_PP=UWvKzp;rY>FpkZEZcyYHfip;g)lQn_=!03|@|bUXHP_ay<5=$SXF- XeobrwosPKEf&3XTU1(I`+X~zP{NfdE literal 0 HcmV?d00001 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bec7622..6ec40de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,5 +15,4 @@ # specific language governing permissions and limitations # under the License. -add_subdirectory(core) -add_subdirectory(puffin) +add_subdirectory(iceberg) diff --git a/src/core/icebergConfig.cmake.in b/src/core/icebergConfig.cmake.in deleted file mode 100644 index 2e12a8f..0000000 --- a/src/core/icebergConfig.cmake.in +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# - -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/icebergTargets.cmake") -check_required_components(iceberg) diff --git a/src/core/CMakeLists.txt b/src/iceberg/CMakeLists.txt similarity index 64% rename from src/core/CMakeLists.txt rename to src/iceberg/CMakeLists.txt index 83787d7..a84f3f9 100644 --- a/src/core/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -15,13 +15,21 @@ # specific language governing permissions and limitations # under the License. -set(ICEBERG_CORE_SOURCES demo_table.cc) -set(ICEBERG_CORE_INCLUDES "${ICEBERG_API_DIR}") +set(ICEBERG_SOURCES demo_table.cc) +set(ICEBERG_INCLUDES "${CMAKE_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}/src") -add_iceberg_lib(iceberg_core - CMAKE_PACKAGE_NAME - iceberg +add_iceberg_lib(iceberg SOURCES - ${ICEBERG_CORE_SOURCES} + ${ICEBERG_SOURCES} PRIVATE_INCLUDES - ${ICEBERG_CORE_INCLUDES}) + ${ICEBERG_INCLUDES}) + +iceberg_install_all_headers(iceberg) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_export.h + DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg) + +add_subdirectory(arrow) +add_subdirectory(puffin) + +iceberg_install_cmake_package(Iceberg iceberg_targets) diff --git a/src/iceberg/IcebergConfig.cmake.in b/src/iceberg/IcebergConfig.cmake.in new file mode 100644 index 0000000..e0b690d --- /dev/null +++ b/src/iceberg/IcebergConfig.cmake.in @@ -0,0 +1,80 @@ +# 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. +# +# This config sets the following variables in your project:: +# +# Iceberg_FOUND - true if Iceberg found on the system +# Iceberg_VERSION - version of the found Iceberg +# +# This config sets the following targets (if built) in your project:: +# +# Iceberg::iceberg_shared +# Iceberg::iceberg_static +# Iceberg::iceberg_puffin_shared +# Iceberg::iceberg_puffin_static +# Iceberg::iceberg_arrow_shared +# Iceberg::iceberg_arrow_static + +@PACKAGE_INIT@ + +set(ICEBERG_BUILD_STATIC "@ICEBERG_BUILD_STATIC@") +set(ICEBERG_SYSTEM_DEPENDENCIES "@ICEBERG_SYSTEM_DEPENDENCIES@") + +include(CMakeFindDependencyMacro) + +macro(iceberg_find_dependencies dependencies) + if(DEFINED CMAKE_MODULE_PATH) + set(ICEBERG_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH}) + else() + unset(ICEBERG_CMAKE_MODULE_PATH_OLD) + endif() + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + + foreach(dependency ${dependencies}) + find_dependency(${dependency}) + endforeach() + + if(DEFINED ICEBERG_CMAKE_MODULE_PATH_OLD) + set(CMAKE_MODULE_PATH ${ICEBERG_CMAKE_MODULE_PATH_OLD}) + unset(ICEBERG_CMAKE_MODULE_PATH_OLD) + else() + unset(CMAKE_MODULE_PATH) + endif() +endmacro() + +macro(iceberg_find_components components) + foreach(comp ${components}) + string(TOLOWER "${comp}" _comp_lower_case) + if(TARGET "Iceberg::iceberg_${_comp_lower_case}_shared" OR + TARGET "Iceberg::iceberg_${_comp_lower_case}_static") + set(Iceberg_${comp}_FOUND TRUE) + else() + set(Iceberg_${comp}_FOUND FALSE) + set(Iceberg_NOT_FOUND_MESSAGE "Component ${comp} was not installed") + endif() + endforeach() +endmacro() + +# Find system dependencies +iceberg_find_dependencies("${ICEBERG_SYSTEM_DEPENDENCIES}") + +include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") + +# Find required components +iceberg_find_components("${Iceberg_FIND_COMPONENTS}") + +check_required_components(Iceberg) diff --git a/src/iceberg/arrow/CMakeLists.txt b/src/iceberg/arrow/CMakeLists.txt new file mode 100644 index 0000000..792631d --- /dev/null +++ b/src/iceberg/arrow/CMakeLists.txt @@ -0,0 +1,78 @@ +# 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. + +if(NOT ICEBERG_ARROW) + return() +endif() + +set(ICEBERG_ARROW_SOURCES demo_arrow.cc) +set(ICEBERG_ARROW_INCLUDES "${ICEBERG_INCLUDES}") + +# Libraries to link with exported libiceberg_arrow.{so,a}. +set(ICEBERG_ARROW_STATIC_BUILD_INTERFACE_LIBS) +set(ICEBERG_ARROW_SHARED_BUILD_INTERFACE_LIBS) +set(ICEBERG_ARROW_STATIC_INSTALL_INTERFACE_LIBS) +set(ICEBERG_ARROW_SHARED_INSTALL_INTERFACE_LIBS) + +list(APPEND ICEBERG_ARROW_STATIC_BUILD_INTERFACE_LIBS + "$,iceberg_static,iceberg_shared>" + "$,Arrow::arrow_static,Arrow::arrow_shared>") +list(APPEND ICEBERG_ARROW_SHARED_BUILD_INTERFACE_LIBS + "$,iceberg_shared,iceberg_static>" + "$,Arrow::arrow_shared,Arrow::arrow_static>") + +if(ARROW_VENDORED) + list(APPEND ICEBERG_ARROW_STATIC_INSTALL_INTERFACE_LIBS Iceberg::arrow_static) + list(APPEND ICEBERG_ARROW_SHARED_INSTALL_INTERFACE_LIBS Iceberg::arrow_static) +else() + list(APPEND + ICEBERG_ARROW_STATIC_INSTALL_INTERFACE_LIBS + "$,Arrow::arrow_static,Arrow::arrow_shared>" + ) + list(APPEND + ICEBERG_ARROW_SHARED_INSTALL_INTERFACE_LIBS + "$,Arrow::arrow_shared,Arrow::arrow_static>" + ) +endif() + +list(APPEND + ICEBERG_ARROW_STATIC_INSTALL_INTERFACE_LIBS + "$,Iceberg::iceberg_static,Iceberg::iceberg_shared>" +) +list(APPEND + ICEBERG_ARROW_SHARED_INSTALL_INTERFACE_LIBS + "$,Iceberg::iceberg_shared,Iceberg::iceberg_static>" +) + +add_iceberg_lib(iceberg_arrow + SOURCES + ${ICEBERG_ARROW_SOURCES} + PRIVATE_INCLUDES + ${ICEBERG_ARROW_INCLUDES} + SHARED_LINK_LIBS + ${ICEBERG_ARROW_SHARED_BUILD_INTERFACE_LIBS} + STATIC_LINK_LIBS + ${ICEBERG_ARROW_STATIC_BUILD_INTERFACE_LIBS} + STATIC_INSTALL_INTERFACE_LIBS + ${ICEBERG_ARROW_STATIC_INSTALL_INTERFACE_LIBS} + SHARED_INSTALL_INTERFACE_LIBS + ${ICEBERG_ARROW_SHARED_INSTALL_INTERFACE_LIBS}) + +iceberg_install_all_headers(iceberg/arrow) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_arrow_export.h + DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg/arrow) diff --git a/src/iceberg/arrow/demo_arrow.cc b/src/iceberg/arrow/demo_arrow.cc new file mode 100644 index 0000000..22c2b2a --- /dev/null +++ b/src/iceberg/arrow/demo_arrow.cc @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#include "iceberg/arrow/demo_arrow.h" + +#include + +#include "iceberg/demo_table.h" + +namespace iceberg::arrow { + +std::string DemoArrow::print() const { + return DemoTable().print() + + ", Arrow version: " + ::arrow::GetBuildInfo().version_string; +} + +} // namespace iceberg::arrow diff --git a/src/iceberg/arrow/demo_arrow.h b/src/iceberg/arrow/demo_arrow.h new file mode 100644 index 0000000..61ac953 --- /dev/null +++ b/src/iceberg/arrow/demo_arrow.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include "iceberg/arrow/iceberg_arrow_export.h" +#include "iceberg/table.h" + +namespace iceberg::arrow { + +class ICEBERG_ARROW_EXPORT DemoArrow : public Table { + public: + DemoArrow() = default; + ~DemoArrow() override = default; + std::string print() const override; +}; + +} // namespace iceberg::arrow diff --git a/src/core/demo_table.cc b/src/iceberg/demo_table.cc similarity index 83% rename from src/core/demo_table.cc rename to src/iceberg/demo_table.cc index 5c9d521..29879b8 100644 --- a/src/core/demo_table.cc +++ b/src/iceberg/demo_table.cc @@ -17,12 +17,12 @@ * under the License. */ -#include "demo_table.h" +#include "iceberg/demo_table.h" -namespace iceberg { +#include "iceberg/puffin.h" -std::string_view DemoTable::print() const { return "DemoTable"; } +namespace iceberg { -std::unique_ptr Table::create() { return std::make_unique(); } +std::string DemoTable::print() const { return "DemoTable"; } } // namespace iceberg diff --git a/src/core/demo_table.h b/src/iceberg/demo_table.h similarity index 91% rename from src/core/demo_table.h rename to src/iceberg/demo_table.h index 3a8604c..2dabaa5 100644 --- a/src/core/demo_table.h +++ b/src/iceberg/demo_table.h @@ -23,12 +23,12 @@ namespace iceberg { -class DemoTable : public Table { +class ICEBERG_EXPORT DemoTable : public Table { public: DemoTable() = default; ~DemoTable() override = default; - std::string_view print() const override; + std::string print() const override; }; } // namespace iceberg diff --git a/api/iceberg/puffin.h b/src/iceberg/puffin.h similarity index 86% rename from api/iceberg/puffin.h rename to src/iceberg/puffin.h index b3dc8f7..52514f7 100644 --- a/api/iceberg/puffin.h +++ b/src/iceberg/puffin.h @@ -19,16 +19,16 @@ #pragma once -#include -#include +#include + +#include "iceberg/iceberg_export.h" namespace iceberg { -class Puffin { +class ICEBERG_EXPORT Puffin { public: virtual ~Puffin() = default; - virtual std::string_view print() const = 0; - static std::unique_ptr create(); + virtual std::string print() const = 0; }; } // namespace iceberg diff --git a/src/iceberg/puffin/CMakeLists.txt b/src/iceberg/puffin/CMakeLists.txt new file mode 100644 index 0000000..5acd6be --- /dev/null +++ b/src/iceberg/puffin/CMakeLists.txt @@ -0,0 +1,56 @@ +# 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. + +set(ICEBERG_PUFFIN_SOURCES demo_puffin.cc) +set(ICEBERG_PUFFIN_INCLUDES "${ICEBERG_INCLUDES}") + +set(ICEBERG_PUFFIN_STATIC_BUILD_INTERFACE_LIBS) +set(ICEBERG_PUFFIN_SHARED_BUILD_INTERFACE_LIBS) +set(ICEBERG_PUFFIN_STATIC_INSTALL_INTERFACE_LIBS) +set(ICEBERG_PUFFIN_SHARED_INSTALL_INTERFACE_LIBS) + +list(APPEND ICEBERG_PUFFIN_STATIC_BUILD_INTERFACE_LIBS + "$,iceberg_static,iceberg_shared>") +list(APPEND ICEBERG_PUFFIN_SHARED_BUILD_INTERFACE_LIBS + "$,iceberg_shared,iceberg_static>") +list(APPEND + ICEBERG_PUFFIN_STATIC_INSTALL_INTERFACE_LIBS + "$,Iceberg::iceberg_static,Iceberg::iceberg_shared>" +) +list(APPEND + ICEBERG_PUFFIN_SHARED_INSTALL_INTERFACE_LIBS + "$,Iceberg::iceberg_shared,Iceberg::iceberg_static>" +) + +add_iceberg_lib(iceberg_puffin + SOURCES + ${ICEBERG_PUFFIN_SOURCES} + PRIVATE_INCLUDES + ${ICEBERG_PUFFIN_INCLUDES} + SHARED_LINK_LIBS + ${ICEBERG_PUFFIN_SHARED_BUILD_INTERFACE_LIBS} + STATIC_LINK_LIBS + ${ICEBERG_PUFFIN_STATIC_BUILD_INTERFACE_LIBS} + STATIC_INSTALL_INTERFACE_LIBS + ${ICEBERG_PUFFIN_STATIC_INSTALL_INTERFACE_LIBS} + SHARED_INSTALL_INTERFACE_LIBS + ${ICEBERG_PUFFIN_SHARED_INSTALL_INTERFACE_LIBS}) + +iceberg_install_all_headers(iceberg/puffin) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_puffin_export.h + DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg/puffin) diff --git a/src/puffin/demo_puffin.cc b/src/iceberg/puffin/demo_puffin.cc similarity index 78% rename from src/puffin/demo_puffin.cc rename to src/iceberg/puffin/demo_puffin.cc index a4fe7a0..51aa08c 100644 --- a/src/puffin/demo_puffin.cc +++ b/src/iceberg/puffin/demo_puffin.cc @@ -17,12 +17,10 @@ * under the License. */ -#include "demo_puffin.h" +#include "iceberg/puffin/demo_puffin.h" -namespace iceberg { +namespace iceberg::puffin { -std::string_view DemoPuffin::print() const { return "DemoPuffin"; } +std::string DemoPuffin::print() const { return "DemoPuffin"; } -std::unique_ptr Puffin::create() { return std::make_unique(); } - -} // namespace iceberg +} // namespace iceberg::puffin diff --git a/src/puffin/demo_puffin.h b/src/iceberg/puffin/demo_puffin.h similarity index 81% rename from src/puffin/demo_puffin.h rename to src/iceberg/puffin/demo_puffin.h index a03649b..3544b7c 100644 --- a/src/puffin/demo_puffin.h +++ b/src/iceberg/puffin/demo_puffin.h @@ -20,15 +20,15 @@ #pragma once #include "iceberg/puffin.h" +#include "iceberg/puffin/iceberg_puffin_export.h" -namespace iceberg { +namespace iceberg::puffin { -class DemoPuffin : public Puffin { +class ICEBERG_PUFFIN_EXPORT DemoPuffin : public Puffin { public: DemoPuffin() = default; ~DemoPuffin() override = default; - - std::string_view print() const override; + std::string print() const override; }; -} // namespace iceberg +} // namespace iceberg::puffin diff --git a/api/iceberg/table.h b/src/iceberg/table.h similarity index 86% rename from api/iceberg/table.h rename to src/iceberg/table.h index f06e336..bbdd999 100644 --- a/api/iceberg/table.h +++ b/src/iceberg/table.h @@ -19,16 +19,16 @@ #pragma once -#include -#include +#include + +#include "iceberg/iceberg_export.h" namespace iceberg { -class Table { +class ICEBERG_EXPORT Table { public: virtual ~Table() = default; - virtual std::string_view print() const = 0; - static std::unique_ptr
create(); + virtual std::string print() const = 0; }; } // namespace iceberg diff --git a/src/puffin/CMakeLists.txt b/src/puffin/CMakeLists.txt deleted file mode 100644 index ff353e2..0000000 --- a/src/puffin/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# 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. - -set(ICEBERG_PUFFIN_SOURCES demo_puffin.cc) -set(ICEBERG_PUFFIN_INCLUDES "${ICEBERG_API_DIR}") - -add_iceberg_lib(iceberg_puffin - CMAKE_PACKAGE_NAME - puffin - SOURCES - ${ICEBERG_PUFFIN_SOURCES} - PRIVATE_INCLUDES - ${ICEBERG_PUFFIN_INCLUDES}) diff --git a/src/puffin/puffinConfig.cmake.in b/src/puffin/puffinConfig.cmake.in deleted file mode 100644 index c55b018..0000000 --- a/src/puffin/puffinConfig.cmake.in +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# - -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/puffinTargets.cmake") -check_required_components(puffin)