Skip to content

Commit

Permalink
Now that we are specifying the config at build time, the hack to re-w…
Browse files Browse the repository at this point in the history
…rite 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
  • Loading branch information
enetheru committed Sep 23, 2024
1 parent 123cee0 commit 719f94b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ project(godot-cpp LANGUAGES CXX)
# Get Python
find_package(Python3 3.4 REQUIRED) # pathlib should be present

# 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 ()

if( CMAKE_C_COMPILER)
#Silence warning from unused CMAKE_C_COMPILER from toolchain
endif ()
Expand Down
10 changes: 8 additions & 2 deletions cmake/common_compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ set( GNU_LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>" )
set( GNU_GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>" )

set( WARNING_AS_ERROR "$<BOOL:${GODOT_WARNING_AS_ERROR}>")
set( HOT_RELOAD "$<BOOL:${GODOT_USE_HOT_RELOAD}>")

set( NOT_RELEASE "$<NOT:$<CONFIG:Release>>")

set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${NOT_RELEASE},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )

set( DISABLE_EXCEPTIONS "$<BOOL:${GODOT_DISABLE_EXCEPTIONS}>")

target_compile_features(${PROJECT_NAME}
Expand Down Expand Up @@ -101,8 +106,9 @@ target_compile_definitions(${PROJECT_NAME}
PUBLIC
GDEXTENSION

$<$<BOOL:${WIN32}>:WINDOWS_ENABLED>

$<${IS_MSVC}:
WINDOWS_ENABLED
TYPED_METHOD_BIND
NOMINMAX
$<${DISABLE_EXCEPTIONS}:_HAS_EXCEPTIONS=0>
Expand Down
15 changes: 2 additions & 13 deletions cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ function( godotcpp_generate )
set( GODOT_SYMBOL_VISIBILITY "default" )
endif ()

# Default build type is Debug in the SConstruct
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Debug)
endif()

# Hot reload is enabled by default in Debug-builds
if( GODOT_USE_HOT_RELOAD STREQUAL "" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
set(GODOT_USE_HOT_RELOAD ON)
endif()

### Generate Bindings
if(NOT DEFINED BITS)
set(BITS 32)
Expand Down Expand Up @@ -145,10 +135,9 @@ function( godotcpp_generate )

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


### Create the correct name (godot.os.build_type.system_bits)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME)
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
set( SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>" )
set( BUILD_TYPE "$<LOWER_CASE:$<CONFIG>>" )

if(ANDROID)
# Added the android abi after system name
Expand Down

0 comments on commit 719f94b

Please sign in to comment.