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
Copy file name to clipboardExpand all lines: docs/godot_docs/cmake.md
+64-36
Original file line number
Diff line number
Diff line change
@@ -10,61 +10,92 @@ This method requires a local RISC-V compiler installed on your system. If you do
10
10
11
11
CMake is completely optional. Normally, you can use Docker which compiles for you in the Godot editor.
12
12
13
-
## Setup & Installation
13
+
## Build using Zig
14
14
15
-
There is a [CMake project in the Godot Sandbox](https://github.com/libriscv/godot-sandbox/tree/main/program/cpp/cmake) repository that can be used to create ELFs with the API pre-included.
15
+
In order to build programs you will need to install: CMake, git, Zig
16
16
17
-
The easiest way to access it is to create a symlink to the cmake folder above in your project so that you can directly reference it in CMake:
17
+
[Download Zig](https://ziglang.org/download/) and add the extracted folder to PATH so that it becomes globally accessible. This means that typing `zig` from anywhere should work.
18
+
19
+
The easiest way to use CMake is to have a look at what [Godot Sandbox Programs](https://github.com/libriscv/godot-sandbox-programs) is doing. It has build scripts for Linux, macOS and Windows, and builds several projects for you.
20
+
21
+
Either fork the godot-sandbox-programs repository or copy it into a new one that you just created. Then go into the programs folder and remove everything except hello-world. Also edit `programs/CMakeLists.txt` to remove the other projects that you just deleted. You can rename hello-world, if you want.
22
+
23
+
Now you have two options:
24
+
1. If you commit changes and push them, Github Actions will build programs for you and upload them to a draft release. These are ready-to-use and will be very small.
25
+
2. You can build programs yourself using any of the root-level scripts. Linux/macOS: `./build.sh` Windows: `./build.cmd`
26
+
27
+
28
+
## Manual CMake setup
29
+
30
+
There is a [CMake project in the Godot Sandbox](https://github.com/libriscv/godot-sandbox/tree/main/program/cpp/cmake) repository that can be used to create ELFs with the API pre-included. This CMake script supports both RISC-V cross-compilers and Zig cross-compilation.
18
31
19
32
```cmake
20
33
cmake_minimum_required(VERSION 3.10)
21
34
project(example LANGUAGES CXX)
22
35
23
-
# Add the Godot Sandbox build functions
24
-
add_subdirectory(cmake)
36
+
# Fetch godot-sandbox repository (add_subdirectory is implicitly called)
You can use Zig as a cross-compiler. Have a look at the first chapter.
65
+
66
+
The [macOS github action](https://github.com/libriscv/godot-sandbox-programs/blob/main/.github/workflows/zig-macos.yml) shows you what dependencies to install and how to build on macOS.
67
+
68
+
The [Linux/macOS Zig cross-compiler script](https://github.com/libriscv/godot-sandbox-programs/blob/main/zig.sh) will also come in handy.
69
+
70
+
71
+
### Windows
72
+
73
+
You can use Zig as a cross-compiler. Have a look at the first chapter.
74
+
75
+
The [Windows github action](https://github.com/libriscv/godot-sandbox-programs/blob/main/.github/workflows/zig-windows.yml) shows you how to build on Windows.
76
+
55
77
56
78
### Ubuntu and Windows WSL2
57
79
58
80
On Linux and Windows WSL2 we can install a RISC-V compiler like so:
You can find a working [MSYS2 build example here](https://github.com/libriscv/godot-sandbox-demo/tree/master/json_diff_sample/json_diff). For `unknown-elf`-type toolchains a toolchain file is needed.
77
108
78
109
79
-
### macOS
80
-
81
-
On macOS there are RISC-V toolchains in brew. Let us know which ones worked for you.
If there is a `CMakeLists.txt` in the project root or in a `cmake` folder, when saving C++ code in the editor, `cmake --build` will be executed instead as if the CMake build folder was `.build`. Docker is ignored.
96
123
97
124
If the CMake script is in project root, the build folder is also in project root: `./.build`, and if the CMake script is in `./cmake`, the build folder is in `./cmake/.build`. The CMake invocation is verbose, so pay attention to it in the Godot console.
98
125
99
-
This feature allows you to use your own CMake project and RISC-V toolchain to build all the programs with.
126
+
This feature allows you to use your own CMake project and RISC-V toolchain to build all the programs with, all from within the Godot editor.
100
127
101
128
:::note
102
129
@@ -111,13 +138,14 @@ Docker can be disabled per project.
111
138
112
139
Go to Project -> Project Settings and enable Advanced settings on the right. Scroll to Editor -> Script and disable Docker Enabled. You should no longer see any attempts at using Docker in this project.
113
140
114
-
## Auto-completion in editor
115
141
116
-
Auto-completion should automatically work if you symlink the `cmake` folder from Godot Sandbox to your project. If not, you can always add this path to your editor workspace:
142
+
## Auto-completion in external editor
143
+
144
+
Auto-completion should automatically work when using the pre-made CMake script from Godot Sandbox. The CMake script gives your editor access to the C++ API and the run-time generated API. Combined this covers 100% of the Godot API.
0 commit comments