Skip to content

Commit 719f94b

Browse files
committed
Now that we are specifying the config at build time, the hack to re-write CMAKE_CXX_FLAGS[_DEBUG] flags is no longer needed.
Refactor HOT_RELOAD to use generator expressions Turn on WINDOWS_ENABLED based on WIN32, not IS_MSVC Refactor SYSTEM_NAME and BUILD_TYPE to use generator expressions CMAKE_BUILD_TYPE is no longer depended upon, eliminating config errors for multi-config builds like Visual Studio, and Ninja-MultiConfig
1 parent 123cee0 commit 719f94b

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ project(godot-cpp LANGUAGES CXX)
44
# Get Python
55
find_package(Python3 3.4 REQUIRED) # pathlib should be present
66

7-
# Configure CMake
8-
# https://discourse.cmake.org/t/how-do-i-remove-compile-options-from-target/5965
9-
# https://stackoverflow.com/questions/74426638/how-to-remove-rtc1-from-specific-target-or-file-in-cmake
10-
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
11-
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
12-
STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
13-
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
14-
endif ()
15-
endif ()
16-
177
if( CMAKE_C_COMPILER)
188
#Silence warning from unused CMAKE_C_COMPILER from toolchain
199
endif ()

cmake/common_compiler_flags.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ set( GNU_LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>" )
1010
set( GNU_GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>" )
1111

1212
set( WARNING_AS_ERROR "$<BOOL:${GODOT_WARNING_AS_ERROR}>")
13-
set( HOT_RELOAD "$<BOOL:${GODOT_USE_HOT_RELOAD}>")
13+
14+
set( NOT_RELEASE "$<NOT:$<CONFIG:Release>>")
15+
16+
set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
17+
set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${NOT_RELEASE},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )
18+
1419
set( DISABLE_EXCEPTIONS "$<BOOL:${GODOT_DISABLE_EXCEPTIONS}>")
1520

1621
target_compile_features(${PROJECT_NAME}
@@ -101,8 +106,9 @@ target_compile_definitions(${PROJECT_NAME}
101106
PUBLIC
102107
GDEXTENSION
103108

109+
$<$<BOOL:${WIN32}>:WINDOWS_ENABLED>
110+
104111
$<${IS_MSVC}:
105-
WINDOWS_ENABLED
106112
TYPED_METHOD_BIND
107113
NOMINMAX
108114
$<${DISABLE_EXCEPTIONS}:_HAS_EXCEPTIONS=0>

cmake/godotcpp.cmake

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ function( godotcpp_generate )
6666
set( GODOT_SYMBOL_VISIBILITY "default" )
6767
endif ()
6868

69-
# Default build type is Debug in the SConstruct
70-
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
71-
set(CMAKE_BUILD_TYPE Debug)
72-
endif()
73-
74-
# Hot reload is enabled by default in Debug-builds
75-
if( GODOT_USE_HOT_RELOAD STREQUAL "" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
76-
set(GODOT_USE_HOT_RELOAD ON)
77-
endif()
78-
7969
### Generate Bindings
8070
if(NOT DEFINED BITS)
8171
set(BITS 32)
@@ -145,10 +135,9 @@ function( godotcpp_generate )
145135

146136
include(${PROJECT_SOURCE_DIR}/cmake/common_compiler_flags.cmake)
147137

148-
149138
### Create the correct name (godot.os.build_type.system_bits)
150-
string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME)
151-
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
139+
set( SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>" )
140+
set( BUILD_TYPE "$<LOWER_CASE:$<CONFIG>>" )
152141

153142
if(ANDROID)
154143
# Added the android abi after system name

0 commit comments

Comments
 (0)