You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is currently possible to build C++ from within the editor in two major ways:
Docker automatically picks up all .cpp files in a folder and compiles an ELF file on all platforms
When CMake is present, the Godot editor calls cmake --build instead, turning it into a CMake build
This means that it is possible to build any kind of project within the Godot editor at present.
Most of the friction currently lies in the CMake configuration step. Many are not familiar with how to follow basic instructions download CMake, git, Ninja and Zig and initialize a CMake project with Zig as a cross compiler. I'm joking. Nobody should need to know all of that. It would be very beneficial for everyone (me included) if we could automate this process on the 3 desktop platforms that we now support with Zig. There is one extra step on Windows where we are forced to use Ninja as the build executor. We could in theory just use Ninja on all platforms.
So, perhaps what we can do is to make it possible to download these dependencies and initialize a CMake project in the root of the current Godot project. Ideas and implementation efforts are welcome.
Complete example for macOS:
Install dependencies. Different on all platforms.
brew install git cmake
Download zig nightly somewhere and add to PATH. It will use 350MB after extraction. Same on all platforms, just different URL.
wget https://ziglang.org/builds/zig-macos-aarch64-0.14.0-dev.2441+3670910f2.tar.xz
tar -xf zig-macos-aarch64-0.14.0-dev.2441+3670910f2.tar.xz
export PATH=$PWD/zig-macos-aarch64-0.14.0-dev.2441+3670910f2:$PATH
Create cmake folder in project root. Same on all platforms.
mkdir -p cmake
cd cmake
Create template CMakeLists.txt in cmake folder. Same on all platforms.
Initialize CMake with the toolchain file as argument. The toolchain file is only used to initialize CMake. Same on all platforms.
mkdir -p .build
cd .build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake
That's it. Now that CMake is initialized, it doesn't have to be initialized again. We can now build using CMake from the editor. As you can see, almost all steps are the same on all platforms. On Windows the CMake invocation needs to add -G Ninja.
The example CMake script looks for example.cpp and builds example.elf. It has full C++ API and Godot run-time API support.
The text was updated successfully, but these errors were encountered:
It is currently possible to build C++ from within the editor in two major ways:
cmake --build
instead, turning it into a CMake buildThis means that it is possible to build any kind of project within the Godot editor at present.
Most of the friction currently lies in the CMake configuration step. Many are not familiar with how to
follow basic instructionsdownload CMake, git, Ninja and Zig and initialize a CMake project with Zig as a cross compiler. I'm joking. Nobody should need to know all of that. It would be very beneficial for everyone (me included) if we could automate this process on the 3 desktop platforms that we now support with Zig. There is one extra step on Windows where we are forced to use Ninja as the build executor. We could in theory just use Ninja on all platforms.So, perhaps what we can do is to make it possible to download these dependencies and initialize a CMake project in the root of the current Godot project. Ideas and implementation efforts are welcome.
Complete example for macOS:
Copy toolchain.cmake from Godot Sandbox Programs repo.
mkdir -p .build cd .build cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake
That's it. Now that CMake is initialized, it doesn't have to be initialized again. We can now build using CMake from the editor. As you can see, almost all steps are the same on all platforms. On Windows the CMake invocation needs to add
-G Ninja
.The example CMake script looks for
example.cpp
and buildsexample.elf
. It has full C++ API and Godot run-time API support.The text was updated successfully, but these errors were encountered: