From 5c1a8fdbe3c4f6ba6ad2c5bf8d34e5090143b081 Mon Sep 17 00:00:00 2001 From: Richard Biely Date: Sun, 6 Oct 2024 14:24:37 +0200 Subject: [PATCH] Changed: Make sure RTTI an exceptions are disabled on all supported platforms --- src/CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0346f01b..50d6b3fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -161,8 +161,6 @@ else() endif() endif() - enable_cxx_compiler_flag_if_supported("-fno-exceptions") - # strictness rules # Tracy profiler is not written with strictness and warnings-as-errors in mind # so rather than reading spam in the build output we disable any strictness @@ -208,6 +206,12 @@ else() endif() endif() +# Turn off RTTI and exception handling +# Ideally we would want something like following: +# set(CMAKE_CXX_EXCEPTIONS OFF) +# set(CMAKE_CXX_RTTI OFF) +# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4634 +# However, it does not look like it is ever going to happen so let us do things manually. if(MSVC) # Turn off RTTI string(REGEX REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -215,11 +219,12 @@ if(MSVC) # Turn off exceptions (including in STL) string(REGEX REPLACE "/EHsc" "/EHs-c-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_definitions(-D_HAS_EXCEPTIONS=0) +else() + # Turn off RTTI + enable_cxx_compiler_flag_if_supported("-fno-rtti") - # TODO: Enable this once it lands - # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4634 - # set(CMAKE_CXX_EXCEPTIONS OFF) - # set(CMAKE_CXX_RTTI OFF) + # Turn off exceptions (including in STL) + enable_cxx_compiler_flag_if_supported("-fno-exceptions") endif() set(IS_FETCH_AVAILABLE OFF)