aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-02-27 18:38:35 +0200
committerLasse Collin <lasse.collin@tukaani.org>2023-03-11 21:53:16 +0200
commit01f1da25e5b4b851f850eb3263e184a57cefe923 (patch)
tree140a7757dc34dbe5f683b137cc7377087fb02656
parentUpdate THANKS. (diff)
downloadxz-01f1da25e5b4b851f850eb3263e184a57cefe923.tar.xz
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
-rw-r--r--CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a66310b..db8f6aa1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,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)