From a5efdfe76987e780e39fd354bd8c8dea55ae0b0a Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Mon, 4 Sep 2023 18:27:06 +0100 Subject: [PATCH] chore: bump C++ standard version (#2685) * chore: bump C++ min version * refactor: set flags on targets * chore: only set on awkward-parent * chore: tests already link against targets with compile features * chore: drop standards These are already linked * fix: restore std * fix: drop more references to CXX_EXTENSIONS et al. for non-compiled targets * ci: add old CMake job Signed-off-by: Henry Schreiner * fix: awkward-cpp expected version --------- Signed-off-by: Henry Schreiner Co-authored-by: Henry Schreiner --- .github/workflows/test.yml | 7 +++++- awkward-cpp/CMakeLists.txt | 24 ++++++++++++++------ awkward-cpp/pyproject.toml | 2 +- header-only/CMakeLists.txt | 13 +---------- header-only/examples/cython/CMakeLists.txt | 4 ---- header-only/examples/pybind11/CMakeLists.txt | 4 ---- header-only/tests/CMakeLists.txt | 3 +-- pyproject.toml | 2 +- 8 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f6e5456216..143d3a1ff8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -212,6 +212,11 @@ jobs: with: python-version: '${{ matrix.python-version }}' + - name: Oldest supported CMake + uses: jwlawson/actions-setup-cmake@v1.14 + with: + cmake-version: '3.15.x' + - name: Generate build files run: pipx run nox -s prepare -- --headers --signatures --tests @@ -220,7 +225,7 @@ jobs: uses: actions/cache@v3 with: path: ./awkward-cpp/dist - key: ${{ github.job }}-${{ matrix.python-version }}-${{ hashFiles('awkward-cpp/**') }} + key: ${{ github.job }}-${{ matrix.python-version }}-cmake315-${{ hashFiles('awkward-cpp/**') }} - name: Build awkward-cpp wheel if: steps.cache-awkward-cpp-wheel.outputs.cache-hit != 'true' diff --git a/awkward-cpp/CMakeLists.txt b/awkward-cpp/CMakeLists.txt index 3c2f34cfaa..ac33dfb976 100644 --- a/awkward-cpp/CMakeLists.txt +++ b/awkward-cpp/CMakeLists.txt @@ -24,12 +24,7 @@ Please check https://github.com/scikit-hep/awkward#installation-for-developers t ") endif() -# Defaults for properties in this directory (and below) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) - +# Setup the RPATH for built libraries if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) message(STATUS "Using Emscripten") set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) @@ -50,7 +45,7 @@ file(GLOB_RECURSE LIBAWKWARD_SOURCES CONFIGURE_DEPENDS "src/libawkward/*.cpp") add_library(awkward-parent INTERFACE) target_compile_definitions(awkward-parent INTERFACE VERSION_INFO="${SKBUILD_PROJECT_VERSION}") target_include_directories(awkward-parent INTERFACE include) -target_compile_features(awkward-parent INTERFACE cxx_std_11) +target_compile_features(awkward-parent INTERFACE cxx_std_17) # C++ dependencies (header-only): RapidJSON target_include_directories(awkward-parent INTERFACE rapidjson/include) @@ -63,6 +58,11 @@ target_link_libraries(awkward-parent INTERFACE awkward::growable-buffer) add_library(awkward-cpu-kernels-objects OBJECT ${CPU_KERNEL_SOURCES}) set_target_properties(awkward-cpu-kernels-objects PROPERTIES POSITION_INDEPENDENT_CODE ON) target_link_libraries(awkward-cpu-kernels-objects PUBLIC awkward-parent) +set_target_properties( + awkward-cpu-kernels-objects + PROPERTIES CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + CXX_EXTENSIONS NO) add_library(awkward-cpu-kernels-static STATIC $) set_property(TARGET awkward-cpu-kernels-static PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -91,6 +91,11 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") -Wunused) endif() target_link_libraries(awkward-objects PUBLIC awkward-parent) +set_target_properties( + awkward-objects + PROPERTIES CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + CXX_EXTENSIONS NO) add_library(awkward-static STATIC $) set_property(TARGET awkward-static PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -109,6 +114,11 @@ find_package(pybind11 CONFIG REQUIRED) file(GLOB LAYOUT_SOURCES "src/python/*.cpp") pybind11_add_module(_ext ${LAYOUT_SOURCES}) target_link_libraries(_ext PRIVATE awkward-static) +set_target_properties( + _ext + PROPERTIES CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + CXX_EXTENSIONS NO) # Install pure-python files file(GLOB_RECURSE PYTHON_SOURCES "src/${SKBUILD_PROJECT_NAME}/*.py") diff --git a/awkward-cpp/pyproject.toml b/awkward-cpp/pyproject.toml index a104579785..9bbf21aacd 100644 --- a/awkward-cpp/pyproject.toml +++ b/awkward-cpp/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "scikit_build_core.build" [project] name = "awkward_cpp" -version = "22" +version = "23" dependencies = [ "numpy>=1.18.0", "importlib_resources;python_version < \"3.9\"" diff --git a/header-only/CMakeLists.txt b/header-only/CMakeLists.txt index 3e634d240e..6481dd00a0 100644 --- a/header-only/CMakeLists.txt +++ b/header-only/CMakeLists.txt @@ -24,6 +24,7 @@ macro(add_component name) target_include_directories( ${name} INTERFACE $ $) + target_compile_features(${name} INTERFACE cxx_std_17) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${name}/awkward" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${name}") @@ -38,18 +39,6 @@ target_link_libraries(growable-buffer INTERFACE builder-options) add_component(layout-builder) target_link_libraries(layout-builder INTERFACE growable-buffer builder-options) -# Set target compile properties -set_target_properties( - layout-builder - PROPERTIES CXX_STANDARD 17 - CXX_STANDARD_REQUIRED YES - CXX_EXTENSIONS NO) -set_target_properties( - builder-options growable-buffer - PROPERTIES CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES - CXX_EXTENSIONS NO) - # Build test suite? if(BUILD_TESTS) add_subdirectory(tests) diff --git a/header-only/examples/cython/CMakeLists.txt b/header-only/examples/cython/CMakeLists.txt index 609ecc52dd..dc6d8b616a 100644 --- a/header-only/examples/cython/CMakeLists.txt +++ b/header-only/examples/cython/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 3.15...3.26) project(demo LANGUAGES CXX C) -# Set required standards -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - # Download headers include(FetchContent) set(AWKWARD_VERSION "v2.0.10") diff --git a/header-only/examples/pybind11/CMakeLists.txt b/header-only/examples/pybind11/CMakeLists.txt index 7d6c2fb472..32d38d2da7 100644 --- a/header-only/examples/pybind11/CMakeLists.txt +++ b/header-only/examples/pybind11/CMakeLists.txt @@ -5,10 +5,6 @@ project( LANGUAGES CXX VERSION ${SKBUILD_PROJECT_VERSION}) -# Set required standards -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - # Download headers include(FetchContent) set(AWKWARD_VERSION "v2.0.10") diff --git a/header-only/tests/CMakeLists.txt b/header-only/tests/CMakeLists.txt index 3987a8f097..99ddddfbf0 100644 --- a/header-only/tests/CMakeLists.txt +++ b/header-only/tests/CMakeLists.txt @@ -7,8 +7,7 @@ macro(addtest_nolibs name filename) ${name} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON - CXX_STANDARD 14) - target_compile_features(${name} INTERFACE cxx_std_14) + CXX_EXTENSIONS NO) add_test(${name} ${name}) endmacro(addtest_nolibs) diff --git a/pyproject.toml b/pyproject.toml index 4d7b1dc682..4234fd585a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ classifiers = [ "Topic :: Utilities", ] dependencies = [ - "awkward_cpp==22", + "awkward_cpp==23", "importlib_metadata>=4.13.0;python_version < \"3.12\"", "numpy>=1.18.0", "packaging",