Skip to content

Commit 856fb1a

Browse files
committed
Document the "update_locale" and "clangformat" targets.
Update the build instructions.
1 parent 93d26a6 commit 856fb1a

File tree

1 file changed

+56
-35
lines changed

1 file changed

+56
-35
lines changed

README.md

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
### Binaries
1313

1414
Binaries are built automatically from the latest source and can be found here:
15-
**[Windows](../../releases/tag/latest-windows)**
15+
**[Windows](../../releases/tag/latest-windows)**
1616

1717
### Summary
1818

@@ -21,8 +21,8 @@ performance. The game engine itself will eventually be moved off of the renderi
2121
will provide for a much more responsive user interface, particularly when many units are on the map.
2222

2323
All builds are now being done through [CMake](https://cmake.org/) with regular testing
24-
on Windows with [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) and Ubuntu with g++. Windows
25-
development is being done with VS2022's native CMake support, which uses Ninja for the actual build. (It
24+
on Windows with [Visual Studio 2026](https://visualstudio.microsoft.com/vs/) and Ubuntu with g++. Windows
25+
development is being done with VS2026's native CMake support, which uses Ninja for the actual build. (It
2626
is unknown if the CMake Visual Studio generators produce usable `vcxproj` files.)
2727

2828
### Notable Changes
@@ -59,77 +59,91 @@ under the `[Video]` section in the INI file).
5959

6060
### Building
6161

62+
#### Prerequisites
63+
64+
- **CMake 3.22** or later (3.26+ recommended for better preset support).
65+
- **Git** with submodule support.
66+
- A C++20 compatible compiler.
67+
6268
#### Windows Build
6369

64-
Install Visual Studio 2022 including the "Desktop development with C++" workload. Go
70+
Install Visual Studio 2026 (or later) including the "Desktop development with C++" workload. Go
6571
to the "Individual Components" of the installer to make sure "C++ CMake tools for Windows" is
66-
enabled (enable clang as well to enable builds with "clang-cl").
72+
enabled (enable Clang as well to enable builds with `clang-cl`).
73+
74+
**Building from Visual Studio (recommended):**
75+
76+
Open the `dunelegacy` folder directly in Visual Studio ("File" -> "Open" -> "Folder..." or
77+
"File" -> "Clone Repository..."). Select a CMake preset/configuration from the toolbar dropdown,
78+
then select "Build" -> "Build All".
6779

68-
To build from inside Visual Studio, open the "dunelegacy" folder, select a configuration,
69-
then then select "Build" -> "Build All". It should be possible to open the
70-
repository directly by going to "File" -> "Clone Repository..." on the menu.
80+
**Building from the command line:**
7181

72-
From the command line (a bit faster, but requires more typing):
82+
Open a command prompt with access to CMake (e.g., "Developer Command Prompt for Visual Studio 2026"
83+
or "Developer PowerShell for VS 2026").
7384

74-
First open a command prompt with access to CMake (for example, "Developer Command Prompt
75-
for Visual Studio 2022"). Get a copy of the code repository, along with the submodules:
85+
Clone the repository with submodules:
7686

7787
```bat
7888
git clone --recurse-submodules -j 8 https://github.com/henricj/dunelegacy.git
7989
cd dunelegacy
8090
```
8191

82-
Configure CMake's build folder, compile the source, and run the tests (alas, there are far
83-
too few tests):
92+
Configure, build, and test using a CMake preset:
8493

8594
```bat
86-
mkdir out\build\x64-avx2-Release
87-
cd out\build\x64-avx2-Release
88-
cmake --preset=windows-x64-avx2-release -B . -S ../../..
89-
cmake --build .
90-
ctest
95+
cmake --preset=windows-x64-release
96+
cmake --build --preset=windows-x64-release
97+
ctest --preset=windows-x64-release
9198
```
9299

93-
There should now be a working dunelegacy executable in `out\build\x64-avx2-Release\src`.
100+
The executable will be in `out/build/windows-x64-release/src/dunelegacy.exe`.
94101

95-
To see the full list of CMake presets (from the top level dunelegacy directory):
102+
To see all available CMake presets:
96103

97104
```bat
98105
cmake --list-presets
99106
```
100107

108+
**Note:** If you have multiple Visual Studio versions installed, ensure you use a consistent
109+
toolchain. Mixing compiler versions (e.g., building vcpkg packages with one version and
110+
linking with another) can cause linker errors like `unresolved external symbol __std_rotate`.
111+
101112
#### Linux Build
102113

103-
The build-essential, git, ninja-build, and cmake packages are needed. Either g++ or clang
104-
can be used for the build (tested with GCC 11 and Clang 13).
114+
Install the required packages. On Debian/Ubuntu:
115+
116+
```sh
117+
sudo apt-get install build-essential git ninja-build cmake pkg-config \
118+
libsdl2-dev libsdl2-mixer-dev libsdl2-ttf-dev libsoxr-dev
119+
```
120+
121+
Clone the repository with submodules:
105122

106123
```sh
107124
git clone --recurse-submodules -j 8 https://github.com/henricj/dunelegacy.git
108125
cd dunelegacy
109126
```
110127

111-
Configure CMake's build folder, compile the source, and run the tests (alas, there are far
112-
too few tests):
128+
Configure, build, and test using a CMake preset (requires CMake 3.21+):
113129

114130
```sh
115-
mkdir -p out/build/x64-Release
116-
cd out/build/x64-Release
117-
cmake -G Ninja -DCMAKE_BUILD_TYPE:STRING=Release -DVCPKG_TARGET_TRIPLET:STRING=x64-linux ../../..
118-
cmake --build .
119-
ctest
131+
cmake --preset=linux-release
132+
cmake --build --preset=linux-release
133+
ctest --preset=linux-release
120134
```
121135

122-
With a sufficiently recent version of CMake, a preset can be used.
136+
Or configure manually:
123137

124138
```sh
125-
mkdir -p out/build/linux-release
126-
cd out/build/linux-release
127-
cmake --preset=linux-release -B . -S ../../..
139+
mkdir -p out/build/release
140+
cd out/build/release
141+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../../..
128142
cmake --build .
129143
ctest
130144
```
131145

132-
There should now be a working dunelegacy executable in `out/build/linux-release/src`.
146+
The executable will be in `out/build/release/src/dunelegacy` (or the preset's output directory).
133147

134148
### Other Platforms
135149

@@ -149,6 +163,13 @@ If there are linker errors on a BSD platform, check to see if
149163
`/usr/local/lib` is in the link library search path (e.g., check
150164
the LIBRARY_PATH environment variable).
151165

166+
### Useful CMake Targets
167+
168+
There are a few helper targets defined to facilitate development:
169+
170+
- `cmake --build . --target update_locale`: Scans the source code for translatable strings, updates `dunelegacy.pot`, and then merges those changes into the source `.po` files (e.g., `data/locale/German.de.po`).
171+
- `cmake --build . --target clangformat`: Runs `clang-format` on the codebase to enforce code style.
172+
152173
### Notes
153174

154175
Builds for macOS have not been tested, but should be similar to the Linux instructions.
@@ -297,5 +318,5 @@ To play online via Internet you have to manually enable port forwarding if you u
297318
Example: If your machine has IP 192.168.123.1 and your using the default Dune Legacy Port, than forward port 28747 from your router to 192.168.123.1:28747.
298319

299320
---
300-
IRC: #dunelegacy @ irc.freenode.net
321+
IRC: #dunelegacy @ irc.freenode.net
301322
Web: <http://sourceforge.net/projects/dunelegacy>

0 commit comments

Comments
 (0)