From 4b7fb3bf41a0ca4c97fad3799949a2aa61b13b99 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 27 Feb 2023 18:38:35 +0200 Subject: CMake: Require that the C compiler supports C99 or a newer standard. Thanks to autoantwort for reporting the issue and suggesting a different patch: https://github.com/tukaani-project/xz/pull/42 --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44869e59..478fb413 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,14 @@ string(REGEX REPLACE # Among other things, this gives us variables xz_VERSION and xz_VERSION_MAJOR. project(xz VERSION "${XZ_VERSION}" LANGUAGES C) +# We need a compiler that supports enough C99 or newer (variable-length arrays +# aren't needed, those are optional in C17). Setting CMAKE_C_STANDARD here +# makes it the default for all targets. It doesn't affect the INTERFACE so +# liblzma::liblzma won't end up with INTERFACE_COMPILE_FEATURES "c_std_99" +# (the API headers are C89 and C++ compatible). +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + # On Apple OSes, don't build executables as bundles: set(CMAKE_MACOSX_BUNDLE OFF) -- cgit v1.2.3