Skip to content

Commit

Permalink
chore: bump C++ standard version (#2685)
Browse files Browse the repository at this point in the history
* 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 <henryschreineriii@gmail.com>

* fix: awkward-cpp expected version

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
agoose77 and henryiii committed Sep 4, 2023
1 parent 519bba6 commit a5efdfe
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 32 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'
Expand Down
24 changes: 17 additions & 7 deletions awkward-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 $<TARGET_OBJECTS:awkward-cpu-kernels-objects>)
set_property(TARGET awkward-cpu-kernels-static PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -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 $<TARGET_OBJECTS:awkward-objects>)
set_property(TARGET awkward-static PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
Expand Down
13 changes: 1 addition & 12 deletions header-only/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ macro(add_component name)
target_include_directories(
${name} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${name}>
$<INSTALL_INTERFACE:include/${name}>)
target_compile_features(${name} INTERFACE cxx_std_17)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${name}/awkward"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${name}")
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions header-only/examples/cython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 0 additions & 4 deletions header-only/examples/pybind11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions header-only/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a5efdfe

Please sign in to comment.