Skip to content

Commit 9f0f75e

Browse files
authored
Merge pull request ddnet#8365 from heinrich5991/pr_ddnet_readme_cmake_b
README.md: Don't require the user to `mkdir`/`cd`
2 parents f2bd19c + cdaa9c8 commit 9f0f75e

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

README.md

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,31 @@ Building on Linux and macOS
6969

7070
To compile DDNet yourself, execute the following commands in the source root:
7171

72-
mkdir build
73-
cd build
74-
cmake ..
75-
make -j$(nproc)
76-
77-
Pass the number of threads for compilation to `make -j`. `$(nproc)` in this case returns the number of processing units.
72+
cmake -Bbuild
73+
cmake --build build
7874

7975
DDNet requires additional libraries, some of which are bundled for the most common platforms (Windows, Mac, Linux, all x86 and x86\_64) for convenience and the official builds. The bundled libraries for official builds are now in the ddnet-libs submodule. Note that when you build and develop locally, you should ideally use your system's package manager to install the dependencies, instead of relying on ddnet-libs submodule, which does not contain all dependencies anyway (e.g. openssl, vulkan). See the previous section for how to get the dependencies. Alternatively see the following build arguments for how to disable some features and their dependencies (`-DVULKAN=OFF` won't require Vulkan for example).
8076

8177
The following is a non-exhaustive list of build arguments that can be passed to the `cmake` command-line tool in order to enable or disable options in build time:
8278

8379
* **-DCMAKE_BUILD_TYPE=[Release|Debug|RelWithDebInfo|MinSizeRel]** <br>
84-
An optional CMake variable for setting the build type. If not set, defaults to "Release" if `-DDEV=ON` is **not** used, and "Debug" if `-DDEV=ON` is used. See `CMAKE_BUILD_TYPE` in CMake Documentation for more information.
80+
An optional CMake variable for setting the build type. If not set, defaults to "Release" if `-DDEV=ON` is **not** used, and "Debug" if `-DDEV=ON` is used. See `CMAKE_BUILD_TYPE` in CMake Documentation for more information.
8581

8682
* **-DPREFER_BUNDLED_LIBS=[ON|OFF]** <br>
87-
Whether to prefer bundled libraries over system libraries. Setting to ON will make DDNet use third party libraries available in the `ddnet-libs` folder, which is the git-submodule target of the [ddnet-libs](https://github.com/ddnet/ddnet-libs) repository mentioned above -- Useful if you do not have those libraries installed and want to avoid building them. If set to OFF, will only use bundled libraries when system libraries are not found. Default value is OFF.
83+
Whether to prefer bundled libraries over system libraries. Setting to ON will make DDNet use third party libraries available in the `ddnet-libs` folder, which is the git-submodule target of the [ddnet-libs](https://github.com/ddnet/ddnet-libs) repository mentioned above -- Useful if you do not have those libraries installed and want to avoid building them. If set to OFF, will only use bundled libraries when system libraries are not found. Default value is OFF.
8884

8985
* **-DWEBSOCKETS=[ON|OFF]** <br>
90-
Whether to enable WebSocket support for server. Setting to ON requires the `libwebsockets-dev` library installed. Default value is OFF.
86+
Whether to enable WebSocket support for server. Setting to ON requires the `libwebsockets-dev` library installed. Default value is OFF.
9187

9288
* **-DMYSQL=[ON|OFF]** <br>
93-
Whether to enable MySQL/MariaDB support for server. Requires at least MySQL 8.0 or MariaDB 10.2. Setting to ON requires the `libmariadbclient-dev` library installed, which are also provided as bundled libraries for the common platforms. Default value is OFF.
89+
Whether to enable MySQL/MariaDB support for server. Requires at least MySQL 8.0 or MariaDB 10.2. Setting to ON requires the `libmariadbclient-dev` library installed, which are also provided as bundled libraries for the common platforms. Default value is OFF.
9490

95-
Note that the bundled MySQL libraries might not work properly on your system. If you run into connection problems with the MySQL server, for example that it connects as root while you chose another user, make sure to install your system libraries for the MySQL client. Make sure that the CMake configuration summary says that it found MySQL libs that were not bundled (no "using bundled libs").
91+
Note that the bundled MySQL libraries might not work properly on your system. If you run into connection problems with the MySQL server, for example that it connects as root while you chose another user, make sure to install your system libraries for the MySQL client. Make sure that the CMake configuration summary says that it found MySQL libs that were not bundled (no "using bundled libs").
9692

9793
* **-DTEST_MYSQL=[ON|OFF]** <br>
98-
Whether to test MySQL/MariaDB support in GTest based tests. Default value is OFF.
94+
Whether to test MySQL/MariaDB support in GTest based tests. Default value is OFF.
9995

100-
Note that this requires a running MySQL/MariaDB database on localhost with this setup:
96+
Note that this requires a running MySQL/MariaDB database on localhost with this setup:
10197

10298
```
10399
CREATE DATABASE ddnet;
@@ -107,47 +103,47 @@ FLUSH PRIVILEGES;
107103
```
108104

109105
* **-DAUTOUPDATE=[ON|OFF]** <br>
110-
Whether to enable the autoupdater. Packagers may want to disable this for their packages. Default value is ON for Windows and Linux.
106+
Whether to enable the autoupdater. Packagers may want to disable this for their packages. Default value is ON for Windows and Linux.
111107

112108
* **-DCLIENT=[ON|OFF]** <br>
113-
Whether to enable client compilation. If set to OFF, DDNet will not depend on Curl, Freetype, Ogg, Opus, Opusfile, and SDL2. Default value is ON.
109+
Whether to enable client compilation. If set to OFF, DDNet will not depend on Curl, Freetype, Ogg, Opus, Opusfile, and SDL2. Default value is ON.
114110

115111
* **-DVIDEORECORDER=[ON|OFF]** <br>
116-
Whether to add video recording support using FFmpeg to the client. Default value is ON.
112+
Whether to add video recording support using FFmpeg to the client. Default value is ON.
117113

118114
* **-DDOWNLOAD_GTEST=[ON|OFF]** <br>
119-
Whether to download and compile GTest. Useful if GTest is not installed and, for Linux users, there is no suitable package providing it. Default value is OFF.
115+
Whether to download and compile GTest. Useful if GTest is not installed and, for Linux users, there is no suitable package providing it. Default value is OFF.
120116

121117
* **-DDEV=[ON|OFF]** <br>
122-
Whether to optimize for development, speeding up the compilation process a little. If enabled, don't generate stuff necessary for packaging. Setting to ON will set CMAKE\_BUILD\_TYPE to Debug by default. Default value is OFF.
118+
Whether to optimize for development, speeding up the compilation process a little. If enabled, don't generate stuff necessary for packaging. Setting to ON will set CMAKE\_BUILD\_TYPE to Debug by default. Default value is OFF.
123119

124120
* **-DUPNP=[ON|OFF]** <br>
125-
Whether to enable UPnP support for the server.
126-
You need to install `libminiupnpc-dev` on Debian, `miniupnpc` on Arch Linux.
127-
Default value is OFF.
121+
Whether to enable UPnP support for the server.
122+
You need to install `libminiupnpc-dev` on Debian, `miniupnpc` on Arch Linux.
123+
Default value is OFF.
128124

129125
* **-DVULKAN=[ON|OFF]** <br>
130-
Whether to enable the vulkan backend.
131-
On Windows you need to install the Vulkan SDK and set the `VULKAN_SDK` environment flag accordingly.
132-
Default value is ON for Windows x86\_64 and Linux, and OFF for Windows x86 and macOS.
126+
Whether to enable the vulkan backend.
127+
On Windows you need to install the Vulkan SDK and set the `VULKAN_SDK` environment flag accordingly.
128+
Default value is ON for Windows x86\_64 and Linux, and OFF for Windows x86 and macOS.
133129

134130
* **-GNinja** <br>
135-
Use the Ninja build system instead of Make. This automatically parallelizes the build and is generally faster. Compile with `ninja` instead of `make`. Install Ninja with `sudo apt install ninja-build` on Debian, `sudo pacman -S --needed ninja` on Arch Linux.
131+
Use the Ninja build system instead of Make. This automatically parallelizes the build and is generally faster. Compile with `ninja` instead of `make`. Install Ninja with `sudo apt install ninja-build` on Debian, `sudo pacman -S --needed ninja` on Arch Linux.
136132

137133
* **-DCMAKE_CXX_LINK_FLAGS=[FLAGS]** <br>
138-
Custom flags to set for compiler when linking.
134+
Custom flags to set for compiler when linking.
139135

140136
* **-DEXCEPTION_HANDLING=[ON|OFF]** <br>
141-
Enable exception handling (only works with Windows as of now, uses DrMingw there). Default value is OFF.
137+
Enable exception handling (only works with Windows as of now, uses DrMingw there). Default value is OFF.
142138

143139
* **-DIPO=[ON|OFF]** <br>
144-
Enable interprocedural optimizations, also known as Link Time Optimization (LTO). Default value is OFF.
140+
Enable interprocedural optimizations, also known as Link Time Optimization (LTO). Default value is OFF.
145141

146142
* **-DFUSE_LD=[OFF|LINKER]** <br>
147-
Linker to use. Default value is OFF to try mold, lld, gold.
143+
Linker to use. Default value is OFF to try mold, lld, gold.
148144

149145
* **-DSECURITY_COMPILER_FLAGS=[ON|OFF]** <br>
150-
Whether to set security-relevant compiler flags like `-D_FORTIFY_SOURCE=2` and `-fstack-protector-all`. Default Value is ON.
146+
Whether to set security-relevant compiler flags like `-D_FORTIFY_SOURCE=2` and `-fstack-protector-all`. Default Value is ON.
151147

152148
Running tests (Debian/Ubuntu)
153149
-----------------------------
@@ -159,7 +155,7 @@ This library isn't compiled, so you have to do it:
159155
sudo apt install libgtest-dev
160156
cd /usr/src/gtest
161157
sudo cmake CMakeLists.txt
162-
sudo make -j$(nproc)
158+
sudo make
163159

164160
# copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
165161
sudo cp lib/*.a /usr/lib
@@ -312,11 +308,9 @@ sv_use_sql 1
312308
add_sqlserver r teeworlds record teeworlds "PW2" "localhost" "3306"
313309
add_sqlserver w teeworlds record teeworlds "PW2" "localhost" "3306"
314310

315-
$ mkdir build
316-
$ cd build
317-
$ cmake -DMYSQL=ON ..
318-
$ make -j$(nproc)
319-
$ ./DDNet-Server -f mine.cfg
311+
$ cmake -Bbuild -DMYSQL=ON
312+
$ cmake --build build --target DDNet-Server
313+
$ build/DDNet-Server -f mine.cfg
320314
```
321315

322316
<a href="https://repology.org/metapackage/ddnet/versions">

0 commit comments

Comments
 (0)