From e27dc50689885736b0b79fde22c9d24046264f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 13 Aug 2017 20:03:12 +0200 Subject: [PATCH] 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. --- src/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e9d17f2..5c8f33e6 100644 --- a/src/CMakeLists.txt +++ b/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}