A minimal, no-cruft template for creating a Godot project paired with a C++ GDExtension, built using CMake.
- 🧼 Clean and minimal
- 🛠️ Single-command setup for quick start
- 🌍 Cross-platform (tested on 🪟 Windows, 🐧 Linux, and 🍎 macOS)
- 🧩 VSCode Snippets for Godot boilerplate
git clone git@github.com:yehuthi/godot_cpp_cmake_template.git PROJECT_DIRECTORY
On 🪟 Windows: run init.ps1
On 🐧 Linux and 🍎 macOS: run ./init
Tip
The init
script has no magic in it, it will simply ask you for a project name, get an initial build going, and do some clean-up.
📁 The Godot project lives in game
, and the GDExtension source files live in src
.
git clone git@github.com:yehuthi/godot_cpp_cmake_template.git PROJECT_DIRECTORY
cd PROJECT_DIRECTORY
git submodule update --init --recursive
mkdir build
cd build
cmake ..
cmake --build .
And then to clean up:
- 🗑️ Remove
src/gdexample.cpp
, its headersrc/gdexample.hpp
, and its reference insidesrc/register_types.cpp
(though you might want to use it first to test the build works). - 🔍 Find & Replace
godot_cpp_cmake_template
with your project name. - 📝 Replace this README file with your own.
Although the goal of this template is to be minimal, it includes VSCode snippets*.
The rationale is that deleting a top-level directory (.vscode
) is easy and fast, and the value of good snippets in a Godot project is great, as there is a lot of ritualistic boilerplate that has nothing to do with your project, and everything to do with data plumbing between your GDExtension and the Godot Engine.
All snippets start with gd
, so you can simply begin to type it in a C++ file to explore your options, but here's an overview:
gdclass
: creates a class declaration (place in.hpp
).gdclass_impl
: implementsgdclass
methods (place in.cpp
).gdregister
: registers your class (place inregister_types.cpp
'sinitialize_gdextension_module
).
gdprop
: creates a property declaration (place in.hpp
).gdprop_impl
: implementsgdprop
declarations (place in.cpp
).gdprop_register
: registers a property (place in_bind_methods
in.cpp
).
gdmethod
: registers a method (place in_bind_methods
in.cpp
).
* In the future it will be a toggle in the init script.
Big thanks to mieko for testing on 🍎 macOS.