Skip to content

CMake ‐ System layout setup

PixelRain edited this page Sep 3, 2024 · 2 revisions

Notes based on: https://github.com/vorlac/godot-roguelite/wiki#cmake-configuration

CMake is a build system with many utilities. It can be used to handle dependencies and build flags during a C++ project's compilation.

godot-roguelite project has heavy use of CMake for:

  • Submodule initializations: extern/godot-engine, extern/godot-cpp, and extern/vcpkg
  • Configuring vcpkg for quick use of 3rd dependencies through CMake.
  • Building the godot engine for better debugging. Better VS intellisense.
  • Build 3rd party libraries necessary for the gdextension.
  • Enforce static linking if possible.
  • Building the gdextension.

The key part of the whole CMake system is a script called CMakeLists.txt in godot-roguelite's root folder.

This script (includes various other .cmake scripts for specific functions) configures our gdextension .dll build that will be constructed when running Build (CNTRL+B) from Visual Studio Community.

Visual Studio Community:

We can force the CMake configuration to run with Project > Delete Cache and Reconfigure. It will also re-run if we edit any of the cmake related scripts.

CMake tools add-on is required for this to work, and the .vs (visual studio project) needs to also be in the same root folder as CMakeLists.txt