diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-16 11:47:19 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-22 12:45:46 +0200 |
commit | bf1c03ab5f079d0931cf4390e7435a20cfaacfbd (patch) | |
tree | edc6f759871b75909539b829a809dfc7b89b93d2 /test/CMakeLists.txt | |
parent | 0a6a19e33bb75d9f6f23adf16b4e695d009b0fc6 (diff) | |
download | redot-cpp-bf1c03ab5f079d0931cf4390e7435a20cfaacfbd.tar.gz |
SCons: Disable C++ exception handling by default
Counterpart to https://github.com/godotengine/godot/pull/80612.
Diffstat (limited to 'test/CMakeLists.txt')
-rw-r--r-- | test/CMakeLists.txt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0538c5d..4b25f41 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,7 +36,7 @@ set(GODOT_LINKER_FLAGS ) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc /WX") # /GF /MP + set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /WX") # /GF /MP set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /DTYPED_METHOD_BIND") if(CMAKE_BUILD_TYPE MATCHES Debug) @@ -92,6 +92,21 @@ else() endif(CMAKE_BUILD_TYPE MATCHES Debug) endif() +# Disable exception handling. Godot doesn't use exceptions anywhere, and this +# saves around 20% of binary size and very significant build time (GH-80513). +option(GODOT_DISABLE_EXCEPTIONS ON "Force disabling exception handling code") +if (GODOT_DISABLE_EXCEPTIONS) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -D_HAS_EXCEPTIONS=0") + else() + set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-exceptions") + endif() +else() + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc") + endif() +endif() + # Get Sources file(GLOB_RECURSE SOURCES src/*.c**) file(GLOB_RECURSE HEADERS include/*.h**) |