Skip to content

CMake: Rename all GODOT_ to GODOTCPP_ #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
run: |
mkdir cmake-build
cd cmake-build
cmake ../ -DGODOT_ENABLE_TESTING=YES
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES
cmake --build . --verbose -j $(nproc) -t godot-cpp.test.template_release --config Release

windows-msvc-cmake:
Expand All @@ -218,5 +218,5 @@ jobs:
run: |
mkdir cmake-build
cd cmake-build
cmake ../ -DGODOT_ENABLE_TESTING=YES
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES
cmake --build . --verbose -t godot-cpp.test.template_release --config Release
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ compiler_detection()
godotcpp_generate()

# Conditionally enable the godot-cpp.test.<target> integration testing targets
if( GODOT_ENABLE_TESTING )
if( GODOTCPP_ENABLE_TESTING )
add_subdirectory( test )
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/GodotCPPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function( binding_generator_generate_bindings API_FILE USE_TEMPLATE_GET_NODE, BI
COMMAND "${Python3_EXECUTABLE}" "-c" "${PYTHON_SCRIPT}"
VERBATIM
WORKING_DIRECTORY ${godot-cpp_SOURCE_DIR}
MAIN_DEPENDENCY ${GODOT_GDEXTENSION_API_FILE}
MAIN_DEPENDENCY ${GODOTCPP_GDEXTENSION_API_FILE}
DEPENDS ${godot-cpp_SOURCE_DIR}/binding_generator.py
COMMENT "Generating bindings"
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/common_compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function( common_compiler_flags )

$<${HOT_RELOAD}:HOT_RELOAD_ENABLED>

$<$<STREQUAL:${GODOT_PRECISION},double>:REAL_T_IS_DOUBLE>
$<$<STREQUAL:${GODOTCPP_PRECISION},double>:REAL_T_IS_DOUBLE>

$<${IS_MSVC}:$<${DISABLE_EXCEPTIONS}:_HAS_EXCEPTIONS=0>>

Expand Down
112 changes: 56 additions & 56 deletions cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,46 +102,46 @@ endfunction()
function( godotcpp_options )
#NOTE: platform is managed using toolchain files.
#NOTE: arch is managed by using toolchain files.
# Except for macos universal, which can be set by GODOT_MACOS_UNIVERSAL=YES
# Except for macos universal, which can be set by GODOTCPP_MACOS_UNIVERSAL=YES

# Input from user for GDExtension interface header and the API JSON file
set(GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH
set( GODOTCPP_GDEXTENSION_DIR "gdextension" CACHE PATH
"Path to a custom directory containing GDExtension interface header and API JSON file ( /path/to/gdextension_dir )" )
set(GODOT_CUSTOM_API_FILE "" CACHE FILEPATH
"Path to a custom GDExtension API JSON file (takes precedence over `GODOT_GDEXTENSION_DIR`) ( /path/to/custom_api_file )")
set( GODOTCPP_CUSTOM_API_FILE "" CACHE FILEPATH
"Path to a custom GDExtension API JSON file (takes precedence over `GODOTCPP_GDEXTENSION_DIR`) ( /path/to/custom_api_file )")

#TODO generate_bindings

option(GODOT_GENERATE_TEMPLATE_GET_NODE
option( GODOTCPP_GENERATE_TEMPLATE_GET_NODE
"Generate a template version of the Node class's get_node. (ON|OFF)" ON)

#TODO build_library

set(GODOT_PRECISION "single" CACHE STRING
set( GODOTCPP_PRECISION "single" CACHE STRING
"Set the floating-point precision level (single|double)")

set( GODOT_THREADS ON CACHE BOOL "Enable threading support" )
set( GODOTCPP_THREADS ON CACHE BOOL "Enable threading support" )

#TODO compiledb
#TODO compiledb_file

set( GODOT_BUILD_PROFILE "" CACHE PATH
set( GODOTCPP_BUILD_PROFILE "" CACHE PATH
"Path to a file containing a feature build profile" )

set(GODOT_USE_HOT_RELOAD "" CACHE BOOL
set( GODOTCPP_USE_HOT_RELOAD "" CACHE BOOL
"Enable the extra accounting required to support hot reload. (ON|OFF)")

# 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 )
option( GODOTCPP_DISABLE_EXCEPTIONS "Force disabling exception handling code (ON|OFF)" ON )

set( GODOT_SYMBOL_VISIBILITY "hidden" CACHE STRING
set( GODOTCPP_SYMBOL_VISIBILITY "hidden" CACHE STRING
"Symbols visibility on GNU platforms. Use 'auto' to apply the default value. (auto|visible|hidden)")
set_property( CACHE GODOT_SYMBOL_VISIBILITY PROPERTY STRINGS "auto;visible;hidden" )
set_property( CACHE GODOTCPP_SYMBOL_VISIBILITY PROPERTY STRINGS "auto;visible;hidden" )

#TODO optimize

option( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF )
option( GODOTCPP_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF )

#[[ debug_symbols
Debug symbols are enabled by using the Debug or RelWithDebInfo build configurations.
Expand All @@ -156,11 +156,11 @@ function( godotcpp_options )
]]

# FIXME These options are not present in SCons, and perhaps should be added there.
option( GODOT_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF )
option( GODOT_WARNING_AS_ERROR "Treat warnings as errors" OFF )
option( GODOTCPP_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF )
option( GODOTCPP_WARNING_AS_ERROR "Treat warnings as errors" OFF )

# Enable Testing
option( GODOT_ENABLE_TESTING "Enable the godot-cpp.test.<target> integration testing targets" OFF )
option( GODOTCPP_ENABLE_TESTING "Enable the godot-cpp.test.<target> integration testing targets" OFF )

#[[ Target Platform Options ]]
android_options()
Expand Down Expand Up @@ -192,64 +192,64 @@ function( godotcpp_generate )
message( " eg. cmake --build . -j 7 ...")
endif ()

#[[ GODOT_SYMBOL_VISIBLITY
#[[ GODOTCPP_SYMBOL_VISIBLITY
To match the SCons options, the allowed values are "auto", "visible", and "hidden"
This effects the compiler flag_ -fvisibility=[default|internal|hidden|protected]
The corresponding target option CXX_VISIBILITY_PRESET accepts the compiler values.

TODO: It is probably worth a pull request which changes both to use the compiler values
.. _flag:https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility
]]
if( ${GODOT_SYMBOL_VISIBILITY} STREQUAL "auto" OR ${GODOT_SYMBOL_VISIBILITY} STREQUAL "visible" )
set( GODOT_SYMBOL_VISIBILITY "default" )
if( ${GODOTCPP_SYMBOL_VISIBILITY} STREQUAL "auto" OR ${GODOTCPP_SYMBOL_VISIBILITY} STREQUAL "visible" )
set( GODOTCPP_SYMBOL_VISIBILITY "default" )
endif ()

# Setup variable to optionally mark headers as SYSTEM
set(GODOT_SYSTEM_HEADERS_ATTRIBUTE "")
if (GODOT_SYSTEM_HEADERS)
set(GODOT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM)
set( GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE "")
if( GODOTCPP_SYSTEM_HEADERS)
set( GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE SYSTEM)
endif ()

#[[ Configure Binding Variables ]]
# Generate Binding Parameters (True|False)
set( USE_TEMPLATE_GET_NODE "False" )
if( GODOT_GENERATE_TEMPLATE_GET_NODE )
if( GODOTCPP_GENERATE_TEMPLATE_GET_NODE )
set( USE_TEMPLATE_GET_NODE "True" )
endif()

# Bits (32|64)
math( EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8" ) # CMAKE_SIZEOF_VOID_P refers to target architecture.

# API json File
set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json")
if( GODOT_CUSTOM_API_FILE ) # User-defined override.
set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}")
set( GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_GDEXTENSION_DIR}/extension_api.json")
if( GODOTCPP_CUSTOM_API_FILE ) # User-defined override.
set( GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_CUSTOM_API_FILE}")
endif()

# Build Profile
if( GODOT_BUILD_PROFILE )
if( GODOTCPP_BUILD_PROFILE )
message( STATUS "Using build profile to trim api file")
message( "\tBUILD_PROFILE = '${GODOT_BUILD_PROFILE}'")
message( "\tAPI_SOURCE = '${GODOT_GDEXTENSION_API_FILE}'")
message( "\tBUILD_PROFILE = '${GODOTCPP_BUILD_PROFILE}'")
message( "\tAPI_SOURCE = '${GODOTCPP_GDEXTENSION_API_FILE}'")
build_profile_generate_trimmed_api(
"${GODOT_BUILD_PROFILE}"
"${GODOT_GDEXTENSION_API_FILE}"
"${GODOTCPP_BUILD_PROFILE}"
"${GODOTCPP_GDEXTENSION_API_FILE}"
"${CMAKE_CURRENT_BINARY_DIR}/extension_api.json" )
set( GODOT_GDEXTENSION_API_FILE "${CMAKE_CURRENT_BINARY_DIR}/extension_api.json" )
set( GODOTCPP_GDEXTENSION_API_FILE "${CMAKE_CURRENT_BINARY_DIR}/extension_api.json" )
endif()

message( STATUS "GODOT_GDEXTENSION_API_FILE = '${GODOT_GDEXTENSION_API_FILE}'")
message( STATUS "GODOTCPP_GDEXTENSION_API_FILE = '${GODOTCPP_GDEXTENSION_API_FILE}'")

# generate the file list to use
binding_generator_get_file_list( GENERATED_FILES_LIST
"${GODOT_GDEXTENSION_API_FILE}"
"${GODOTCPP_GDEXTENSION_API_FILE}"
"${CMAKE_CURRENT_BINARY_DIR}" )

binding_generator_generate_bindings(
"${GODOT_GDEXTENSION_API_FILE}"
"${GODOTCPP_GDEXTENSION_API_FILE}"
"${USE_TEMPLATE_GET_NODE}"
"${BITS}"
"${GODOT_PRECISION}"
"${GODOTCPP_PRECISION}"
"${CMAKE_CURRENT_BINARY_DIR}" )

add_custom_target( godot-cpp.generate_bindings DEPENDS ${GENERATED_FILES_LIST} )
Expand All @@ -271,36 +271,36 @@ function( godotcpp_generate )
godot_arch_name( ARCH_NAME )

# Transform options into generator expressions
set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOTCPP_USE_HOT_RELOAD},>")

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

set( THREADS_ENABLED "$<BOOL:${GODOT_THREADS}>" )
set( THREADS_ENABLED "$<BOOL:${GODOTCPP_THREADS}>" )

# GODOT_DEV_BUILD
# GODOTCPP_DEV_BUILD
set( RELEASE_TYPES "Release;MinSizeRel")
get_property( IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if( IS_MULTI_CONFIG )
message( NOTICE "=> Default build type is Debug. For other build types add --config <type> to build command")
elseif( GODOT_DEV_BUILD AND CMAKE_BUILD_TYPE IN_LIST RELEASE_TYPES )
message( WARNING "=> GODOT_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'")
elseif( GODOTCPP_DEV_BUILD AND CMAKE_BUILD_TYPE IN_LIST RELEASE_TYPES )
message( WARNING "=> GODOTCPP_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'")
endif ()
set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>")
set( IS_DEV_BUILD "$<BOOL:${GODOTCPP_DEV_BUILD}>")

### Define our godot-cpp library targets
foreach ( TARGET_ALIAS template_debug template_release editor )
set( TARGET_NAME "godot-cpp.${TARGET_ALIAS}" )

# Generator Expressions that rely on the target
set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_ALIAS},template_release>>" )
set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )
set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES},$<BOOL:${GODOTCPP_USE_HOT_RELOAD}>>" )

# Suffix
string( CONCAT GODOT_SUFFIX
string( CONCAT GODOTCPP_SUFFIX
"$<1:.${SYSTEM_NAME}>"
"$<1:.${TARGET_ALIAS}>"
"$<${IS_DEV_BUILD}:.dev>"
"$<$<STREQUAL:${GODOT_PRECISION},double>:.double>"
"$<$<STREQUAL:${GODOTCPP_PRECISION},double>:.double>"
"$<1:.${ARCH_NAME}>"
# TODO IOS_SIMULATOR
"$<$<NOT:${THREADS_ENABLED}>:.nothreads>"
Expand All @@ -318,33 +318,33 @@ function( godotcpp_generate )
${GENERATED_FILES_LIST}
)

target_include_directories( ${TARGET_NAME} ${GODOT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
target_include_directories( ${TARGET_NAME} ${GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
include
${CMAKE_CURRENT_BINARY_DIR}/gen/include
${GODOT_GDEXTENSION_DIR}
${GODOTCPP_GDEXTENSION_DIR}
)

set_target_properties( ${TARGET_NAME}
PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET ${GODOT_SYMBOL_VISIBILITY}
CXX_VISIBILITY_PRESET ${GODOTCPP_SYMBOL_VISIBILITY}

COMPILE_WARNING_AS_ERROR ${GODOT_WARNING_AS_ERROR}
COMPILE_WARNING_AS_ERROR ${GODOTCPP_WARNING_AS_ERROR}
POSITION_INDEPENDENT_CODE ON
BUILD_RPATH_USE_ORIGIN ON

PREFIX "lib"
OUTPUT_NAME "${PROJECT_NAME}${GODOT_SUFFIX}"
OUTPUT_NAME "${PROJECT_NAME}${GODOTCPP_SUFFIX}"

ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/bin>"

# Things that are handy to know for dependent targets
GODOT_PLATFORM "${SYSTEM_NAME}"
GODOT_TARGET "${TARGET_ALIAS}"
GODOT_ARCH "${ARCH_NAME}"
GODOT_PRECISION "${GODOT_PRECISION}"
GODOT_SUFFIX "${GODOT_SUFFIX}"
GODOTCPP_PLATFORM "${SYSTEM_NAME}"
GODOTCPP_TARGET "${TARGET_ALIAS}"
GODOTCPP_ARCH "${ARCH_NAME}"
GODOTCPP_PRECISION "${GODOTCPP_PRECISION}"
GODOTCPP_SUFFIX "${GODOTCPP_SUFFIX}"

# Some IDE's respect this property to logically group targets
FOLDER "godot-cpp"
Expand Down
8 changes: 4 additions & 4 deletions cmake/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ documentation.

]=======================================================================]
function( windows_options )
option( GODOT_USE_STATIC_CPP "Link MinGW/MSVC C++ runtime libraries statically" ON )
option( GODOT_DEBUG_CRT "Compile with MSVC's debug CRT (/MDd)" OFF )
option( GODOTCPP_USE_STATIC_CPP "Link MinGW/MSVC C++ runtime libraries statically" ON )
option( GODOTCPP_DEBUG_CRT "Compile with MSVC's debug CRT (/MDd)" OFF )

message( STATUS "If not already cached, setting CMAKE_MSVC_RUNTIME_LIBRARY.\n"
"\tFor more information please read godot-cpp/cmake/windows.cmake")

set( CMAKE_MSVC_RUNTIME_LIBRARY
"MultiThreaded$<IF:$<BOOL:${GODOT_DEBUG_CRT}>,DebugDLL,$<$<NOT:$<BOOL:${GODOT_USE_STATIC_CPP}>>:DLL>>"
"MultiThreaded$<IF:$<BOOL:${GODOTCPP_DEBUG_CRT}>,DebugDLL,$<$<NOT:$<BOOL:${GODOTCPP_USE_STATIC_CPP}>>:DLL>>"
CACHE STRING "Select the MSVC runtime library for use by compilers targeting the MSVC ABI.")
endfunction()


#[===========================[ Target Generation ]===========================]
function( windows_generate )
set( STATIC_CPP "$<BOOL:${GODOT_USE_STATIC_CPP}>")
set( STATIC_CPP "$<BOOL:${GODOTCPP_USE_STATIC_CPP}>")

set_target_properties( ${TARGET_NAME}
PROPERTIES
Expand Down
Loading