소스 검색

Merge commit '837416ef8508c2abda02da8b8c2fe4d1a877e78a' into main

Sam Lantinga 2 년 전
부모
커밋
f890f97286
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      CMakeLists.txt

+ 11 - 2
CMakeLists.txt

@@ -551,15 +551,24 @@ if(USE_GCC OR USE_CLANG)
     target_compile_options(sdl-global-options INTERFACE "-fno-strict-aliasing")
     target_compile_options(sdl-global-options INTERFACE "-fno-strict-aliasing")
   endif()
   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)
   check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
   if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
   if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
     if(SDL_WERROR)
     if(SDL_WERROR)
       check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
       check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
       if(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 "$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:OBJCC>>:-Werror=declaration-after-statement>")
+        endif()
       endif()
       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 "$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:OBJC>>:-Wdeclaration-after-statement>")
+    endif()
   endif()
   endif()
 
 
   check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)
   check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)