Skip to content

Commit 984da90

Browse files
committed
Add iceberg_arrow library
1 parent d9e2048 commit 984da90

21 files changed

+806
-19
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
3333
set(CMAKE_CXX_EXTENSIONS OFF)
3434
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3535

36+
if(WIN32 AND NOT MINGW)
37+
# This is used to handle builds using e.g. clang in an MSVC setting.
38+
set(MSVC_TOOLCHAIN TRUE)
39+
else()
40+
set(MSVC_TOOLCHAIN FALSE)
41+
endif()
42+
3643
option(ICEBERG_BUILD_STATIC "Build static library" ON)
3744
option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
3845
option(ICEBERG_BUILD_TESTS "Build tests" ON)
3946

47+
set(ICEBERG_DEPENDENCY_SOURCE "AUTO" CACHE STRING "Method to use for acquiring build dependencies")
48+
set_property(CACHE ICEBERG_DEPENDENCY_SOURCE PROPERTY STRINGS "AUTO" "VENDOR" "SYSTEM")
49+
option(ICEBERG_ARROW "Build Arrow" ON)
50+
4051
include(CMakePackageConfigHelpers)
4152
include(CMakeParseArguments)
4253
include(BuildUtils)
@@ -51,6 +62,8 @@ set(ICEBERG_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
5162
set(ICEBERG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake")
5263
set(ICEBERG_INSTALL_DOCDIR "share/doc/${PROJECT_NAME}")
5364

65+
include(ThirdpartyToolchain)
66+
5467
add_subdirectory(api)
5568
add_subdirectory(src)
5669

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ cmake --build .
3838
cmake --install .
3939
```
4040

41+
### Build and Install Iceberg Arrow Libraries
42+
43+
#### Vendored Apache Arrow (default)
44+
```bash
45+
cd iceberg-cpp/src/arrow
46+
mkdir build && cd build
47+
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_ARROW=ON
48+
cmake --build .
49+
cmake --install .
50+
```
51+
52+
#### Provided Apache Arrow
53+
54+
```bash
55+
cd iceberg-cpp/src/arrow
56+
mkdir build && cd build
57+
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install -DArrow_SOURCE=SYSTEM -DArrow_ROOT=/path/to/arrow
58+
cmake --build .
59+
cmake --install .
60+
```
61+
62+
Please note that `-DArrow_ROOT=/path/to/arrow` is required when building examples below when using provided Apache Arrow.
63+
4164
### Build Examples
4265

4366
After installing the core libraries, you can build the examples:

api/iceberg/puffin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
namespace iceberg {
2626

2727
class Puffin {
28-
public:
28+
public:
2929
virtual ~Puffin() = default;
3030
virtual std::string_view print() const = 0;
3131
static std::unique_ptr<Puffin> create();
3232
};
3333

34-
} // namespace iceberg
34+
} // namespace iceberg

api/iceberg/table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
namespace iceberg {
2626

2727
class Table {
28-
public:
28+
public:
2929
virtual ~Table() = default;
3030
virtual std::string_view print() const = 0;
3131
static std::unique_ptr<Table> create();
3232
};
3333

34-
} // namespace iceberg
34+
} // namespace iceberg

cmake_modules/FindArrowAlt.cmake

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
if(ArrowAlt_FOUND)
19+
return()
20+
endif()
21+
22+
set(find_package_args)
23+
if(ArrowAlt_FIND_VERSION)
24+
list(APPEND find_package_args ${ArrowAlt_FIND_VERSION})
25+
endif()
26+
if(ArrowAlt_FIND_QUIETLY)
27+
list(APPEND find_package_args QUIET)
28+
endif()
29+
find_package(Arrow ${find_package_args})
30+
if(Arrow_FOUND)
31+
set(ArrowAlt_FOUND TRUE)
32+
set(ArrowAlt_VERSION ${ARROW_VERSION})
33+
return()
34+
endif()
35+
36+
if(ARROW_ROOT)
37+
find_library(ARROW_STATIC_LIB
38+
NAMES arrow
39+
PATHS ${ARROW_ROOT}
40+
NO_DEFAULT_PATH
41+
PATH_SUFFIXES ${ICEBERG_LIBRARY_PATH_SUFFIXES})
42+
find_path(ARROW_INCLUDE_DIR
43+
NAMES arrow/api.h
44+
PATHS ${ARROW_ROOT}
45+
NO_DEFAULT_PATH
46+
PATH_SUFFIXES ${ICEBERG_LIBRARY_PATH_SUFFIXES})
47+
else()
48+
find_library(ARROW_STATIC_LIB
49+
NAMES arrow
50+
PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES})
51+
find_path(ARROW_INCLUDE_DIR
52+
NAMES arrow/api.h
53+
PATH_SUFFIXES ${ICEBERG_INCLUDE_PATH_SUFFIXES})
54+
endif()
55+
if(ARROW_INCLUDE_DIR)
56+
file(READ "${ARROW_INCLUDE_DIR}/arrow/util/config.h" ARROW_CONFIG_HH_CONTENT)
57+
string(REGEX MATCH "#define ARROW_VERSION_STRING \"[0-9.]+\"" ARROW_VERSION_DEFINITION
58+
"${ARROW_CONFIG_HH_CONTENT}")
59+
string(REGEX MATCH "[0-9.]+" ARROW_VERSION "${ARROW_VERSION_DEFINITION}")
60+
endif()
61+
62+
find_package_handle_standard_args(
63+
ArrowAlt
64+
REQUIRED_VARS ARROW_STATIC_LIB ARROW_INCLUDE_DIR
65+
VERSION_VAR ARROW_VERSION)
66+
67+
if(ArrowAlt_FOUND)
68+
if(NOT TARGET Arrow::arrow_static)
69+
add_library(Arrow::arrow_static STATIC IMPORTED)
70+
set_target_properties(Arrow::arrow_static
71+
PROPERTIES IMPORTED_LOCATION "${ARROW_STATIC_LIB}"
72+
INTERFACE_INCLUDE_DIRECTORIES "${ARROW_INCLUDE_DIR}")
73+
endif()
74+
set(ArrowAlt_VERSION ${ARROW_VERSION})
75+
endif()

0 commit comments

Comments
 (0)