Browse Source

cmake: check again for unknown documentation commands

Anonymous Maarten 2 years ago
parent
commit
b8adf90aa3
1 changed files with 19 additions and 3 deletions
  1. 19 3
      CMakeLists.txt

+ 19 - 3
CMakeLists.txt

@@ -578,10 +578,26 @@ if(USE_GCC OR USE_CLANG)
       endif()
     endif()
     target_compile_options(sdl-global-options INTERFACE "-Wdocumentation")
+  endif()
 
-    check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS)
-    if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
-      target_compile_options(sdl-global-options INTERFACE "-fcomment-block-commands=threadsafety")
+  check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
+  if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
+    if(SDL_WERROR)
+      check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
+      if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
+        target_compile_options(sdl-global-options INTERFACE "-Werror=documentation-unknown-command")
+      endif()
+    endif()
+    target_compile_options(sdl-global-options INTERFACE "-Wdocumentation-unknown-command")
+  endif()
+
+  check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS)
+  if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
+    target_compile_options(sdl-global-options INTERFACE "-fcomment-block-commands=threadsafety")
+  else()
+    check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
+    if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
+      target_compile_options(sdl-global-options INTERFACE "/clang:-fcomment-block-commands=threadsafety")
     endif()
   endif()