diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15daa874..31d6c5b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,3 +99,36 @@ jobs: run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 bash -c "ci/scripts/build_example.sh $(pwd)/example" + meson: + name: Meson - ${{ matrix.title }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - title: AMD64 Ubuntu 24.04 + runs-on: ubuntu-24.04 + - title: AMD64 Windows 2025 + runs-on: windows-2025 + meson-setup-args: --vsenv + - title: AArch64 macOS 15 + runs-on: macos-15 + steps: + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Checkout iceberg-cpp + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 0 + - name: Install build dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install meson ninja + - name: Build Iceberg + run: | + meson setup builddir ${{ matrix.meson-setup-args || '' }} + meson compile -C builddir + - name: Test Iceberg + run: | + meson test -C builddir diff --git a/.gitignore b/.gitignore index 74df5bd6..8cd4f4e1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,9 @@ cmake-build-release/ # vscode files .vscode + +# meson subprojects - wrap files need to be kept to let meson download +# dependencies as needed, but dependencies themselves should not be versioned +/subprojects/* +!/subprojects/packagefiles +!/subprojects/*.wrap diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 193d69a1..4ee4a0b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,3 +39,15 @@ repos: rev: v0.6.10 hooks: - id: cmake-format + + - repo: https://github.com/trim21/pre-commit-mirror-meson + rev: v1.9.0 + hooks: + - id: meson-fmt + alias: cpp + args: ['--inplace'] + files: >- + ( + ?.*meson\.build$| + ?.*meson\.options$| + ) diff --git a/CMakeLists.txt b/CMakeLists.txt index dea6b46f..0d6f3806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ 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/Iceberg") +set(ICEBERG_INSTALL_DOCDIR "share/doc/iceberg") if(WIN32 AND NOT MINGW) set(MSVC_TOOLCHAIN TRUE) @@ -64,7 +64,6 @@ include(CMakeParseArguments) include(IcebergBuildUtils) include(IcebergSanitizer) include(IcebergThirdpartyToolchain) -include(GenerateExportHeader) if(ICEBERG_BUILD_TESTS) enable_testing() diff --git a/cmake_modules/IcebergBuildUtils.cmake b/cmake_modules/IcebergBuildUtils.cmake index 8b892597..edcb1d93 100644 --- a/cmake_modules/IcebergBuildUtils.cmake +++ b/cmake_modules/IcebergBuildUtils.cmake @@ -21,18 +21,18 @@ include(CMakePackageConfigHelpers) function(iceberg_install_cmake_package PACKAGE_NAME EXPORT_NAME) - set(CONFIG_CMAKE "${PACKAGE_NAME}Config.cmake") + set(CONFIG_CMAKE "${PACKAGE_NAME}-config.cmake") set(BUILT_CONFIG_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_CMAKE}") configure_package_config_file("${CONFIG_CMAKE}.in" "${BUILT_CONFIG_CMAKE}" INSTALL_DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}" ) - set(CONFIG_VERSION_CMAKE "${PACKAGE_NAME}ConfigVersion.cmake") + set(CONFIG_VERSION_CMAKE "${PACKAGE_NAME}config-version.cmake") set(BUILT_CONFIG_VERSION_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_VERSION_CMAKE}") write_basic_package_version_file("${BUILT_CONFIG_VERSION_CMAKE}" COMPATIBILITY SameMajorVersion) install(FILES "${BUILT_CONFIG_CMAKE}" "${BUILT_CONFIG_VERSION_CMAKE}" DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}") - set(TARGETS_CMAKE "${PACKAGE_NAME}Targets.cmake") + set(TARGETS_CMAKE "${PACKAGE_NAME}-targets.cmake") install(EXPORT ${EXPORT_NAME} DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}" NAMESPACE "${PACKAGE_NAME}::" @@ -150,6 +150,9 @@ function(add_iceberg_lib LIB_NAME) target_link_libraries(${LIB_NAME}_shared PUBLIC "$") + string(TOUPPER ${LIB_NAME} VISIBILITY_NAME) + target_compile_definitions(${LIB_NAME}_shared PRIVATE ${VISIBILITY_NAME}_EXPORTING) + install(TARGETS ${LIB_NAME}_shared EXPORT iceberg_targets ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR} @@ -208,6 +211,9 @@ function(add_iceberg_lib LIB_NAME) target_link_libraries(${LIB_NAME}_static PUBLIC "$") + string(TOUPPER ${LIB_NAME} VISIBILITY_NAME) + target_compile_definitions(${LIB_NAME}_static PUBLIC ${VISIBILITY_NAME}_STATIC) + install(TARGETS ${LIB_NAME}_static EXPORT iceberg_targets ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR} @@ -217,18 +223,6 @@ function(add_iceberg_lib LIB_NAME) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() - # 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 if(ARG_OUTPUTS) set(${ARG_OUTPUTS} diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index 793af7f9..af714393 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -461,7 +461,7 @@ function(resolve_cpr_dependency) set(CPR_VENDORED TRUE) set_target_properties(cpr PROPERTIES OUTPUT_NAME "iceberg_vendored_cpr" POSITION_INDEPENDENT_CODE ON) - add_library(Iceberg::cpr ALIAS cpr) + add_library(iceberg::cpr ALIAS cpr) install(TARGETS cpr EXPORT iceberg_targets RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index d120d504..837ed7d7 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -22,9 +22,9 @@ project(example) set(CMAKE_CXX_STANDARD 23) -find_package(Iceberg CONFIG REQUIRED) +find_package(iceberg CONFIG REQUIRED) add_executable(demo_example demo_example.cc) -target_link_libraries(demo_example PRIVATE Iceberg::iceberg_bundle_static - Iceberg::iceberg_rest_static) +target_link_libraries(demo_example PRIVATE iceberg::iceberg_bundle_static + iceberg::iceberg_rest_static) diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..eaeeda4c --- /dev/null +++ b/meson.build @@ -0,0 +1,38 @@ +# 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. + +project( + 'iceberg', + 'cpp', + version: '0.2.0', + license: 'Apache-2.0', + meson_version: '>=1.3.0', + default_options: [ + 'cpp_std=c++23,c++latest', + 'warning_level=2', + # Don't build any tests for curl + 'curl:tests=disabled', + 'curl:unittests=disabled', + ], +) + +subdir('src') + +install_data( + ['LICENSE', 'NOTICE'], + install_dir: get_option('datadir') / 'doc/iceberg', +) diff --git a/meson.options b/meson.options new file mode 100644 index 00000000..943f1e46 --- /dev/null +++ b/meson.options @@ -0,0 +1,39 @@ +# 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. + +# Many of the options that CMake provides do not need to be implemented +# in this configuration, as Meson offers built-in support for them. +# For instance, instead of ICEBERG_BUILD_STATIC and ICEBERG_BUILD_SHARED +# you can pass the `--default_library=