From 3e2dfffdb901508420f0f4a5316df20a86662dea Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Mon, 11 Mar 2024 12:40:04 +1000 Subject: [PATCH] Allow to control C++ standard to use --- .github/workflows/cmake-ci.yml | 8 ++++++-- CMakeLists.txt | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake-ci.yml b/.github/workflows/cmake-ci.yml index aa4f940..f406527 100644 --- a/.github/workflows/cmake-ci.yml +++ b/.github/workflows/cmake-ci.yml @@ -20,13 +20,16 @@ jobs: os: [ubuntu-latest, macos-latest] build_type: [Release, Debug] skip_meson: [false] + cxx_latest: [On] include: - os: ubuntu-20.04 build_type: Release skip_meson: true + cxx_latest: Off - os: ubuntu-20.04 build_type: Debug skip_meson: true + cxx_latest: Off # The CMake configure and build commands are platform agnostic and should work equally @@ -40,12 +43,13 @@ jobs: OS_NAME: ${{ matrix.os }} BUILD_TYPE: ${{ matrix.build_type }} SKIP_MESON: ${{ matrix.skip_meson }} + CXX_LATEST: ${{ matrix.cxx_latest }} steps: - uses: actions/checkout@v3 - name: Dump environment variables - run: echo "OS_NAME=$OS_NAME, BUILD_TYPE=$BUILD_TYPE, SKIP_MESON=$SKIP_MESON" + run: echo "OS_NAME=$OS_NAME, BUILD_TYPE=$BUILD_TYPE, SKIP_MESON=$SKIP_MESON, CXX_LATEST=$CXX_LATEST" - name: Install packages for Linux if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} @@ -58,7 +62,7 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DAV_CXX_LATEST=${{ matrix.cxx_latest }} - name: Build # Build your program with the given configuration diff --git a/CMakeLists.txt b/CMakeLists.txt index 994536f..bc41694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,16 @@ set(FFMPEG_PKG_CONFIG_SUFFIX "" CACHE STRING "This suffix uses for FFmpeg compon set(AV_ENABLE_STATIC On CACHE BOOL "Enable static library build (On)") set(AV_ENABLE_SHARED On CACHE BOOL "Enable shared library build (On)") set(AV_BUILD_EXAMPLES On CACHE BOOL "Build example applications (On)") +set(AV_CXX_LATEST On CACHE BOOL "Use most modern C++ compiler features (On), otherwise use C++17") -# Compiler-specific C++11 activation. -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED no) +# Compiler-specific Modern C++ activation. +if (AV_CXX_LATEST) + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_CXX_STANDARD_REQUIRED no) +else() + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED yes) +endif() # Warnings set (AVCPP_WARNING_OPTIONS