From 53062d97bf108e229ec771baddd01d57315abbfd Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 1 Jun 2021 21:09:11 -0400
Subject: [PATCH] Make GCC and Clang fail if there's a declaration after a
statement.
(that is, make it automatically catch C89 incompatibilities before Ozkan has
to clean up my messes for me later.)
---
CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe9e8ec..f73ac90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,10 @@ include(GNUInstallDirs)
include("cmake/modules/FindSDL2.cmake")
target_include_directories(SDL PRIVATE ${SDL2_INCLUDE_DIRS})
+if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
+ add_definitions("-Werror=declaration-after-statement") # force this universally.
+endif()
+
# avoid DLL having 'lib' prefix with Windows MinGW builds
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX "")