Post

GDExtensions, CMake, VSCode and you

Waiting for Godot (to switch to a Not Terrible build system).

GDExtensions, CMake, VSCode and you

This is, I suspect, rather dry for an inaugural blog post. I’ve been meaning to start Actually Writing about programming, procedural generation, and games in general since God knows when… the problem is, historically, whenever I’ve found time to Actually Write, no Actual Writing has materialised.

Don’t get me wrong, I love that Godot exists as an open source - but I don’t love its scripting language. It has its place, sure, Godot’s C# is as a C/C++ developer by trade, .

So who is this post for? Myself for one: God knows I forget half this stuff every time I fire up a new project. Really, though, I’ve written it at anyone familiar with Godot who wants to get better with C++, and anyone familiar with C++ who wants to get better with Godot.

The theme is more or less, some things I wish I knew the first time around.

Prerequisites

First, I want to give an entry-level explainer on

I also want to make a quick note about compilers here. If you’re following this tutorial on Windows you’ll be using MSVC by default; I personally prefer clang for its suite of compiler optimisations (nice foreshadowing for a future blog, that). Just please, Christ, whatever you do, don’t use gcc.

File Structure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my-project
> build
  > windows-debug
  > windows-release
> exe
> extensions
  > my-gdextension-cpp
      // Source 
      CMakeLists.txt
	  register_types.cpp
    CMakeLists.txt
> game // Create godot project within this dir
  > bin
      my-extension.gdextension
    .gitignore
  .gitignore
  CMakeLists.txt

We can fill in the .gitignore file already. The file only needs two directories added:

1
2
build
exe

This means…

It’ll also be useful to append

1
2
3
4
5
# GDExtension ignores
bin/*.dll
bin/*.exp
bin/*.lib
bin/*.pdb

godot-cpp

There’s one important directory we’re currently missing. Go into extensions. Run git submodule add -b 4.x https://github.com/godotengine/godot-cpp, then init.

1
2
3
git submodule add -b 4.2 https://github.com/godotengine/godot-cpp
cd godot-cpp
git submodule update --init

Then, commit the submodule (and accompanying .gitmodules file).

1
scons platform=[windows,macos,linux,android,ios] target=[template_debug,template_release,editor]

This is, mercifully, the first and only time we’ll need scons is as we generate these

CMake

extensions: linking

gdextension: add nuance, etc.

VSCode

This post is licensed under CC BY 4.0 by the author.