X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3e39df11f9163e4e421be8d8fc31b71eacf8f6fe..7415b33104fb8d0ff748b4f43a3a7d0ac98c2893:/buildtools/Cmake/Flags.cmake diff --git a/buildtools/Cmake/Flags.cmake b/buildtools/Cmake/Flags.cmake index b3dc83771c..a11db3dbf2 100644 --- a/buildtools/Cmake/Flags.cmake +++ b/buildtools/Cmake/Flags.cmake @@ -1,46 +1,15 @@ -set(warnCFLAGS "") -set(optCFLAGS "") - ## -## Request full debugging flags +## This file is in charge of setting our paranoid flags with regard to warnings and optimization. ## -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") -set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") +## These flags do break some classical CMake tests, so you don't +## want to do so before the very end of the configuration. +## +## Other compiler flags (C/C++ standard version) are tested and set +## by the beginning of the configuration, directly in ~/CMakeList.txt -## -## We need a decent support of the c++11 standard -## -include(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) -if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -else() - message(FATAL_ERROR - "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. " - "Please use a decent C++ compiler.") -endif() -if (CMAKE_COMPILER_IS_GNUCC) - 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() +set(warnCFLAGS "") +set(optCFLAGS "") -### -### 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) @@ -53,9 +22,11 @@ if(enable_compile_warnings) if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wclobbered -Wno-error=clobbered") endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # don't care about class that become struct + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags") + endif() - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") # FIXME: Q&D hack - + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint") endif() @@ -64,9 +35,12 @@ if(enable_compile_optimizations) if(CMAKE_COMPILER_IS_GNUCC AND (NOT enable_model-checking)) set(optCFLAGS "${optCFLAGS} -finline-functions ") if(WIN32) - if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.7") + if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.8") # On windows, we need 4.8 or higher to enable lto because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50293 - set(optCFLAGS "${optCFLAGS} -flto ") + # + # We are experiencing assertion failures even with 4.8 on MinGW. + # Push the support forward: will see if 4.9 works when we test it. + set(optCFLAGS "${optCFLAGS} -flto ") endif() else() # On non-windows, 4.6 is enough for that @@ -113,11 +87,6 @@ if(enable_model-checking AND enable_compile_optimizations) endforeach() endif() -if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") - set(optCFLAGS "-O0 ") -endif() - if(NOT enable_debug) set(CMAKE_C_FLAGS "-DNDEBUG ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-DNDEBUG ${CMAKE_CXX_FLAGS}") @@ -127,8 +96,7 @@ if(enable_msg_deprecated) set(CMAKE_C_FLAGS "-DMSG_USE_DEPRECATED ${CMAKE_C_FLAGS}") endif() -set(CMAKE_C_FLAGS "${optCFLAGS} ${warnCFLAGS} ${CMAKE_C_FLAGS}") - +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${optCFLAGS} ${warnCFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${optCFLAGS}") # Try to make Mac a bit more complient to open source standards