X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7b20a596a629242418d813ae845fcd64d36fc150..561cb30f87c531af6b562249ddf90fac2a44aa92:/tools/cmake/GCCFlags.cmake diff --git a/tools/cmake/GCCFlags.cmake b/tools/cmake/GCCFlags.cmake index 0a1719720d..3ca730963d 100644 --- a/tools/cmake/GCCFlags.cmake +++ b/tools/cmake/GCCFlags.cmake @@ -19,12 +19,14 @@ if(enable_compile_warnings) set(warnCFLAGS "${warnCFLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes") 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 -Wno-format-nonliteral -Werror") + 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 -Wno-format-nonliteral") if(CMAKE_COMPILER_IS_GNUCXX) set(warnCXXFLAGS "${warnCXXFLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes") endif() - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # don't care about class that become struct - set(warnCXXFLAGS "${warnCXXFLAGS} -Wno-mismatched-tags") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # 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") endif() # the one specific to C but refused by C++ @@ -37,6 +39,7 @@ endif() # NDEBUG gives a lot of "initialized but unused variables" errors. Don't die anyway. if(enable_compile_warnings AND enable_debug) set(warnCFLAGS "${warnCFLAGS} -Werror") + set(warnCXXFLAGS "${warnCXXFLAGS} -Werror") endif() # Activate the warnings on #if FOOBAR when FOOBAR has no value @@ -162,6 +165,25 @@ if(enable_coverage) endif() endif() +if(enable_address_sanitizer) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") + set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=address") + set(TESH_OPTION --enable-sanitizers) +endif() + +if(enable_thread_sanitizer) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie") + set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=thread -no-pie") +endif() + +if(enable_undefined_sanitizer) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer") + set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=undefined") +endif() + if(NOT $ENV{CFLAGS} STREQUAL "") message(STATUS "Add CFLAGS: \"$ENV{CFLAGS}\" to CMAKE_C_FLAGS") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}") @@ -192,7 +214,7 @@ if(MINGW) set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -Wl,--add-stdcall-alias") # Specify the data model that we are using (yeah it may help Java) - if(ARCH_32_BITS) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32 bits set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") else()