From c57c2aed64bc41af38a0664c6d092295af506043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars-Christian=20Fu=CC=88rstenberg?= Date: Thu, 22 Aug 2024 10:34:12 +0200 Subject: [PATCH] Added CI build for C++20 --- .github/workflows/build_cmake.yml | 10 +++++++--- .gitignore | 3 ++- CMakeLists.txt | 4 ++-- include/rexsapi/Types.hxx | 2 +- test/TypesTest.cxx | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 6d805d9..05b4a73 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -4,6 +4,7 @@ on: push: paths-ignore: - "**/README.md" + - "**/CHANGELOG.md" pull_request: release: branches: @@ -24,6 +25,7 @@ jobs: os: [ubuntu-22.04] build_type: [Debug, Release] cxx: [g++, clang++-15] + cxx_version: [17, 20] steps: - uses: actions/checkout@v4 - name: Install dependencies @@ -39,7 +41,7 @@ jobs: - name: Configure env: CXX: ${{ matrix.cxx }} - run: mkdir build && cd build && cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOVERAGE=${{ env.COVERAGE }} .. + run: mkdir build && cd build && cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} -DCOVERAGE=${{ env.COVERAGE }} .. - name: Build run: cmake --build build - name: Test @@ -98,12 +100,13 @@ jobs: matrix: os: [macos-12] build_type: [Debug, Release] + cxx_version: [17, 20] steps: - uses: actions/checkout@v4 - name: Install dependencies run: brew install doxygen - name: Configure - run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .. + run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} .. - name: Build run: cmake --build build --config ${{ matrix.build_type }} - name: Test @@ -133,12 +136,13 @@ jobs: matrix: os: [windows-2022] build_type: [Debug, Release] + cxx_version: [17, 20] steps: - uses: actions/checkout@v4 - name: Install dependencies run: choco install doxygen.install - name: Configure - run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .. + run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} .. - name: Build run: cmake --build build --config ${{ matrix.build_type }} - name: Test diff --git a/.gitignore b/.gitignore index 2f3bb7a..718e035 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ build_xcode check_loc.sh ignore_files.txt CMakeSettings.json -docker \ No newline at end of file +docker +.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index ecdea63..c545a5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,9 @@ include(cmake/fetch_valijson.cmake) if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) endif() +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) if(CMAKE_CXX_STANDARD LESS 17) message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 17, REXSapi only works with C++17 and above.") diff --git a/include/rexsapi/Types.hxx b/include/rexsapi/Types.hxx index d3a1993..44412e6 100644 --- a/include/rexsapi/Types.hxx +++ b/include/rexsapi/Types.hxx @@ -21,7 +21,7 @@ #include #include -#if __cplusplus >= 202002L || _MSVC_LANG >= 202002L +#if (__cplusplus >= 202002L || _MSVC_LANG >= 202002L) && not __APPLE__ #include namespace rexs_date = std::chrono; namespace rexs_format = std; diff --git a/test/TypesTest.cxx b/test/TypesTest.cxx index d51c895..e0c081d 100644 --- a/test/TypesTest.cxx +++ b/test/TypesTest.cxx @@ -159,7 +159,7 @@ TEST_CASE("Datetime test") SUBCASE("Parse") { const rexsapi::TDatetime dt{"2023-03-28T13:49:36+02:00"}; -#if __cplusplus >= 202002L || _MSVC_LANG >= 202002L +#if (__cplusplus >= 202002L || _MSVC_LANG >= 202002L) && not __APPLE__ auto rexs_march = std::chrono::March; #else auto rexs_march = date::mar;