From 3e39df11f9163e4e421be8d8fc31b71eacf8f6fe Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 25 Jul 2015 11:14:40 +0200 Subject: [PATCH] we need std=gnu11 in C too (was std=gnu99) --- buildtools/Cmake/Flags.cmake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/buildtools/Cmake/Flags.cmake b/buildtools/Cmake/Flags.cmake index 6df76ebe45..b3dc83771c 100644 --- a/buildtools/Cmake/Flags.cmake +++ b/buildtools/Cmake/Flags.cmake @@ -4,7 +4,7 @@ set(optCFLAGS "") ## ## Request full debugging flags ## -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -g3") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") @@ -21,13 +21,27 @@ else() "Please use a decent C++ compiler.") endif() if (CMAKE_COMPILER_IS_GNUCC) - if (COMPILER_C_VERSION_MAJOR_MINOR STRLESS "4.7") + if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7") message(FATAL_ERROR "SimGrid needs g++ version 4.7 to compile " "(c++11 support of previous versions is too limited).") endif() endif() +### +### And we need C11 standard, too +### +include(CheckCCompilerFlag) +CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11) +if(COMPILER_SUPPORTS_C11) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") +else() + message(FATAL_ERROR + "The compiler ${CMAKE_C_COMPILER} has no C11 support. " + "Please use a decent C compiler " + "(note that c++11 support of ${CMAKE_CXX_COMPILER} seems ok).") +endif() + if(enable_compile_warnings) set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ") -- 2.20.1