From 83db02e68da290861cc1ea418f9037f9886f8d9b Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 9 Jul 2021 11:55:10 +0300
Subject: [PATCH] cmake: check immintrin.h and set -DSDL_DISABLE_IMMINTRIN_H if
necessary
just in case. fixes build using older gcc. (yes, I'm being overzealous.)
---
CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7dc89f5..7a5db29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ set(SDL12COMPAT_SRCS
add_library(SDL SHARED ${SDL12COMPAT_SRCS})
include(CheckCSourceCompiles)
+include(CheckIncludeFile)
include(CheckCCompilerFlag)
include(GNUInstallDirs)
@@ -57,6 +58,11 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror=declaration-after-statement")
endif()
endif()
+# just in case:
+check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
+if(NOT HAVE_IMMINTRIN_H)
+ set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DSDL_DISABLE_IMMINTRIN_H")
+endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)