From 8e87ebc069835e10271abf990e0ee8d6c5d226e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Wed, 6 Nov 2024 17:24:07 +0100 Subject: [PATCH] Add compile option -fno-strict-aliasing for all compilers but MSVC. (#1212) --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ab97d554..316e3fc82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,11 @@ endif() # globally add VKB_DEBUG for the debug build add_compile_definitions($<$:VKB_DEBUG>) +# globally set -fno-strict-aliasing, needed due to using reinterpret_cast +if (!MSVC) + add_compile_options(-fno_strict_aliasing) +endif() + if(MSVC AND (DEFINED CMAKE_C_COMPILER_LAUNCHER)) message(DEBUG "Setting MSVC flags to /Z7 for ccache compatibility. Current flags: ${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")