Documenting the compiler flags
This commit is contained in:
parent
65b299c6cf
commit
401b680218
|
|
@ -1,28 +1,52 @@
|
||||||
include(AddIfFlagCompiles)
|
include(AddIfFlagCompiles)
|
||||||
|
|
||||||
|
# Makes +/- operations on void pointers be considered an error
|
||||||
|
# https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
|
||||||
add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
|
add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
|
||||||
|
|
||||||
|
# Generates error whenever a function is used before being declared
|
||||||
|
# https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Warning-Options.html
|
||||||
add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
|
add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
|
||||||
# src/external/jar_xm.h does shady stuff
|
|
||||||
|
# Allows some casting of pointers without generating a warning
|
||||||
add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
|
add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
|
||||||
|
|
||||||
if (ENABLE_ASAN)
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
endif()
|
|
||||||
if (ENABLE_UBSAN)
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
endif()
|
|
||||||
if (ENABLE_MSAN)
|
|
||||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
add_if_flag_compiles(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ENABLE_MSAN AND ENABLE_ASAN)
|
if (ENABLE_MSAN AND ENABLE_ASAN)
|
||||||
|
# MSAN and ASAN both work on memory - ASAN does more things
|
||||||
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
|
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions("-DRAYLIB_CMAKE=1")
|
if (ENABLE_ASAN)
|
||||||
|
|
||||||
|
# If enabled it would generate errors/warnings for all kinds of memory errors
|
||||||
|
# (like returning a stack variable by reference)
|
||||||
|
# https://clang.llvm.org/docs/AddressSanitizer.html
|
||||||
|
|
||||||
|
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
add_if_flag_compiles(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_UBSAN)
|
||||||
|
|
||||||
|
# If enabled this will generate errors for undefined behavior points
|
||||||
|
# (like adding +1 to the maximum int value)
|
||||||
|
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
|
||||||
|
|
||||||
|
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
add_if_flag_compiles(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_MSAN)
|
||||||
|
|
||||||
|
# If enabled this will generate warnings for places where uninitialized memory is used
|
||||||
|
# https://clang.llvm.org/docs/MemorySanitizer.html
|
||||||
|
|
||||||
|
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
add_if_flag_compiles(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user