summaryrefslogtreecommitdiff
path: root/libs/raylib/cmake/CompilerFlags.cmake
diff options
context:
space:
mode:
authorLucaSas <sas.luca.alex@gmail.com>2021-11-04 16:15:47 +0200
committerLucaSas <sas.luca.alex@gmail.com>2021-11-04 16:15:47 +0200
commit4e34ae85948438f726a911c9dbb8616968a378a5 (patch)
tree07b470559a9f973bcf695938606c7c28cd5e161a /libs/raylib/cmake/CompilerFlags.cmake
parentd96b4ebce5ee6245fa80d27d41b67aa56555c912 (diff)
parentd227d3c609c4b95fa9c8a0ba5a10e7c47bcb984c (diff)
downloadgamejam-slgj-2024-4e34ae85948438f726a911c9dbb8616968a378a5.tar.gz
gamejam-slgj-2024-4e34ae85948438f726a911c9dbb8616968a378a5.tar.bz2
gamejam-slgj-2024-4e34ae85948438f726a911c9dbb8616968a378a5.zip
Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md # libs/raylib/.gitignore # libs/raylib/BINDINGS.md # libs/raylib/CHANGELOG # libs/raylib/CMakeLists.txt # libs/raylib/CONTRIBUTING.md # libs/raylib/HISTORY.md # libs/raylib/LICENSE # libs/raylib/README.md # libs/raylib/ROADMAP.md # libs/raylib/SPONSORS.md # libs/raylib/raylib.pc.in # libs/raylib/src/CMakeLists.txt # libs/raylib/src/Makefile # libs/raylib/src/camera.h # libs/raylib/src/config.h # libs/raylib/src/core.c # libs/raylib/src/easings.h # libs/raylib/src/external/cgltf.h # libs/raylib/src/external/dr_flac.h # libs/raylib/src/external/dr_mp3.h # libs/raylib/src/external/dr_wav.h # libs/raylib/src/external/glfw/CMake/glfw3.pc.in # libs/raylib/src/external/glfw/CMake/glfw3Config.cmake.in # libs/raylib/src/external/glfw/CMakeLists.txt # libs/raylib/src/external/glfw/README.md # libs/raylib/src/external/glfw/include/GLFW/glfw3.h # libs/raylib/src/external/glfw/src/cocoa_init.m # libs/raylib/src/external/glfw/src/cocoa_joystick.h # libs/raylib/src/external/glfw/src/cocoa_joystick.m # libs/raylib/src/external/glfw/src/cocoa_monitor.m # libs/raylib/src/external/glfw/src/cocoa_platform.h # libs/raylib/src/external/glfw/src/cocoa_window.m # libs/raylib/src/external/glfw/src/egl_context.c # libs/raylib/src/external/glfw/src/egl_context.h # libs/raylib/src/external/glfw/src/glfw_config.h.in # libs/raylib/src/external/glfw/src/init.c # libs/raylib/src/external/glfw/src/input.c # libs/raylib/src/external/glfw/src/internal.h # libs/raylib/src/external/glfw/src/linux_joystick.c # libs/raylib/src/external/glfw/src/linux_joystick.h # libs/raylib/src/external/glfw/src/mappings.h # libs/raylib/src/external/glfw/src/nsgl_context.m # libs/raylib/src/external/glfw/src/null_init.c # libs/raylib/src/external/glfw/src/null_joystick.c # libs/raylib/src/external/glfw/src/null_monitor.c # libs/raylib/src/external/glfw/src/null_platform.h # libs/raylib/src/external/glfw/src/null_window.c # libs/raylib/src/external/glfw/src/osmesa_context.h # libs/raylib/src/external/glfw/src/wgl_context.h # libs/raylib/src/external/glfw/src/win32_init.c # libs/raylib/src/external/glfw/src/win32_joystick.c # libs/raylib/src/external/glfw/src/win32_joystick.h # libs/raylib/src/external/glfw/src/win32_monitor.c # libs/raylib/src/external/glfw/src/win32_platform.h # libs/raylib/src/external/glfw/src/win32_window.c # libs/raylib/src/external/glfw/src/window.c # libs/raylib/src/external/glfw/src/wl_init.c # libs/raylib/src/external/glfw/src/wl_monitor.c # libs/raylib/src/external/glfw/src/wl_platform.h # libs/raylib/src/external/glfw/src/wl_window.c # libs/raylib/src/external/glfw/src/x11_init.c # libs/raylib/src/external/glfw/src/x11_monitor.c # libs/raylib/src/external/glfw/src/x11_platform.h # libs/raylib/src/external/glfw/src/x11_window.c # libs/raylib/src/external/jar_xm.h # libs/raylib/src/external/miniaudio.h # libs/raylib/src/external/stb_image.h # libs/raylib/src/external/stb_image_write.h # libs/raylib/src/external/stb_vorbis.h # libs/raylib/src/external/tinyobj_loader_c.h # libs/raylib/src/gestures.h # libs/raylib/src/models.c # libs/raylib/src/physac.h # libs/raylib/src/raudio.c # libs/raylib/src/raudio.h # libs/raylib/src/raylib.dll.rc # libs/raylib/src/raylib.dll.rc.data # libs/raylib/src/raylib.h # libs/raylib/src/raylib.rc # libs/raylib/src/raylib.rc.data # libs/raylib/src/raymath.h # libs/raylib/src/rglfw.c # libs/raylib/src/rlgl.h # libs/raylib/src/rmem.h # libs/raylib/src/rnet.h # libs/raylib/src/shapes.c # libs/raylib/src/text.c # libs/raylib/src/textures.c # libs/raylib/src/utils.c # libs/raylib/src/utils.h
Diffstat (limited to 'libs/raylib/cmake/CompilerFlags.cmake')
-rw-r--r--libs/raylib/cmake/CompilerFlags.cmake79
1 files changed, 79 insertions, 0 deletions
diff --git a/libs/raylib/cmake/CompilerFlags.cmake b/libs/raylib/cmake/CompilerFlags.cmake
new file mode 100644
index 0000000..970462c
--- /dev/null
+++ b/libs/raylib/cmake/CompilerFlags.cmake
@@ -0,0 +1,79 @@
+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)
+
+# 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)
+
+# Allows some casting of pointers without generating a warning
+add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
+
+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")
+endif()
+
+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_C_COMPILER_ID STREQUAL "GNU")
+ add_if_flag_compiles(-std=gnu99 CMAKE_C_FLAGS)
+ endif()
+else()
+ set (CMAKE_C_STANDARD 99)
+endif()
+
+if(${PLATFORM} MATCHES "Android")
+
+ # If enabled will remove dead code during the linking process
+ # https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html
+ add_if_flag_compiles(-ffunction-sections CMAKE_C_FLAGS)
+
+ # If enabled will generate some exception data (usually disabled for C programs)
+ # https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Code-Gen-Options.html
+ add_if_flag_compiles(-funwind-tables CMAKE_C_FLAGS)
+
+ # If enabled adds stack protection guards around functions that allocate memory
+ # https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cjh1548250046139.htm
+ add_if_flag_compiles(-fstack-protector-strong CMAKE_C_FLAGS)
+
+ # Marks that the library will not be compiled with an executable stack
+ add_if_flag_compiles(-Wa,--noexecstack CMAKE_C_FLAGS)
+
+ # Do not expand symbolic links or resolve paths like "/./" or "/../", etc.
+ # https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
+ add_if_flag_compiles(-no-canonical-prefixes CMAKE_C_FLAGS)
+endif()