Learn how to configure GDExtension projects with CMake for Godot!
In this tutorial, we add a CMake option to enable/disable a debug FPS tool — and show how to conditionally compile C++ code for Godot extensions. This lets you build lighter release builds and include debug-only tools when needed.
✅ What you’ll learn:
How to add CMake options (WITH_DEBUG_TOOL)
How to conditionally compile C++ files in GDExtension
Using configure_file() to generate a config header
A good practices for organizing Godot C++ projects
Have questions? Drop a comment, I answer them!
Support the series
You can use YouTube Thanks or support me on Patreon
Discord:
https://discord.gg/ravFervXVW
Twitter:
https://x.com/mohsenph69
Chapters:
00:00 - intro
01:10 - cmake cache variable
02:20 - organizing project
03:56 - debug tool class
04:57 - debug tool compile source
05:43 - debug tool macro
08:24 - testing
05:55 - configure_file