From e338287e64a430773bcfc5e9f090e1572d10ecc0 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 30 Jan 2026 18:41:16 +0100 Subject: [PATCH] cmake: treat linker warnings as errors when configuring with SDL_WERROR=ON --- cmake/sdlcompilers.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/sdlcompilers.cmake b/cmake/sdlcompilers.cmake index 3ea5a97555..f9d5a9c313 100644 --- a/cmake/sdlcompilers.cmake +++ b/cmake/sdlcompilers.cmake @@ -155,6 +155,18 @@ function(SDL_AddCommonCompilerFlags TARGET) endif() endif() endif() + + if(NOT (APPLE OR MSVC)) + if(SDL_WERROR) + get_property(target_type TARGET ${TARGET} PROPERTY TYPE) + if(target_type MATCHES "SHARED_LIBRARY|MODULE_LIBRARY") + check_linker_flag(C "-Wl,-fatal-warnings" LINKER_SUPPORTS_WL_FATAL_WARNINGS) + if(LINKER_SUPPORTS_WL_FATAL_WARNINGS) + target_link_options(${TARGET} PRIVATE "-Wl,-fatal-warnings") + endif() + endif() + endif() + endif() endif() if(USE_CLANG)