From: Alexander Vieth Date: Thu, 11 Sep 2025 10:27:49 +0000 (+0200) Subject: Allow C17 for newer CMake versions (#1958) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78005695a1b186234477f7ca34ad75770394f05b;p=thirdparty%2Fzlib-ng.git Allow C17 for newer CMake versions (#1958) --- diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a5bf8f2d..5408f897 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -86,6 +86,18 @@ jobs: packages: gcc-multilib g++-multilib codecov: ubuntu_gcc_m32 + - name: Ubuntu GCC C17 + os: ubuntu-latest + compiler: gcc + cxx-compiler: g++ + cmake-args: -DCMAKE_C_STANDARD=17 + + - name: Ubuntu GCC C23 + os: ubuntu-latest + compiler: gcc + cxx-compiler: g++ + cmake-args: -DCMAKE_C_STANDARD=23 + - name: Ubuntu GCC No Chorba os: ubuntu-latest compiler: gcc @@ -422,6 +434,20 @@ jobs: gcov-exec: llvm-cov-15 gcov codecov: ubuntu_clang + - name: Ubuntu Clang C17 + os: ubuntu-latest + compiler: clang-15 + cxx-compiler: clang++-15 + cmake-args: -DCMAKE_C_STANDARD=17 + packages: clang-15 llvm-15 llvm-15-tools + + - name: Ubuntu Clang C23 + os: ubuntu-latest + compiler: clang-18 + cxx-compiler: clang++-18 + cmake-args: -DCMAKE_C_STANDARD=23 + packages: clang-18 llvm-18 llvm-18-tools + # Check for undefined symbols in the version script for the modern api - name: Ubuntu Clang Undefined Symbols os: ubuntu-latest @@ -515,6 +541,11 @@ jobs: compiler: cl cmake-args: -G "Visual Studio 17 2022" -A x64 -T v143 -DWITH_NATIVE_INSTRUCTIONS=ON -DNATIVE_ARCH_OVERRIDE=/arch:AVX + - name: Windows MSVC 2022 v143 Win64 C17 + os: windows-latest + compiler: cl + cmake-args: -G "Visual Studio 17 2022" -A x64 -T v143 -DCMAKE_C_STANDARD=17 + - name: Windows MSVC 2022 v142 Win32 os: windows-latest compiler: cl diff --git a/CMakeLists.txt b/CMakeLists.txt index 38885089..f2d03979 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,9 @@ if(NOT DEFINED CMAKE_C_EXTENSIONS) set(CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested endif() set(VALID_C_STANDARDS "99" "11") +if(CMAKE_VERSION VERSION_GREATER 3.20) + list(APPEND VALID_C_STANDARDS "17" "23") +endif() if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS) MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in known standards list\n ${VALID_C_STANDARDS}") endif()