Skip to content

Commit

Permalink
Changed: Make sure RTTI an exceptions are disabled on all supported p…
Browse files Browse the repository at this point in the history
…latforms
  • Loading branch information
richardbiely committed Oct 6, 2024
1 parent b820dea commit 5c1a8fd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -208,18 +206,25 @@ 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}")

# 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)
Expand Down

0 comments on commit 5c1a8fd

Please sign in to comment.