aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2012-01-17 19:25:35 +0000
committerJosé Fonseca <jfonseca@vmware.com>2012-01-20 08:28:37 +0000
commitf08ef39d524e8b91075197fd8e6aeb7c6a43c293 (patch)
treef383fa842cfd7b1706cfcce77440f7c2706c823b /CMakeLists.txt
parent17f35429a20542783586b821057afd799461fa2d (diff)
downloadpiglit-f08ef39d524e8b91075197fd8e6aeb7c6a43c293.tar.gz
cmake: Warn when placing declarations after statements.
Unfortunately this will enable the warning even on OS specific directories will never be built with MSVC, but it looks like the use of this C99 is actually very scarce, even on those OS specific directories. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 179340e5..d4b5b2a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,14 @@ if (NOT MSVC)
IF (CXX_COMPILER_FLAG_WALL)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ENDIF (CXX_COMPILER_FLAG_WALL)
+
+ # Unfortunately MSVC does not support C99. Among all features enabled
+ # by C99, declarations after statements is the most frequently used.
+ # For portability sake, we request gcc to warn when this is used.
+ CHECK_C_COMPILER_FLAG("-Wall" C_COMPILER_FLAG_WDECL_AFTER_STMT)
+ IF (C_COMPILER_FLAG_WDECL_AFTER_STMT)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
+ ENDIF (C_COMPILER_FLAG_WDECL_AFTER_STMT)
else ()
# -Wall or (/Wall) is actually supported by MSVC and would be detected
# by CHECK_C_COMPILER_FLAG above, but is very pedantic, causing