Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'surf++'
[simgrid.git] / buildtools / Cmake / Flags.cmake
index 68cae01..9c37da3 100644 (file)
@@ -11,12 +11,12 @@ else()
 endif()
 
 if(enable_compile_warnings)
-  set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wclobbered -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror -Wno-error=clobbered ")
-  if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
-    set(warnCFLAGS "${warnCFLAGS}-Wno-error=unused-but-set-variable ")
-  endif()
-  if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
-    string(REPLACE "-Wclobbered " "" warnCFLAGS "${warnCFLAGS}")
+  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 ")
+  if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+    set(warnCFLAGS "${warnCFLAGS}-Wclobbered -Wno-error=clobbered ")
+    if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
+      set(warnCFLAGS "${warnCFLAGS}-Wno-error=unused-but-set-variable ")
+    endif()
   endif()
 
   set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall") # FIXME: Q&D hack
@@ -26,15 +26,17 @@ endif()
 
 if(enable_compile_optimizations)
   set(optCFLAGS "-O3 -finline-functions -funroll-loops -fno-strict-aliasing ")
-  if(WIN32)
-    if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.7")
-    # 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 ")
-    endif()
-  else()    
-    # On non-windows, 4.6 is enough for that
-    if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
-      set(optCFLAGS "${optCFLAGS} -flto ")
+  if(CMAKE_COMPILER_IS_GNUCC)
+    if(WIN32)
+      if (COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.7")
+      # 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 ")
+      endif()
+    else()    
+      # On non-windows, 4.6 is enough for that
+      if(COMPILER_C_VERSION_MAJOR_MINOR STRGREATER "4.5")
+        set(optCFLAGS "${optCFLAGS} -flto ")
+      endif()
     endif()
   endif()
 else()
@@ -67,9 +69,10 @@ set(TESH_OPTION "")
 if(enable_coverage)
   find_program(GCOV_PATH gcov)
   if(GCOV_PATH)
-    SET(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
+    set(COVERAGE_COMMAND "${GCOV_PATH}" CACHE TYPE FILEPATH FORCE)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOVERAGE")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fprofile-arcs -ftest-coverage")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
     set(TESH_OPTION --enable-coverage)