summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-02-18 13:29:19 +0000
committerJose Fonseca <jfonseca@vmware.com>2015-02-20 11:50:33 +0000
commit435d7a2c9a410e2771e3b6417f3acfc6cc9f711f (patch)
treebc86cab135893f0c4cb9a2c6044aa8212ce1641a /CMakeLists.txt
parent6433b3c88ce65f8694c31a14975e99f8a93b6ce3 (diff)
cmake: Enforce standard C99 syntax for variadic macros.
Although the non-standard GCC syntax has some nice properties, for most practical cases the standard C99 syntax is perfectly fine. Particuarly for printf-like macros, which pretty much account for most the uses of variadic macros in piglit. Unfortunately this will only be effective on newer GCC versions, due a bug in GCC. See comment for more details. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4236c89ae..420f76f36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,6 +214,17 @@ if (NOT MSVC)
IF (C_COMPILER_FLAG_WVLA)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla")
ENDIF ()
+ # MSVC only supports C99 variadic macros. It doesn't support the
+ # non-standard GNU named variadic macro syntax that's documented in
+ # https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
+ #
+ # XXX: on older GCC version this option has no effect unless -Wpedantic
+ # is set, but this should be fixed on future GCC versions, per
+ # https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01459.html
+ check_c_compiler_flag ("-Werror=variadic-macros" C_COMPILER_FLAG_WVARIADIC_MACROS)
+ if (C_COMPILER_FLAG_WVARIADIC_MACROS)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=variadic-macros")
+ endif ()
CHECK_CXX_COMPILER_FLAG("-Wno-narrowing" CXX_COMPILER_FLAG_WNO_NARROWING)
IF (CXX_COMPILER_FLAG_WNO_NARROWING)