From 837416ef8508c2abda02da8b8c2fe4d1a877e78a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 9 Jan 2023 18:02:40 +0100 Subject: [PATCH] =?UTF-8?q?cmake:=20command-line=20option=20=E2=80=98-Wdec?= =?UTF-8?q?laration-after-statement=E2=80=99=20is=20valid=20for=20C/ObjC?= =?UTF-8?q?=20but=20not=20for=20C++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca0efe7072..0e0bf0e05e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -551,15 +551,24 @@ if(USE_GCC OR USE_CLANG) target_compile_options(sdl-global-options INTERFACE "-fno-strict-aliasing") endif() + # command-line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT) if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT) if(SDL_WERROR) check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) - target_compile_options(sdl-global-options INTERFACE "-Werror=declaration-after-statement") + if(CMAKE_VERSION VERSION_LESS 3.3) + target_compile_options(sdl-global-options INTERFACE "-Werror=declaration-after-statement") + else() + target_compile_options(sdl-global-options INTERFACE "$<$,$>:-Werror=declaration-after-statement>") + endif() endif() endif() - target_compile_options(sdl-global-options INTERFACE "-Wdeclaration-after-statement") + if(CMAKE_VERSION VERSION_LESS 3.3) + target_compile_options(sdl-global-options INTERFACE "-Wdeclaration-after-statement") + else() + target_compile_options(sdl-global-options INTERFACE "$<$,$>:-Wdeclaration-after-statement>") + endif() endif() check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)