diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a3316d1f..cbad369860 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,16 @@ cmake_minimum_required(VERSION 3.13) project(godot-cpp LANGUAGES CXX) +# Configure CMake +# https://discourse.cmake.org/t/how-do-i-remove-compile-options-from-target/5965 +# https://stackoverflow.com/questions/74426638/how-to-remove-rtc1-from-specific-target-or-file-in-cmake +if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) + if(NOT CMAKE_BUILD_TYPE MATCHES Debug) + STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + endif () +endif () + # Add path to modules list( APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/" ) include( godotcpp ) diff --git a/cmake/godotcpp.cmake b/cmake/godotcpp.cmake index 315d727094..b50bcbca7f 100644 --- a/cmake/godotcpp.cmake +++ b/cmake/godotcpp.cmake @@ -28,7 +28,7 @@ function( godotcpp_options ) set(GODOT_USE_HOT_RELOAD "" CACHE BOOL "Enable the extra accounting required to support hot reload. (ON|OFF)") - #TODO disable_exceptions + option(GODOT_DISABLE_EXCEPTIONS "Force disabling exception handling code (ON|OFF)" ON ) set( GODOT_SYMBOL_VISIBILITY "hidden" CACHE STRING "Symbols visibility on GNU platforms. Use 'auto' to apply the default value. (auto|visible|hidden)") @@ -105,8 +105,6 @@ function( godotcpp_generate ) set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi else() set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MD /O2") # /Oy /GL /Gy - STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) endif(CMAKE_BUILD_TYPE MATCHES Debug) add_definitions(-DNOMINMAX) @@ -120,7 +118,6 @@ function( godotcpp_generate ) # 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 "Force disabling exception handling code (ON|OFF)" ON ) if (GODOT_DISABLE_EXCEPTIONS) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -D_HAS_EXCEPTIONS=0")