Skip to content

Commit

Permalink
update module to track 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
enetheru committed Mar 4, 2025
1 parent 8dcbd90 commit fb3895b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 21 deletions.
78 changes: 58 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Using the same minimum as the godot-cpp project
cmake_minimum_required(VERSION 3.17)

#[[ Things to know
The default build type in CMake is 'Debug' which optimises for and generates debugging symbols.
To compile a roughly equivalent build as a default SCons build, further action is required:
* For Ninja, or Makefile; add '-DCMAKE_BUILD_TYPE=Release' to the configure command
* For Ninja-Multi, Visual Studio, or XCode; add '--config Release' to the build command
]]

set(LIBNAME "EXTENSION-NAME" CACHE STRING "The name of the library")

set(GODOT_PROJECT_DIR "demo" CACHE STRING "The directory of a Godot project folder")

set(GODOT_TARGET_TYPE "template_debug" CACHE STRING "Which target type to build against")
set_property(CACHE GODOT_TARGET_TYPE PROPERTY STRINGS "template_debug;template_release;editor")

# Specify Options
option(USE_GIT_SUBMODULES ON "")
option(USE_FETCHCONTENT OFF "")
option(USE_GIT_SUBMODULES "Use the git submodules to fetch godot-cpp" ON)
option(USE_FETCHCONTENT "Use CMake's FetchContent to fetch godot-cpp" OFF)

# Verify Options
if(USE_GIT_SUBMODULES AND USE_FETCHCONTENT)
message(FATAL_ERROR "Cannot specify both git submodules and fetchcontent.")
message(FATAL_ERROR "USE_GIT_SUBMODULES and USE_FETCHCONTENT are mutually exclusive options")
endif()

#[[ CMake has a bunch of global properties which get copied to projects and targets at the moment of definition.
Expand All @@ -20,25 +35,24 @@ Examples are: CMAKE_OSX_ARCHITECTURES, CMAKE_MSVC_RUNTIME_LIBRARY
if(CMAKE_C_COMPILER)
endif()


# Make sure all the dependencies are satisfied
find_package(Python3 3.4 REQUIRED)

# For godot-cpp we can use the git submodule method, or we can use CMake's fetchcontent module
# In either case it is important to specify any GODOTCPP_ options prior to add_subdirectory
# or fetchcontent_makeavailable

#set(GODOTCPP_BUILD_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/build_profile.json")
# I highly recommend using a build profile to cut down on the code generation and build time of godot-cpp
# set(GODOTCPP_BUILD_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/build_profile.json")

if(USE_GIT_SUBMODULES)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/godot-cpp/src")
message(NOTICE "godot-cpp bindings source not found")
message(NOTICE "initializing/updating the godot-cpp submodule...")

# update the c++ bindings submodule to populate it with
# the necessary source for the library
# update the c++ bindings submodule to populate it with the necessary source for the library
execute_process(
COMMAND git submodule update --init extern/godot-cpp
COMMAND git submodule update --init godot-cpp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY
)
Expand All @@ -61,32 +75,56 @@ if(USE_FETCHCONTENT)
fetchcontent_makeavailable(godot-cpp)
endif()

# Now we can specify our own project.
# Add godot-cpp's module path and include the exported functions.
# This is made available for documentation generation
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/godot-cpp/cmake")
include(GodotCPPModule)

# The godot-cpp cmake project specifies three targets to link against.
# godot-cpp.template-debug
# godot-cpp.template_release
# godot-cpp.editor

# Helper variable to prevent typo's
set(GODOTCPP_TARGET godot-cpp.${GODOT_TARGET_TYPE})

# The targets have some of useful properties attached to them that can be retrieved like so.
get_target_property(GODOTCPP_SUFFIX ${GODOTCPP_TARGET} GODOTCPP_SUFFIX)
get_target_property(GODOTCPP_PLATFORM ${GODOTCPP_TARGET} GODOTCPP_PLATFORM)

# Now we can specify our own project which will inherit any global cmake properties or variables that have been defined.
project(godot-cpp-template
VERSION 1.0
DESCRIPTION "This repository serves as a quickstart template for GDExtension development with Godot 4.0+."
HOMEPAGE_URL "https://github.com/enetheru/godot-cpp-template/tree/main"
LANGUAGES CXX
)

# The PROJECT_NAME stores the name of the last called project()
add_library(${PROJECT_NAME} SHARED)
add_library(${LIBNAME} SHARED)

target_sources(${PROJECT_NAME}
target_sources(${LIBNAME}
PRIVATE
src/register_types.cpp
src/register_types.h
)

target_link_libraries(${PROJECT_NAME} PRIVATE godot-cpp.editor)
# Fetch a list of the xml files to use for documentation and add to our target
file(GLOB_RECURSE DOC_XML LIST_DIRECTORIES NO CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml")

# The godot targets have a couple of useful properties attached to them
get_target_property(GODOTCPP_SUFFIX godot-cpp.editor GODOTCPP_SUFFIX)
# conditionally add doc data to compile output
if(DOC_XML)
if(GODOT_TARGET_TYPE MATCHES "editor|template_debug")
target_doc_sources(${LIBNAME} ${DOC_XML})
endif()
endif()

target_link_libraries(${LIBNAME} PRIVATE ${GODOTCPP_TARGET})

set_target_properties(${PROJECT_NAME}
set_target_properties(${LIBNAME}
PROPERTIES
#The generator expression here prevents a subdir from being created.
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}>"
# name format project.<platform>.<target>[.dev][.double].<arch>[.custom_suffix]
OUTPUT_NAME "${PROJECT_NAME}${GODOTCPP_SUFFIX}"
# The generator expression here prevents msvc from adding a Debug or Release subdir.
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_SOURCE_DIR}/${GODOT_PROJECT_DIR}/bin/${GODOTCPP_PLATFORM}>"

PREFIX lib
OUTPUT_NAME "${LIBNAME}${GODOTCPP_SUFFIX}"
)
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 78 files
+14 −11 .github/actions/godot-cache-restore/action.yml
+6 −5 .github/actions/godot-cache-save/action.yml
+62 −0 .github/actions/setup-godot-cpp/action.yml
+28 −78 .github/workflows/ci.yml
+21 −0 .github/workflows/runner.yml
+7 −2 .github/workflows/static_checks.yml
+7 −0 .gitignore
+50 −216 CMakeLists.txt
+1 −2 README.md
+266 −215 binding_generator.py
+183 −0 build_profile.py
+169 −0 cmake/GodotCPPModule.cmake
+0 −94 cmake/GodotCompilerWarnings.cmake
+40 −0 cmake/android.cmake
+177 −0 cmake/common_compiler_flags.cmake
+40 −0 cmake/emsdkHack.cmake
+373 −0 cmake/godotcpp.cmake
+21 −0 cmake/ios.cmake
+21 −0 cmake/linux.cmake
+46 −0 cmake/macos.cmake
+42 −0 cmake/web.cmake
+103 −0 cmake/windows.cmake
+377 −0 doc/cmake.rst
+55 −0 doc_source_generator.py
+106,876 −87,456 gdextension/extension_api.json
+133 −12 gdextension/gdextension_interface.h
+6 −2 include/godot_cpp/classes/ref.hpp
+24 −23 include/godot_cpp/classes/wrapped.hpp
+24 −12 include/godot_cpp/core/class_db.hpp
+8 −4 include/godot_cpp/core/defs.hpp
+73 −0 include/godot_cpp/core/print_string.hpp
+12 −11 include/godot_cpp/core/type_info.hpp
+5 −2 include/godot_cpp/godot.hpp
+1 −1 include/godot_cpp/templates/safe_refcount.hpp
+1 −1 include/godot_cpp/variant/aabb.hpp
+2 −2 include/godot_cpp/variant/basis.hpp
+1 −1 include/godot_cpp/variant/color.hpp
+1 −1 include/godot_cpp/variant/plane.hpp
+1 −1 include/godot_cpp/variant/projection.hpp
+43 −45 include/godot_cpp/variant/quaternion.hpp
+1 −1 include/godot_cpp/variant/rect2.hpp
+1 −1 include/godot_cpp/variant/rect2i.hpp
+1 −1 include/godot_cpp/variant/transform2d.hpp
+1 −1 include/godot_cpp/variant/transform3d.hpp
+439 −0 include/godot_cpp/variant/typed_dictionary.hpp
+3 −2 include/godot_cpp/variant/variant.hpp
+509 −0 include/godot_cpp/variant/variant_internal.hpp
+1 −1 include/godot_cpp/variant/vector2.hpp
+1 −1 include/godot_cpp/variant/vector2i.hpp
+1 −1 include/godot_cpp/variant/vector3.hpp
+1 −1 include/godot_cpp/variant/vector3i.hpp
+5 −4 include/godot_cpp/variant/vector4.hpp
+1 −1 include/godot_cpp/variant/vector4i.hpp
+31 −17 misc/scripts/check_get_file_list.py
+25 −23 src/classes/wrapped.cpp
+15 −7 src/core/class_db.cpp
+39 −0 src/core/print_string.cpp
+10 −4 src/godot.cpp
+5 −2 src/variant/basis.cpp
+6 −0 src/variant/packed_arrays.cpp
+28 −40 src/variant/quaternion.cpp
+7 −6 src/variant/variant.cpp
+43 −0 src/variant/variant_internal.cpp
+81 −143 test/CMakeLists.txt
+1 −0 test/SConstruct
+5 −1 test/build_profile.json
+24 −2 test/project/main.gd
+65 −0 test/src/example.cpp
+20 −0 test/src/example.h
+1 −0 test/src/register_types.cpp
+5 −0 tools/android.py
+31 −1 tools/common_compiler_flags.py
+44 −47 tools/godotcpp.py
+5 −0 tools/ios.py
+4 −0 tools/linux.py
+5 −0 tools/macos.py
+9 −1 tools/web.py
+64 −12 tools/windows.py

0 comments on commit fb3895b

Please sign in to comment.