Skip to content

Commit 064d53b

Browse files
authored
feat: Add support for Meson build system (#233)
closes #228 @wgtmac
1 parent 4ebf729 commit 064d53b

40 files changed

+1091
-118
lines changed

.github/.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ header:
2828
- '.github/**'
2929
- 'LICENSE'
3030
- 'NOTICE'
31+
- 'requirements.txt'
3132
- 'src/iceberg/expected.h'
3233
- 'src/iceberg/util/murmurhash3_internal.*'
3334
- 'src/iceberg/test/resources/**'

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,36 @@ jobs:
9999
run: |
100100
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
101101
bash -c "ci/scripts/build_example.sh $(pwd)/example"
102+
meson:
103+
name: Meson - ${{ matrix.title }}
104+
runs-on: ${{ matrix.runs-on }}
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
include:
109+
- title: AMD64 Ubuntu 24.04
110+
runs-on: ubuntu-24.04
111+
- title: AMD64 Windows 2025
112+
runs-on: windows-2025
113+
meson-setup-args: --vsenv
114+
- title: AArch64 macOS 15
115+
runs-on: macos-15
116+
steps:
117+
- uses: actions/setup-python@v5
118+
with:
119+
python-version: '3.x'
120+
- name: Checkout iceberg-cpp
121+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
122+
with:
123+
fetch-depth: 0
124+
- name: Install build dependencies
125+
run: |
126+
python3 -m pip install --upgrade pip
127+
python3 -m pip install -r requirements.txt
128+
- name: Build Iceberg
129+
run: |
130+
meson setup builddir ${{ matrix.meson-setup-args || '' }}
131+
meson compile -C builddir
132+
- name: Test Iceberg
133+
run: |
134+
meson test -C builddir

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ cmake-build-release/
2626

2727
# vscode files
2828
.vscode
29+
30+
# meson subprojects - wrap files need to be kept to let meson download
31+
# dependencies as needed, but dependencies themselves should not be versioned
32+
/subprojects/*
33+
!/subprojects/packagefiles
34+
!/subprojects/*.wrap

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ repos:
3939
rev: v0.6.10
4040
hooks:
4141
- id: cmake-format
42+
43+
- repo: https://github.com/trim21/pre-commit-mirror-meson
44+
rev: v1.9.0
45+
hooks:
46+
- id: meson-fmt
47+
alias: cpp
48+
args: ['--inplace']
49+
files: >-
50+
(
51+
?.*meson\.build$|
52+
?.*meson\.options$|
53+
)

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ set(ICEBERG_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
5252
set(ICEBERG_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
5353
set(ICEBERG_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
5454
set(ICEBERG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake")
55-
set(ICEBERG_INSTALL_DOCDIR "share/doc/Iceberg")
55+
set(ICEBERG_INSTALL_DOCDIR "share/doc/iceberg")
5656

5757
if(WIN32 AND NOT MINGW)
5858
set(MSVC_TOOLCHAIN TRUE)
@@ -64,7 +64,6 @@ include(CMakeParseArguments)
6464
include(IcebergBuildUtils)
6565
include(IcebergSanitizer)
6666
include(IcebergThirdpartyToolchain)
67-
include(GenerateExportHeader)
6867

6968
if(ICEBERG_BUILD_TESTS)
7069
enable_testing()

cmake_modules/IcebergBuildUtils.cmake

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
include(CMakePackageConfigHelpers)
2222

2323
function(iceberg_install_cmake_package PACKAGE_NAME EXPORT_NAME)
24-
set(CONFIG_CMAKE "${PACKAGE_NAME}Config.cmake")
24+
set(CONFIG_CMAKE "${PACKAGE_NAME}-config.cmake")
2525
set(BUILT_CONFIG_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_CMAKE}")
2626
configure_package_config_file("${CONFIG_CMAKE}.in" "${BUILT_CONFIG_CMAKE}"
2727
INSTALL_DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}"
2828
)
29-
set(CONFIG_VERSION_CMAKE "${PACKAGE_NAME}ConfigVersion.cmake")
29+
set(CONFIG_VERSION_CMAKE "${PACKAGE_NAME}config-version.cmake")
3030
set(BUILT_CONFIG_VERSION_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_VERSION_CMAKE}")
3131
write_basic_package_version_file("${BUILT_CONFIG_VERSION_CMAKE}"
3232
COMPATIBILITY SameMajorVersion)
3333
install(FILES "${BUILT_CONFIG_CMAKE}" "${BUILT_CONFIG_VERSION_CMAKE}"
3434
DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}")
35-
set(TARGETS_CMAKE "${PACKAGE_NAME}Targets.cmake")
35+
set(TARGETS_CMAKE "${PACKAGE_NAME}-targets.cmake")
3636
install(EXPORT ${EXPORT_NAME}
3737
DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}"
3838
NAMESPACE "${PACKAGE_NAME}::"
@@ -150,6 +150,9 @@ function(add_iceberg_lib LIB_NAME)
150150
target_link_libraries(${LIB_NAME}_shared
151151
PUBLIC "$<BUILD_INTERFACE:iceberg_sanitizer_flags>")
152152

153+
string(TOUPPER ${LIB_NAME} VISIBILITY_NAME)
154+
target_compile_definitions(${LIB_NAME}_shared PRIVATE ${VISIBILITY_NAME}_EXPORTING)
155+
153156
install(TARGETS ${LIB_NAME}_shared
154157
EXPORT iceberg_targets
155158
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
@@ -208,6 +211,9 @@ function(add_iceberg_lib LIB_NAME)
208211
target_link_libraries(${LIB_NAME}_static
209212
PUBLIC "$<BUILD_INTERFACE:iceberg_sanitizer_flags>")
210213

214+
string(TOUPPER ${LIB_NAME} VISIBILITY_NAME)
215+
target_compile_definitions(${LIB_NAME}_static PUBLIC ${VISIBILITY_NAME}_STATIC)
216+
211217
install(TARGETS ${LIB_NAME}_static
212218
EXPORT iceberg_targets
213219
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
@@ -217,18 +223,6 @@ function(add_iceberg_lib LIB_NAME)
217223
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
218224
endif()
219225

220-
# generate export header file
221-
if(BUILD_SHARED)
222-
generate_export_header(${LIB_NAME}_shared BASE_NAME ${LIB_NAME})
223-
if(BUILD_STATIC)
224-
string(TOUPPER ${LIB_NAME} LIB_NAME_UPPER)
225-
target_compile_definitions(${LIB_NAME}_static
226-
PUBLIC ${LIB_NAME_UPPER}_STATIC_DEFINE)
227-
endif()
228-
elseif(BUILD_STATIC)
229-
generate_export_header(${LIB_NAME}_static BASE_NAME ${LIB_NAME})
230-
endif()
231-
232226
# Modify variable in calling scope
233227
if(ARG_OUTPUTS)
234228
set(${ARG_OUTPUTS}

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ function(resolve_cpr_dependency)
461461
set(CPR_VENDORED TRUE)
462462
set_target_properties(cpr PROPERTIES OUTPUT_NAME "iceberg_vendored_cpr"
463463
POSITION_INDEPENDENT_CODE ON)
464-
add_library(Iceberg::cpr ALIAS cpr)
464+
add_library(iceberg::cpr ALIAS cpr)
465465
install(TARGETS cpr
466466
EXPORT iceberg_targets
467467
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"

dev/release/rat_exclude_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ NOTICE
2121
build/**
2222
dist/**
2323
.git/**
24+
requirements.txt
2425
test/resources/**
2526
*.avro
2627
*.json

example/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ project(example)
2222

2323
set(CMAKE_CXX_STANDARD 23)
2424

25-
find_package(Iceberg CONFIG REQUIRED)
25+
find_package(iceberg CONFIG REQUIRED)
2626

2727
add_executable(demo_example demo_example.cc)
2828

29-
target_link_libraries(demo_example PRIVATE Iceberg::iceberg_bundle_static
30-
Iceberg::iceberg_rest_static)
29+
target_link_libraries(demo_example PRIVATE iceberg::iceberg_bundle_static
30+
iceberg::iceberg_rest_static)

meson.build

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
project(
19+
'iceberg',
20+
'cpp',
21+
version: '0.2.0',
22+
license: 'Apache-2.0',
23+
meson_version: '>=1.3.0',
24+
default_options: [
25+
'cpp_std=c++23,c++latest',
26+
'warning_level=2',
27+
# Don't build any tests for curl
28+
'curl:tests=disabled',
29+
'curl:unittests=disabled',
30+
],
31+
)
32+
33+
subdir('src')
34+
35+
install_data(
36+
['LICENSE', 'NOTICE'],
37+
install_dir: get_option('datadir') / 'doc/iceberg',
38+
)

0 commit comments

Comments
 (0)