Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't include simgrid/config.h from simgrid/modelchecker.h so that the later is cheap...
[simgrid.git] / tools / cmake / Flags.cmake
index d84df86e0c1405cafaf0cf51b5f8f7347d63cebf..ba2e37fe709d77028af1864174ac70341831da9a 100644 (file)
@@ -14,7 +14,7 @@ set(optCFLAGS "")
 set(warnCXXFLAGS "")
 
 if(enable_compile_warnings)
-  set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")
+  set(warnCFLAGS "-fno-common -Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")
   if(CMAKE_COMPILER_IS_GNUCC)
     set(warnCFLAGS "${warnCFLAGS} -Wclobbered -Wformat-signedness -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes -Wno-error=maybe-uninitialized")
   endif()
@@ -32,7 +32,7 @@ if(enable_compile_warnings)
     set(warnCFLAGS "${warnCFLAGS} -diag-disable=191,1418,2196,2651,3179 -diag-warning=597,2330,11003")
   endif()
 
-  set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")
+  set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")
   if(CMAKE_COMPILER_IS_GNUCXX)
     set(warnCXXFLAGS "${warnCXXFLAGS} -Wclobbered -Wformat-signedness -Wno-error=clobbered -Wno-free-nonheap-object -Wno-unused-local-typedefs -Wno-error=attributes -Wno-error=maybe-uninitialized")
   endif()
@@ -44,6 +44,10 @@ if(enable_compile_warnings)
     # don't care about class that become struct, avoid issue of empty C structs
     # size (coming from libunwind.h)
     set(warnCXXFLAGS "${warnCXXFLAGS} -Wno-mismatched-tags -Wno-extern-c-compat")
+    # also ignore deprecated builtins (seen with clang 15 + boost 1.79)
+    if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0")
+      set(warnCXXFLAGS "${warnCXXFLAGS} -Wno-deprecated-builtins")
+    endif()
   endif()
 
   # the one specific to C but refused by C++
@@ -84,6 +88,12 @@ if(enable_compile_optimizations)
 else()
   set(optCFLAGS "-O0 ")
 endif()
+
+#ARM platforms have signed char by default, switch to unsigned for consistancy
+if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
+  set(optCFLAGS "${optCFLAGS} -fsigned-char")
+endif()
+
 if(enable_compile_optimizations AND CMAKE_COMPILER_IS_GNUCC
     AND (NOT enable_model-checking))
   # This is redundant (already in -03):
@@ -91,7 +101,7 @@ if(enable_compile_optimizations AND CMAKE_COMPILER_IS_GNUCC
 endif()
 
 # Do not leak the current directory into the binaries
-if(CMAKE_COMPILER_IS_GNUCC)
+if(CMAKE_COMPILER_IS_GNUCC AND NOT enable_coverage)
   execute_process(COMMAND realpath --relative-to=${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}
     RESULT_VARIABLE RESULT OUTPUT_VARIABLE RELATIVE_SOURCE_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
   if(RESULT EQUAL 0)
@@ -191,7 +201,8 @@ endif()
 
 if (CMAKE_C_COMPILER_ID MATCHES "Intel")
   # honor parentheses when determining the order of expression evaluation.
-  set(optCFLAGS "${optCFLAGS} -fprotect-parens ")
+  # disallow optimizations for floating-point arithmetic with Nans or +-Infs (breaks Eigen3)
+  set(optCFLAGS "${optCFLAGS} -fprotect-parens -fno-finite-math-only")
 endif()
 
 if(NOT enable_debug)