From 7eca84d57ed30b320d6c36c34557d48f448cfee0 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Wed, 21 Feb 2024 00:51:40 +0100
Subject: [PATCH] cmake: don't use target_compile_features when the CMake
thinks the compiler does not support it
This happens when using an older CMake with a new LLVM toolchain (e.g. Android ndk)
---
CMakeLists.txt | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74ed3a10de2d..5818a6e18955 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,14 +372,22 @@ if(SDL_SHARED)
add_library(SDL3-shared SHARED)
add_library(SDL3::SDL3-shared ALIAS SDL3-shared)
SDL_AddCommonCompilerFlags(SDL3-shared)
- target_compile_features(SDL3-shared PRIVATE c_std_99)
+ if ("c_std_99" IN_LIST CMAKE_C_COMPILE_FEATURES)
+ target_compile_features(SDL3-shared PRIVATE c_std_99)
+ else()
+ message(WARNING "target_compile_features does not know c_std_99 for C compiler")
+ endif()
endif()
if(SDL_STATIC)
add_library(SDL3-static STATIC)
add_library(SDL3::SDL3-static ALIAS SDL3-static)
SDL_AddCommonCompilerFlags(SDL3-static)
- target_compile_features(SDL3-static PRIVATE c_std_99)
+ if ("c_std_99" IN_LIST CMAKE_C_COMPILE_FEATURES)
+ target_compile_features(SDL3-static PRIVATE c_std_99)
+ else()
+ message(WARNING "target_compile_features does not know c_std_99 for C compiler")
+ endif()
endif()
if(SDL_TEST_LIBRARY)