Parcourir la source

Add non-VS warning about C99 declarations

This adds a warning in GCC and Clang about using intermingled
variable declarations in source files that will be built by VS.

This currently excludes egl_context.c and osmesa_context.c.  It will
be addressed by a separate commit.

Related to #1026.
Camilla Löwy il y a 8 ans
Parent
commit
e27dc50689
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      src/CMakeLists.txt

+ 12 - 0
src/CMakeLists.txt

@@ -66,6 +66,18 @@ if (APPLE)
     set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
+# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
+# for all source files that VS will build
+if (${CMAKE_C_COMPILER_ID} STREQUAL GNU OR ${CMAKE_C_COMPILER_ID} STREQUAL Clang)
+    if (WIN32)
+        set(windows_SOURCES ${glfw_SOURCES})
+    else()
+        set(windows_SOURCES ${common_SOURCES})
+    endif()
+    set_source_files_properties(${windows_SOURCES} PROPERTIES
+        COMPILE_FLAGS -Wdeclaration-after-statement)
+endif()
+
 add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})
 set_target_properties(glfw PROPERTIES
                       OUTPUT_NAME ${GLFW_LIB_NAME}