Skip to content

Commit 4a16331

Browse files
committed
update module to track 4.4
1 parent 8dcbd90 commit 4a16331

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

CMakeLists.txt

+33-21
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# Using the same minimum as the godot-cpp project
22
cmake_minimum_required(VERSION 3.17)
33

4+
#[[ Things to know
5+
* The default build type in CMake is Debug,
6+
]]
7+
8+
9+
set(LIBNAME "EXTENSION-NAME" CACHE STRING "The name of the library")
10+
set(GODOT_PROJECT_DIR "demo" CACHE STRING "The directory of the Godot project folder")
11+
412
# Specify Options
5-
option(USE_GIT_SUBMODULES ON "")
6-
option(USE_FETCHCONTENT OFF "")
13+
option(USE_GIT_SUBMODULES "Use the git submodules to fetch godot-cpp" ON)
14+
option(USE_FETCHCONTENT "Use CMake's FetchContent to fetch godot-cpp" OFF)
715

816
# Verify Options
917
if(USE_GIT_SUBMODULES AND USE_FETCHCONTENT)
10-
message(FATAL_ERROR "Cannot specify both git submodules and fetchcontent.")
18+
message(FATAL_ERROR "USE_GIT_SUBMODULES and USE_FETCHCONTENT are mutually exclusive options")
1119
endif()
1220

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

23-
2431
# Make sure all the dependencies are satisfied
2532
find_package(Python3 3.4 REQUIRED)
2633

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

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

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

38-
# update the c++ bindings submodule to populate it with
39-
# the necessary source for the library
46+
# update the c++ bindings submodule to populate it with the necessary source for the library
4047
execute_process(
41-
COMMAND git submodule update --init extern/godot-cpp
48+
COMMAND git submodule update --init godot-cpp
4249
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
4350
COMMAND_ERROR_IS_FATAL ANY
4451
)
@@ -61,32 +68,37 @@ if(USE_FETCHCONTENT)
6168
fetchcontent_makeavailable(godot-cpp)
6269
endif()
6370

64-
# Now we can specify our own project.
71+
# The godot-cpp cmake project specifies three targets to link against.
72+
# godot-cpp.template-debug
73+
# godot-cpp.template_release
74+
# godot-cpp.editor
75+
76+
# The targets have some of useful properties attached to them that can be retrieved like so.
77+
get_target_property(GODOTCPP_SUFFIX godot-cpp.editor GODOTCPP_SUFFIX)
78+
get_target_property(GODOTCPP_PLATFORM godot-cpp.editor GODOTCPP_PLATFORM)
79+
80+
# Now we can specify our own project which will inherit any global cmake properties or variables that have been defined.
6581
project(godot-cpp-template
6682
VERSION 1.0
6783
DESCRIPTION "This repository serves as a quickstart template for GDExtension development with Godot 4.0+."
6884
HOMEPAGE_URL "https://github.com/enetheru/godot-cpp-template/tree/main"
6985
LANGUAGES CXX
7086
)
7187

72-
# The PROJECT_NAME stores the name of the last called project()
73-
add_library(${PROJECT_NAME} SHARED)
88+
add_library(${LIBNAME} SHARED)
7489

75-
target_sources(${PROJECT_NAME}
90+
target_sources(${LIBNAME}
7691
PRIVATE
7792
src/register_types.cpp
7893
src/register_types.h
7994
)
8095

81-
target_link_libraries(${PROJECT_NAME} PRIVATE godot-cpp.editor)
96+
target_link_libraries(${LIBNAME} PRIVATE godot-cpp.editor)
8297

83-
# The godot targets have a couple of useful properties attached to them
84-
get_target_property(GODOTCPP_SUFFIX godot-cpp.editor GODOTCPP_SUFFIX)
85-
86-
set_target_properties(${PROJECT_NAME}
98+
set_target_properties(${LIBNAME}
8799
PROPERTIES
88-
#The generator expression here prevents a subdir from being created.
89-
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}>"
90-
# name format project.<platform>.<target>[.dev][.double].<arch>[.custom_suffix]
91-
OUTPUT_NAME "${PROJECT_NAME}${GODOTCPP_SUFFIX}"
100+
# The generator expression here prevents msvc from adding a Debug or Release subdir.
101+
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_SOURCE_DIR}/${GODOT_PROJECT_DIR}/bin/${GODOTCPP_PLATFORM}>"
102+
103+
OUTPUT_NAME "${LIBNAME}${GODOTCPP_SUFFIX}"
92104
)

godot-cpp

Submodule godot-cpp updated 78 files

0 commit comments

Comments
 (0)