Skip to content

Commit de7b278

Browse files
committed
expose ICEBERG_EXAMPLE_CXX_STANDARD and update docs to state C++20 as minimum standard for public headers
1 parent d005280 commit de7b278

6 files changed

Lines changed: 71 additions & 14 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,19 @@ jobs:
7878
with:
7979
key-prefix: sccache-test-ubuntu-${{ matrix.cmake_build_type }}
8080
job-status: ${{ job.status }}
81-
- name: Build Example
81+
- name: Build Example (C++20)
8282
shell: bash
8383
env:
8484
CC: gcc-14
8585
CXX: g++-14
8686
run: ci/scripts/build_example.sh $(pwd)/example
87+
- name: Build Example (C++23)
88+
shell: bash
89+
env:
90+
CC: gcc-14
91+
CXX: g++-14
92+
ICEBERG_EXAMPLE_CXX_STANDARD: 23
93+
run: ci/scripts/build_example.sh $(pwd)/example
8794
hive:
8895
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
8996
name: AMD64 Ubuntu 26.04 Hive
@@ -153,9 +160,14 @@ jobs:
153160
with:
154161
key-prefix: sccache-test-macos
155162
job-status: ${{ job.status }}
156-
- name: Build Example
163+
- name: Build Example (C++20)
157164
shell: bash
158165
run: ci/scripts/build_example.sh $(pwd)/example
166+
- name: Build Example (C++23)
167+
shell: bash
168+
env:
169+
ICEBERG_EXAMPLE_CXX_STANDARD: 23
170+
run: ci/scripts/build_example.sh $(pwd)/example
159171
windows:
160172
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
161173
name: AMD64 Windows 2025
@@ -199,8 +211,15 @@ jobs:
199211
with:
200212
key-prefix: sccache-test-windows
201213
job-status: ${{ job.status }}
202-
- name: Build Example
214+
- name: Build Example (C++20)
215+
shell: pwsh
216+
run: |
217+
$ErrorActionPreference = "Stop"
218+
bash -lc 'ci/scripts/build_example.sh $(pwd)/example'
219+
- name: Build Example (C++23)
203220
shell: pwsh
221+
env:
222+
ICEBERG_EXAMPLE_CXX_STANDARD: 23
204223
run: |
205224
$ErrorActionPreference = "Stop"
206225
bash -lc 'ci/scripts/build_example.sh $(pwd)/example'

‎README.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ C++ implementation of [Apache Iceberg™](https://iceberg.apache.org/).
3131

3232
**Required:**
3333

34-
- C++23 compliant compiler (GCC 14+, Clang 18+, MSVC 2022+)
34+
- C++23 compliant compiler (GCC 14+, Clang 18+, MSVC 2022+) to build iceberg-cpp itself
3535
- CMake 3.25+
3636
- [Ninja](https://ninja-build.org/) (recommended build backend)
3737

38+
**Using iceberg-cpp from your project:** the installed public headers require
39+
C++20 at minimum, so applications that link against iceberg-cpp can be
40+
compiled as C++20 or later. The library itself is still built as C++23.
41+
3842
**Optional:**
3943

4044
- Python 3 and [pre-commit](https://pre-commit.com/) (for linting)
@@ -121,6 +125,14 @@ If you are using provided Apache Arrow, include `/path/to/arrow` in `CMAKE_PREFI
121125
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow"
122126
```
123127

128+
The examples build as C++20 by default, which is the minimum standard supported
129+
by the public headers. Set `ICEBERG_EXAMPLE_CXX_STANDARD` to `23` to build them
130+
as C++23 instead:
131+
132+
```bash
133+
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/install -DICEBERG_EXAMPLE_CXX_STANDARD=23
134+
```
135+
124136
## Customizing Dependency URLs
125137

126138
If you experience network issues when downloading dependencies, you can customize the download URLs using environment variables:

‎ci/scripts/build_example.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set -eux
2222
source_dir=${1}
2323
build_dir=${1}/build
2424
run_example=${ICEBERG_RUN_EXAMPLE:-OFF}
25+
cxx_standard=${ICEBERG_EXAMPLE_CXX_STANDARD:-20}
2526

2627
# Clean up before configuring. If Windows still holds a just-built exe/dll
2728
# after the retries, let mkdir fail rather than reuse a half-deleted tree.
@@ -53,6 +54,7 @@ fi
5354

5455
build_type="${ICEBERG_BUILD_TYPE:-Debug}"
5556
CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=${build_type}")
57+
CMAKE_ARGS+=("-DICEBERG_EXAMPLE_CXX_STANDARD=${cxx_standard}")
5658

5759
cmake "${CMAKE_ARGS[@]}" ${source_dir}
5860
cmake --build .

‎example/CMakeLists.txt‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,21 @@ cmake_minimum_required(VERSION 3.25)
2020

2121
project(example)
2222

23-
set(CMAKE_CXX_STANDARD 20)
23+
# C++20 is the minimum standard iceberg-cpp's public headers support, so the
24+
# example builds as C++20 by default to keep that contract exercised. Set this to
25+
# 23 to also check the headers from a C++23 consumer.
26+
set(ICEBERG_EXAMPLE_CXX_STANDARD
27+
20
28+
CACHE STRING "C++ standard used to build the example (20 or 23)")
29+
set_property(CACHE ICEBERG_EXAMPLE_CXX_STANDARD PROPERTY STRINGS 20 23)
30+
if(NOT ICEBERG_EXAMPLE_CXX_STANDARD MATCHES "^(20|23)$")
31+
message(FATAL_ERROR "ICEBERG_EXAMPLE_CXX_STANDARD must be 20 or 23, got "
32+
"'${ICEBERG_EXAMPLE_CXX_STANDARD}'")
33+
endif()
34+
35+
set(CMAKE_CXX_STANDARD ${ICEBERG_EXAMPLE_CXX_STANDARD})
36+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
37+
set(CMAKE_CXX_EXTENSIONS OFF)
2438

2539
find_package(iceberg CONFIG REQUIRED COMPONENTS bundle rest)
2640

@@ -41,7 +55,8 @@ add_executable(demo_example demo_example.cc)
4155
target_link_libraries(demo_example PRIVATE ${ICEBERG_BUNDLE_TARGET}
4256
${ICEBERG_REST_TARGET})
4357

44-
# Compile every installed public header as a C++20 consumer. The installed include
58+
# Compile every installed public header as a consumer using
59+
# ICEBERG_EXAMPLE_CXX_STANDARD. The installed include
4560
# tree is the public API contract: iceberg_install_all_headers excludes internal
4661
# headers before packaging them.
4762
get_target_property(ICEBERG_BUNDLE_INCLUDE_DIRS ${ICEBERG_BUNDLE_TARGET}
@@ -75,12 +90,9 @@ endforeach()
7590
string(APPEND ICEBERG_PUBLIC_HEADER_CHECK_SOURCE "\nint main() { return 0; }\n")
7691

7792
file(GENERATE
78-
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/public_headers_cxx20.cc"
93+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/public_headers_check.cc"
7994
CONTENT "${ICEBERG_PUBLIC_HEADER_CHECK_SOURCE}")
8095

81-
add_executable(public_headers_cxx20 "${CMAKE_CURRENT_BINARY_DIR}/public_headers_cxx20.cc")
82-
set_target_properties(public_headers_cxx20
83-
PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS
84-
OFF)
85-
target_link_libraries(public_headers_cxx20 PRIVATE ${ICEBERG_BUNDLE_TARGET}
96+
add_executable(public_headers_check "${CMAKE_CURRENT_BINARY_DIR}/public_headers_check.cc")
97+
target_link_libraries(public_headers_check PRIVATE ${ICEBERG_BUNDLE_TARGET}
8698
${ICEBERG_REST_TARGET})

‎mkdocs/docs/getting-started.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323

2424
**Required:**
2525

26-
- C++23 compliant compiler (GCC 14+, Clang 18+, MSVC 2022+)
26+
- C++23 compliant compiler (GCC 14+, Clang 18+, MSVC 2022+) to build iceberg-cpp itself
2727
- CMake 3.25+
2828
- [Ninja](https://ninja-build.org/) (recommended build backend)
2929

30+
**Using iceberg-cpp from your project:** the installed public headers require
31+
C++20 at minimum, so applications that link against iceberg-cpp can be
32+
compiled as C++20 or later. The library itself is still built as C++23.
33+
3034
## Quick Start
3135

3236
```bash
@@ -112,6 +116,14 @@ If using provided Apache Arrow, include both paths:
112116
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow"
113117
```
114118

119+
The examples build as C++20 by default, which is the minimum standard supported
120+
by the public headers. Set `ICEBERG_EXAMPLE_CXX_STANDARD` to `23` to build them
121+
as C++23 instead:
122+
123+
```bash
124+
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/install -DICEBERG_EXAMPLE_CXX_STANDARD=23
125+
```
126+
115127
## Customizing Dependency URLs
116128

117129
If you experience network issues when downloading dependencies, you can override the download URLs using environment variables:

‎mkdocs/docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ iceberg-cpp is a C++ implementation of [Apache Iceberg™](https://iceberg.apach
2525

2626
## Key Features
2727

28-
- **Modern C++23** — Built with ranges, concepts, `std::expected`, and other modern idioms
28+
- **Modern C++** — Built as C++23 with ranges, concepts, and other modern idioms; public headers require only C++20
2929
- **Cross-Platform** — Builds and runs on Linux, macOS, and Windows
3030
- **Spec Compliance** — Full table spec support today; Puffin, View, and UDF specs are on the roadmap
3131
- **Arrow-Native** — Uses the Arrow C Data Interface as the primary data API

0 commit comments

Comments
 (0)