1
0
This commit is contained in:
Your Name 2023-04-14 23:38:34 +08:00
commit ff5da79d57
1392 changed files with 378574 additions and 0 deletions

2
.cargo/config.toml Executable file
View File

@ -0,0 +1,2 @@
[target.'cfg(target_env = "msvc")']
rustflags = ["-C", "target-feature=+crt-static"]

53
.clang-format Executable file
View File

@ -0,0 +1,53 @@
---
Language: Cpp
AccessModifierOffset: -8
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignTrailingComments: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterExternBlock: false
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyNamespace: true
SplitEmptyRecord: true
#ColumnLimit: 100
ColumnLimit: 0
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
IncludeCategories:
- Regex: '^"'
Priority: 1
- Regex: '^<(engine|game|mastersrv|versionsrv>'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '$'
IndentWidth: 8
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right
ReflowComments: true
SpaceBeforeParens: Never
SpaceAfterTemplateKeyword: false
TabWidth: 8
UseTab: ForContinuationAndIndentation
...

90
.clang-tidy Executable file
View File

@ -0,0 +1,90 @@
# Why we disabled individual checks:
#
# clang-analyzer-optin.cplusplus.UninitializedObject
# TODO: Occurs commonly in graphics_threaded.h
# clang-analyzer-optin.cplusplus.VirtualCall
# Occurs very commonly all over
# clang-analyzer-optin.performance.Padding
# Too annoying to always align for perfect padding
# clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
# TODO: Requires C11 to fix
# modernize-use-override,
# TODO: modernize-use-override.IgnoreDestructors not supported on ubuntu-latest yet for CI
# misc-unused-parameters
# TODO: Many changes
# readability-static-accessed-through-instance,
# Crashes: https://github.com/llvm/llvm-project/issues/53359
Checks: >
-*,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-incorrect-roundings,
-bugprone-integer-division,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-parent-virtual-call,
-bugprone-reserved-identifier,
-bugprone-suspicious-include,
-bugprone-unhandled-self-assignment,
clang-analyzer-*,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
-clang-analyzer-optin.performance.Padding,
-clang-analyzer-osx.cocoa.RetainCount,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-security.insecureAPI.rand,
cppcoreguidelines-avoid-goto,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-slicing,
cppcoreguidelines-virtual-class-destructor,
misc-*,
-misc-const-correctness,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-static-assert,
-misc-unused-parameters,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-unique,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
readability-*,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-identifier-naming,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-named-parameter,
-readability-non-const-parameter,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
performance-*,
-performance-no-int-to-ptr,
portability-*,

2
.gitattributes vendored Executable file
View File

@ -0,0 +1,2 @@
other/*/include/* linguist-vendored
src/engine/external/* linguist-vendored

146
.gitignore vendored Normal file
View File

@ -0,0 +1,146 @@
# Ignore data-folders outside the root, these are copied around to build
# directories.
data/
!/data/
docs/
bundle/
!/other/bundle/
.DS_Store
.ninja_deps
.ninja_log
CACHEDIR.TAG
CMakeCache.txt
CMakeFiles
CMakeSettings*
CPackConfig.cmake
CPackSourceConfig.cmake
CTestTestfile.cmake
Debug
Makefile
Release
SAN.*
_CPack_Packages/
build.ninja
checksummed_*
cmake_install.cmake
debug
gmock.pc
gmock_main.pc
googletest-build/
googletest-download/
googletest-src/
gtest.pc
gtest_main.pc
install_manifest*.txt
ninja_package
pack_*/
release
rules.ninja
testrunner\[1\]_include.cmake
b
/SDL2.framework
# Ignore all the generated executables without extensions (for non-Windows
# systems).
DDNet
!DDNet/
DDNet-Server
DDNet-Server-Launcher
libsteam_api.a
config_retrieve
config_store
crapnet
dilate
dummy_map
fake_server
map_convert_07
map_create_pixelart
map_diff
map_extract
map_find_env
map_optimize
map_replace_area
map_replace_image
map_resave
map_version
mastersrv
packetgen
stun
testrunner
twping
unicode_confusables
uuid
versionsrv
# But we still should allow to download mastersrv/twping sources
!src/mastersrv
!src/twping
generated
target
/build*
/integration_test/*
# IDE project files
.cache
.cproject
.cmake
.gdb_history
.idea
.project
.settings
.vs
.vscode
compile_commands.json
cmake-build-*/*
cscope.files
cscope.out
out
tags
# don't ignore this, it's used for the vscode workspace that ddnet provides
!ddnet-cmake-tools-kits.json
# bam ignores
/.bam
/config.lua
/objs
*.a
*.cmd
*.csv
*.dll
*.dmg
*.dtb
*.dylib
*.exe
*.fifo
*.filters
*.json
*.lnk
*.log
*.opensdf
*.patch
*.pdb
*.prefs
*.pyc
*.res
*.sdf
*.sln
*.so
*.spv
*.sqlite
*.sqlite-shm
*.sqlite-wal
*.suo
*.swp
*.tar.gz
*.tar.xz
*.teehistorian
*.tmp
*.user
*.vcxproj
*.zip

2
.gitlab-ci.yml Executable file
View File

@ -0,0 +1,2 @@
include: '.gitlab/*.yml'

4
.gitmodules vendored Executable file
View File

@ -0,0 +1,4 @@
[submodule "ddnet-libs"]
path = ddnet-libs
url = https://github.com/ddnet/ddnet-libs
shallow = true

25
.pylintrc Executable file
View File

@ -0,0 +1,25 @@
[MESSAGES CONTROL]
indent-string=' '
disable=
C0103, # invalid-name
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
C0301, # line-too-long
C0326, # bad-whitespace
C0330, # bad-continuation
E0402, # relative-beyond-top-level
R0201, # no-self-use
R0801, # duplicate-code
R0902, # too-many-instance-attributes
R0903, # too-few-public-methods
R0911, # too-many-return-statements
R0912, # too-many-branches
R0913, # too-many-arguments
R0914, # too-many-locals
R0915, # too-many-statements
W0511, # fixme
W0603, # global-statement
R0022, # useless-option-value

3363
CMakeLists.txt Normal file

File diff suppressed because it is too large Load Diff

3366
CMakeLists.txt.bak Normal file

File diff suppressed because it is too large Load Diff

114
Cargo.lock generated Executable file
View File

@ -0,0 +1,114 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cxx"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5469a6f42296f4fd40789b397383718f9a0bd75d2f9b7cedbb249996811fba27"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fef2b4ffdc935c973bc7817d541fc936fdc8a85194cfdd9c761aca8387edd48"
[[package]]
name = "cxxbridge-macro"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d3a240a54f5526967ffae81fdcda1fc80564964220d90816960b2eae2eab7f4"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "ddnet-base"
version = "0.0.1"
dependencies = [
"cxx",
"ddnet-test",
]
[[package]]
name = "ddnet-engine"
version = "0.0.1"
dependencies = [
"cxx",
"ddnet-base",
"ddnet-engine-shared",
"ddnet-test",
]
[[package]]
name = "ddnet-engine-shared"
version = "0.0.1"
dependencies = [
"cxx",
"ddnet-base",
"ddnet-engine",
"ddnet-test",
]
[[package]]
name = "ddnet-test"
version = "0.0.1"
[[package]]
name = "link-cplusplus"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cae2cd7ba2f3f63938b9c724475dfb7b9861b545a90324476324ed21dbc8c8"
dependencies = [
"cc",
]
[[package]]
name = "proc-macro2"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"

15
Cargo.toml Executable file
View File

@ -0,0 +1,15 @@
[workspace]
members = [
"src/base",
"src/engine",
"src/engine/shared",
"src/rust-bridge/test",
]
[profile.dev]
panic = "abort"
[profile.release]
lto = "thin"
panic = "abort"

52
Dockerfile Executable file
View File

@ -0,0 +1,52 @@
FROM debian:11
RUN apt-get update && apt-get install -y mingw-w64 \
wget \
git \
ca-certificates \
build-essential \
python3 \
libcurl4-openssl-dev \
libfreetype6-dev \
libglew-dev \
libogg-dev \
libopus-dev \
libpng-dev \
libwavpack-dev \
libopusfile-dev \
libsdl2-dev \
cmake
RUN git clone --depth=1 https://github.com/tpoechtrager/osxcross.git /osxcross
RUN /osxcross/tools/get_dependencies.sh
ARG OSX_SDK_FILE
COPY $OSX_SDK_FILE /osxcross/tarballs/
RUN ls -la /osxcross/tarballs
RUN UNATTENDED=1 /osxcross/build.sh
RUN printf '#!/bin/bash\n \
set -x\n \
export PATH=$PATH:/osxcross/target/bin\n \
o32-clang++ -v\n \
mkdir /build/linux\n \
cd /build/linux\n \
pwd\n \
cmake /ddnet && make\n \
mkdir /build/win64\n \
cd /build/win64\n \
pwd\n \
cmake -DCMAKE_TOOLCHAIN_FILE=/ddnet/cmake/toolchains/mingw64.toolchain /ddnet && make\n \
mkdir /build/win32\n \
cd /build/win32\n \
pwd\n \
cmake -DCMAKE_TOOLCHAIN_FILE=/ddnet/cmake/toolchains/mingw32.toolchain /ddnet && make\n \
mkdir /build/macos\n \
cd /build/macos\n \
pwd\n \
cmake -DCMAKE_TOOLCHAIN_FILE=/ddnet/cmake/toolchains/darwin.toolchain -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX10.11.sdk/ /ddnet && make' \
>> build-all.sh
RUN chmod +x build-all.sh
RUN mkdir /build
ADD . /ddnet

2661
Doxyfile Executable file

File diff suppressed because it is too large Load Diff

363
README.md Executable file
View File

@ -0,0 +1,363 @@
[![DDraceNetwork](https://ddnet.org/ddnet-small.png)](https://ddnet.org) [![](https://github.com/ddnet/ddnet/workflows/Build/badge.svg)](https://github.com/ddnet/ddnet/actions?query=workflow%3ABuild+event%3Apush+branch%3Amaster) [![](https://codecov.io/gh/ddnet/ddnet/branch/master/graph/badge.svg)](https://codecov.io/gh/ddnet/ddnet/branch/master)
Our own flavor of DDRace, a Teeworlds mod. See the [website](https://ddnet.org) for more information.
Development discussions happen on #ddnet on Quakenet ([Webchat](http://webchat.quakenet.org/?channels=ddnet&uio=d4)) or on [Discord in the developer channel](https://discord.gg/xsEd9xu).
You can get binary releases on the [DDNet website](https://ddnet.org/downloads/), find it on [Steam](https://store.steampowered.com/app/412220/DDraceNetwork/) or [install from repository](#installation-from-repository).
- [Code Browser](https://ddnet.org/codebrowser/DDNet/)
- [Source Code Documentation](https://codedoc.ddnet.org/) (very incomplete, only a few items are documented)
If you want to learn about the source code, you can check the [Development](https://wiki.ddnet.org/wiki/Development) article on the wiki.
Cloning
-------
To clone this repository with full history and external libraries (~350 MB):
git clone --recursive https://github.com/ddnet/ddnet
To clone this repository with full history when you have the necessary libraries on your system already (~220 MB):
git clone https://github.com/ddnet/ddnet
To clone this repository with history since we moved the libraries to https://github.com/ddnet/ddnet-libs (~40 MB):
git clone --shallow-exclude=included-libs https://github.com/ddnet/ddnet
To clone the libraries if you have previously cloned DDNet without them, or if you require the ddnet-libs history instead of a shallow clone:
git submodule update --init --recursive
Dependencies on Linux / macOS
-----------------------------
You can install the required libraries on your system, `touch CMakeLists.txt` and CMake will use the system-wide libraries by default. You can install all required dependencies and CMake on Debian or Ubuntu like this:
sudo apt install build-essential cargo cmake git glslang-tools google-mock libavcodec-extra libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpng-dev libsdl2-dev libsqlite3-dev libssl-dev libvulkan-dev libwavpack-dev libx264-dev python rustc spirv-tools
On older distributions like Ubuntu 18.04 don't install `google-mock`, but instead set `-DDOWNLOAD_GTEST=ON` when building to get a more recent gtest/gmock version.
On older distributions `rustc` version might be too old, to get an up-to-date Rust compiler you can use [rustup](https://rustup.rs/) with stable channel instead or try the `rustc-mozilla` package.
Or on CentOS, RedHat and AlmaLinux like this:
sudo yum install cargo cmake ffmpeg-devel freetype-devel gcc gcc-c++ git glew-devel glslang gmock-devel gtest-devel libcurl-devel libnotify-devel libogg-devel libpng-devel libx264-devel make openssl-devel opus-devel opusfile-devel python2 rust SDL2-devel spirv-tools sqlite-devel vulkan-devel wavpack-devel
Or on Fedora like this:
sudo dnf install cargo cmake ffmpeg-devel freetype-devel gcc gcc-c++ git glew-devel glslang gmock-devel gtest-devel libcurl-devel libnotify-devel libogg-devel libpng-devel make openssl-devel opus-devel opusfile-devel python2 SDL2-devel spirv-tools sqlite-devel vulkan-devel wavpack-devel x264-devel
Or on Arch Linux like this:
sudo pacman -S --needed base-devel cmake curl ffmpeg freetype2 git glew glslang gmock libnotify libpng opusfile python rust sdl2 spirv-tools sqlite vulkan-headers vulkan-icd-loader wavpack x264
Or on Gentoo like this:
emerge --ask dev-db/sqlite dev-lang/rust-bin dev-libs/glib dev-libs/openssl dev-util/glslang dev-util/spirv-headers dev-util/spirv-tools media-libs/freetype media-libs/glew media-libs/libglvnd media-libs/libogg media-libs/libpng media-libs/libsdl2 media-libs/libsdl2[vulkan] media-libs/opus media-libs/opusfile media-libs/pnglite media-libs/vulkan-loader[layers] media-sound/wavpack media-video/ffmpeg net-misc/curl x11-libs/gdk-pixbuf x11-libs/libnotify
On macOS you can use [homebrew](https://brew.sh/) to install build dependencies like this:
brew install cmake ffmpeg freetype glew glslang googletest libpng molten-vk opusfile rust SDL2 spirv-tools vulkan-headers wavpack x264
If you don't want to use the system libraries, you can pass the `-DPREFER_BUNDLED_LIBS=ON` parameter to cmake.
Building on Linux and macOS
---------------------------
To compile DDNet yourself, execute the following commands in the source root:
mkdir build
cd build
cmake ..
make -j$(nproc)
Pass the number of threads for compilation to `make -j`. `$(nproc)` in this case returns the number of processing units.
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).
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:
* **-DCMAKE_BUILD_TYPE=[Release|Debug|RelWithDebInfo|MinSizeRel]** <br>
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.
* **-DPREFER_BUNDLED_LIBS=[ON|OFF]** <br>
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.
* **-DWEBSOCKETS=[ON|OFF]** <br>
Whether to enable WebSocket support for server. Setting to ON requires the `libwebsockets-dev` library installed. Default value is OFF.
* **-DMYSQL=[ON|OFF]** <br>
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.
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").
* **-DTEST_MYSQL=[ON|OFF]** <br>
Whether to test MySQL/MariaDB support in GTest based tests. Default value is OFF.
Note that this requires a running MySQL/MariaDB database on localhost with this setup:
```
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
```
* **-DAUTOUPDATE=[ON|OFF]** <br>
Whether to enable the autoupdater. Packagers may want to disable this for their packages. Default value is ON for Windows and Linux.
* **-DCLIENT=[ON|OFF]** <br>
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.
* **-DVIDEORECORDER=[ON|OFF]** <br>
Whether to add video recording support using FFmpeg to the client. Default value is ON.
* **-DDOWNLOAD_GTEST=[ON|OFF]** <br>
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.
* **-DDEV=[ON|OFF]** <br>
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.
* **-DUPNP=[ON|OFF]** <br>
Whether to enable UPnP support for the server.
You need to install `libminiupnpc-dev` on Debian, `miniupnpc` on Arch Linux.
Default value is OFF.
* **-DVULKAN=[ON|OFF]** <br>
Whether to enable the vulkan backend.
On Windows you need to install the Vulkan SDK and set the `VULKAN_SDK` environment flag accordingly.
Default value is ON for Windows x86\_64 and Linux, and OFF for Windows x86 and macOS.
* **-GNinja** <br>
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.
* **-DCMAKE_CXX_LINK_FLAGS=[FLAGS]** <br>
Custom flags to set for compiler when linking.
* **-DEXCEPTION_HANDLING=[ON|OFF]** <br>
Enable exception handling (only works with Windows as of now, uses DrMingw there). Default value is OFF.
* **-DIPO=[ON|OFF]** <br>
Enable interprocedural optimizations, also known as Link Time Optimization (LTO). Default value is OFF.
* **-DFUSE_LD=[OFF|LINKER]** <br>
Linker to use. Default value is OFF to try mold, lld, gold.
* **-DSECURITY_COMPILER_FLAGS=[ON|OFF]** <br>
Whether to set security-relevant compiler flags like `-D_FORTIFY_SOURCE=2` and `-fstack-protector-all`. Default Value is ON.
Running tests (Debian/Ubuntu)
-----------------------------
In order to run the tests, you need to install the following library `libgtest-dev`.
This library isn't compiled, so you have to do it:
```bash
sudo apt install libgtest-dev
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make -j8
# copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
sudo cp lib/*.a /usr/lib
```
To run the tests you must target `run_tests` with make:
`make run_tests`
Code formatting
---------------
We use clang-format 10 to format the C++ code of this project. Execute `scripts/fix_style.py` after changing the code to ensure code is formatted properly, a GitHub central style checker will do the same and prevent your change from being submitted.
On Arch Linux you can install clang-format 10 using the [clang-format-static-bin AUR package](https://aur.archlinux.org/packages/clang-format-static-bin/). On macOS you can install clang-format 10 using a [homebrew tap](https://github.com/r-lib/homebrew-taps):
```bash
brew install r-lib/taps/clang-format@10
sudo ln -s /opt/homebrew/Cellar/clang-format@10/10.0.1/bin/clang-format /opt/homebrew/bin/clang-format-10
```
Using AddressSanitizer + UndefinedBehaviourSanitizer or Valgrind's Memcheck
---------------------------------------------------------------------------
ASan+UBSan and Memcheck are useful to find code problems more easily. Please use them to test your changes if you can.
For ASan+UBSan compile with:
```bash
CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug .
make
```
and run with:
```bash
UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0 ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 LSAN_OPTIONS=suppressions=./lsan.supp ./DDNet
```
Check the SAN.\* files afterwards. This finds more problems than memcheck, runs faster, but requires a modern GCC/Clang compiler.
For valgrind's memcheck compile a normal Debug build and run with: `valgrind --tool=memcheck ./DDNet`
Expect a large slow down.
Building on Windows with Visual Studio
--------------------------------------
Download and install some version of [Microsoft Visual Studio](https://www.visualstudio.com/) (as of writing, MSVS Community 2017) with **C++ support**, install [Python 3](https://www.python.org/downloads/) **for all users** and install [CMake](https://cmake.org/download/#latest). You also need to install [Rust](https://rustup.rs/).
Start CMake and select the source code folder (where DDNet resides, the directory with `CMakeLists.txt`). Additionally select a build folder, e.g. create a build subdirectory in the source code directory. Click "Configure" and select the Visual Studio generator (it should be pre-selected, so pressing "Finish" will suffice). After configuration finishes and the "Generate" reactivates, click it. When that finishes, click "Open Project". Visual Studio should open. You can compile the DDNet client by right-clicking the DDNet project (not the solution) and select "Select as StartUp project". Now you should be able to compile DDNet by clicking the green, triangular "Run" button.
Cross-compiling on Linux to Windows x86/x86\_64
-----------------------------------------------
Install MinGW cross-compilers of the form `i686-w64-mingw32-gcc` (32 bit) or
`x86_64-w64-mingw32-gcc` (64 bit). This is probably the hard part. ;)
Then add `-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mingw64.toolchain` to the
**initial** CMake command line.
Cross-compiling on Linux to WebAssembly via Emscripten
--------------------------------------------------------
Install Emscripten cross-compilers (e.g. `sudo apt install emscripten`) on a modern linux distro.
If you need to compile the ddnet-libs for WebAssembly, simply call
```bash
# <directory to build in> should be a directory outside of the project's source directory
scripts/compile_libs/gen_libs.sh <directory to build in> webasm
```
from the project's source directory. It will automatically create a directory called `ddnet-libs`.
You can then manually merge this directory with the one in the ddnet source directory.
Then run `emcmake cmake .. -DVIDEORECORDER=OFF -DVULKAN=OFF -DSERVER=OFF -DTOOLS=OFF -DPREFER_BUNDLED_LIBS=ON` in your build directory.
To test the compiled code locally, just use `emrun --browser firefox DDNet.html`
To host the compiled .html file copy all `.data`, `.html`, `.js`, `.wasm` files to the web server. (see /other/emscripten/minimal.html for a minimal html example)
Then enable cross origin policies. Example for apache2 on debian based distros:
```bash
sudo a2enmod header
# edit the apache2 config to allow .htaccess files
sudo nano /etc/apache2/apache2.conf
# set AllowOverride to All for your directory
# then create a .htaccess file on the web server (where the .html is)
# and add these lines
Header add Cross-Origin-Embedder-Policy "require-corp"
Header add Cross-Origin-Opener-Policy "same-origin"
# now restart apache2
sudo service apache2 restart
```
Cross-compiling on Linux to macOS
---------------------------------
Install [osxcross](https://github.com/tpoechtrager/osxcross), then add
`-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/darwin.toolchain` and
`-DCMAKE_OSX_SYSROOT=/path/to/osxcross/target/SDK/MacOSX10.11.sdk/` to the
**initial** CMake command line.
Install `dmg` and `hfsplus` from
[libdmg-hfsplus](https://github.com/mozilla/libdmg-hfsplus) and `newfs_hfs`
from
[diskdev\_cmds](http://pkgs.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-540.1.linux3.tar.gz/0435afc389b919027b69616ad1b05709/diskdev_cmds-540.1.linux3.tar.gz)
to unlock the `package_dmg` target that outputs a macOS disk image.
Importing the official DDNet Database
-------------------------------------
```bash
$ wget https://ddnet.org/stats/ddnet-sql.zip
$ unzip ddnet-sql.zip
$ yaourt -S mariadb mysql-connector-c++
$ mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
$ systemctl start mariadb
$ mysqladmin -u root password 'PW'
$ mysql -u root -p'PW'
MariaDB [(none)]> create database teeworlds; create user 'teeworlds'@'localhost' identified by 'PW2'; grant all privileges on teeworlds.* to 'teeworlds'@'localhost'; flush privileges;
# this takes a while, you can remove the KEYs in record_race.sql to trade performance in queries
$ mysql -u teeworlds -p'PW2' teeworlds < ddnet-sql/record_*.sql
$ cat mine.cfg
sv_use_sql 1
add_sqlserver r teeworlds record teeworlds "PW2" "localhost" "3306"
add_sqlserver w teeworlds record teeworlds "PW2" "localhost" "3306"
$ mkdir build
$ cd build
$ cmake -DMYSQL=ON ..
$ make -j8
$ ./DDNet-Server -f mine.cfg
```
<a href="https://repology.org/metapackage/ddnet/versions">
<img src="https://repology.org/badge/vertical-allrepos/ddnet.svg?header=" alt="Packaging status" align="right">
</a>
Installation from Repository
----------------------------
Debian/Ubuntu
```bash
$ apt-get install ddnet
```
MacOS
```bash
$ brew install --cask ddnet
```
Fedora
```bash
$ dnf install ddnet
```
Arch Linux
```bash
$ yay -S ddnet
```
FreeBSD
```bash
$ pkg install DDNet
```
Benchmarking
------------
DDNet is available in the [Phoronix Test Suite](https://openbenchmarking.org/test/pts/ddnet). If you have PTS installed you can easily benchmark DDNet on your own system like this:
```bash
$ phoronix-test-suite benchmark ddnet
```
Better Git Blame
----------------
First, use a better tool than `git blame` itself, e.g. [`tig`](https://jonas.github.io/tig/). There's probably a good UI for Windows, too. Alternatively, use the GitHub UI, click "Blame" in any file view.
For `tig`, use `tig blame path/to/file.cpp` to open the blame view, you can navigate with arrow keys or kj, press comma to go to the previous revision of the current line, q to quit.
Only then you could also set up git to ignore specific formatting revisions:
```bash
git config blame.ignoreRevsFile formatting-revs.txt
```
(Neo)Vim Syntax Highlighting for config files
----------------------------------------
Copy the file detection and syntax files to your vim config folder:
```bash
# vim
cp -R other/vim/* ~/.vim/
# neovim
cp -R other/vim/* ~/.config/nvim/
```

9
bors.toml Executable file
View File

@ -0,0 +1,9 @@
status = [
"build-cmake (ubuntu-latest)",
"build-cmake (ubuntu-20.04)",
"build-cmake (macOS-latest)",
"build-cmake (windows-latest)",
"check-clang-san",
"check-clang-tidy",
"check-style",
]

178
cmake/BuildVulkanShaders.cmake Executable file
View File

@ -0,0 +1,178 @@
find_program(GLSLANG_VALIDATOR_PROGRAM glslangValidator)
find_program(SPIRV_OPTIMIZER_PROGRAM spirv-opt)
set(GLSLANG_VALIDATOR_PROGRAM_FOUND TRUE)
if(NOT GLSLANG_VALIDATOR_PROGRAM)
set(GLSLANG_VALIDATOR_PROGRAM_FOUND FALSE)
if(TARGET_OS STREQUAL "windows")
if(${TARGET_CPU_ARCHITECTURE} STREQUAL "x86_64")
set(GLSLANG_VALIDATOR_PROGRAM "$ENV{VULKAN_SDK}/Bin/glslangValidator.exe")
else()
set(GLSLANG_VALIDATOR_PROGRAM "$ENV{VULKAN_SDK}/Bin32/glslangValidator.exe")
endif()
endif()
if(EXISTS ${GLSLANG_VALIDATOR_PROGRAM})
set(GLSLANG_VALIDATOR_PROGRAM_FOUND TRUE)
elseif(TARGET_OS STREQUAL "windows" AND ${TARGET_CPU_ARCHITECTURE} STREQUAL "x86_64")
set(GLSLANG_VALIDATOR_PROGRAM "${PROJECT_SOURCE_DIR}/ddnet-libs/vulkan/windows/lib64/glslangValidator.exe")
if(EXISTS ${GLSLANG_VALIDATOR_PROGRAM})
set(GLSLANG_VALIDATOR_PROGRAM_FOUND TRUE)
endif()
endif()
if(NOT GLSLANG_VALIDATOR_PROGRAM_FOUND)
message(FATAL_ERROR "glslangValidator binary was not found. Did you install the Vulkan SDK / packages ?")
endif()
endif()
set(SPIRV_OPTIMIZER_PROGRAM_FOUND TRUE)
if(NOT SPIRV_OPTIMIZER_PROGRAM)
set(SPIRV_OPTIMIZER_PROGRAM_FOUND FALSE)
if(TARGET_OS STREQUAL "windows")
if (${TARGET_CPU_ARCHITECTURE} STREQUAL "x86_64")
set(SPIRV_OPTIMIZER_PROGRAM "$ENV{VULKAN_SDK}/Bin/spirv-opt.exe")
else()
set(SPIRV_OPTIMIZER_PROGRAM "$ENV{VULKAN_SDK}/Bin32/spirv-opt.exe")
endif()
endif()
if(EXISTS ${SPIRV_OPTIMIZER_PROGRAM})
set(SPIRV_OPTIMIZER_PROGRAM_FOUND TRUE)
endif()
endif()
file(GLOB_RECURSE GLSL_SHADER_FILES
"data/shader/vulkan/*.frag"
"data/shader/vulkan/*.vert"
)
set(TMP_SHADER_SHA256_LIST "")
foreach(GLSL_SHADER_FILE ${GLSL_SHADER_FILES})
file(SHA256 ${GLSL_SHADER_FILE} TMP_FILE_SHA)
set(TMP_SHADER_SHA256_LIST "${TMP_SHADER_SHA256_LIST}${TMP_FILE_SHA}")
endforeach(GLSL_SHADER_FILE)
string(SHA256 GLSL_SHADER_SHA256 "${TMP_SHADER_SHA256_LIST}")
set(GLSL_SHADER_SHA256 "${GLSL_SHADER_SHA256}@v1")
set(FOUND_MATCHING_SHA256_FILE FALSE)
if("${VULKAN_SHADER_FILE_SHA256}" STREQUAL "${GLSL_SHADER_SHA256}")
set(FOUND_MATCHING_SHA256_FILE TRUE)
endif()
set(TW_VULKAN_VERSION "vulkan100")
set(GLSLANG_VALIDATOR_COMMAND_LIST)
set(GLSLANG_VALIDATOR_DELETE_LIST)
set(SPIRV_OPTIMIZER_COMMAND_LIST)
function(generate_shader_file FILE_ARGS1 FILE_ARGS2 FILE_NAME FILE_OUTPUT_NAME)
set(FILE_TMP_NAME_POSTFIX "")
if(SPIRV_OPTIMIZER_PROGRAM_FOUND)
set(FILE_TMP_NAME_POSTFIX ".tmp")
endif()
list(APPEND GLSLANG_VALIDATOR_COMMAND_LIST COMMAND ${GLSLANG_VALIDATOR_PROGRAM} --client ${TW_VULKAN_VERSION} ${FILE_ARGS1} ${FILE_ARGS2} ${FILE_NAME} -o "${PROJECT_BINARY_DIR}/${FILE_OUTPUT_NAME}${FILE_TMP_NAME_POSTFIX}")
if(SPIRV_OPTIMIZER_PROGRAM_FOUND)
list(APPEND SPIRV_OPTIMIZER_COMMAND_LIST COMMAND ${SPIRV_OPTIMIZER_PROGRAM} -O "${PROJECT_BINARY_DIR}/${FILE_OUTPUT_NAME}${FILE_TMP_NAME_POSTFIX}" -o "${PROJECT_BINARY_DIR}/${FILE_OUTPUT_NAME}")
list(APPEND GLSLANG_VALIDATOR_DELETE_LIST "${PROJECT_BINARY_DIR}/${FILE_OUTPUT_NAME}${FILE_TMP_NAME_POSTFIX}")
endif()
file(RELATIVE_PATH TMP_SHADER_FILE_REL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/${FILE_OUTPUT_NAME}")
list(APPEND VULKAN_SHADER_FILE_LIST "${FILE_OUTPUT_NAME}")
set(VULKAN_SHADER_FILE_LIST ${VULKAN_SHADER_FILE_LIST} PARENT_SCOPE)
set(GLSLANG_VALIDATOR_DELETE_LIST ${GLSLANG_VALIDATOR_DELETE_LIST} PARENT_SCOPE)
set(SPIRV_OPTIMIZER_COMMAND_LIST ${SPIRV_OPTIMIZER_COMMAND_LIST} PARENT_SCOPE)
set(GLSLANG_VALIDATOR_COMMAND_LIST ${GLSLANG_VALIDATOR_COMMAND_LIST} PARENT_SCOPE)
endfunction()
if(NOT FOUND_MATCHING_SHA256_FILE)
message(STATUS "Building vulkan shaders")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/data/shader/vulkan/")
unset(VULKAN_SHADER_FILE_LIST CACHE)
# primitives
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim.frag" "data/shader/vulkan/prim.frag.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim.frag" "data/shader/vulkan/prim_textured.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim.vert" "data/shader/vulkan/prim.vert.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim.vert" "data/shader/vulkan/prim_textured.vert.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim3d.frag" "data/shader/vulkan/prim3d.frag.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim3d.frag" "data/shader/vulkan/prim3d_textured.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim3d.vert" "data/shader/vulkan/prim3d.vert.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/prim3d.vert" "data/shader/vulkan/prim3d_textured.vert.spv")
# text
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/text.frag" "data/shader/vulkan/text.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/text.vert" "data/shader/vulkan/text.vert.spv")
# quad container
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.frag" "data/shader/vulkan/primex.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.vert" "data/shader/vulkan/primex.vert.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.frag" "data/shader/vulkan/primex_rotationless.frag.spv")
generate_shader_file("-DTW_ROTATIONLESS" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.vert" "data/shader/vulkan/primex_rotationless.vert.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.frag" "data/shader/vulkan/primex_tex.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.vert" "data/shader/vulkan/primex_tex.vert.spv")
generate_shader_file("-DTW_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.frag" "data/shader/vulkan/primex_tex_rotationless.frag.spv")
generate_shader_file("-DTW_ROTATIONLESS" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/primex.vert" "data/shader/vulkan/primex_tex_rotationless.vert.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/spritemulti.frag" "data/shader/vulkan/spritemulti.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/spritemulti.vert" "data/shader/vulkan/spritemulti.vert.spv")
generate_shader_file("-DTW_PUSH_CONST" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/spritemulti.frag" "data/shader/vulkan/spritemulti_push.frag.spv")
generate_shader_file("-DTW_PUSH_CONST" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/spritemulti.vert" "data/shader/vulkan/spritemulti_push.vert.spv")
# tile layer
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile.vert.spv")
generate_shader_file("-DTW_TILE_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_textured.frag.spv")
generate_shader_file("-DTW_TILE_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_textured.vert.spv")
generate_shader_file("-DTW_TILE_BORDER" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border.frag.spv")
generate_shader_file("-DTW_TILE_BORDER" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border.vert.spv")
generate_shader_file("-DTW_TILE_BORDER" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_textured.frag.spv")
generate_shader_file("-DTW_TILE_BORDER" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_textured.vert.spv")
generate_shader_file("-DTW_TILE_BORDER_LINE" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_line.frag.spv")
generate_shader_file("-DTW_TILE_BORDER_LINE" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_line.vert.spv")
generate_shader_file("-DTW_TILE_BORDER_LINE" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.frag" "data/shader/vulkan/tile_border_line_textured.frag.spv")
generate_shader_file("-DTW_TILE_BORDER_LINE" "-DTW_TILE_TEXTURED" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/tile.vert" "data/shader/vulkan/tile_border_line_textured.vert.spv")
# quad layer
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.frag" "data/shader/vulkan/quad.frag.spv")
generate_shader_file("" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.vert" "data/shader/vulkan/quad.vert.spv")
generate_shader_file("-DTW_PUSH_CONST" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.frag" "data/shader/vulkan/quad_push.frag.spv")
generate_shader_file("-DTW_PUSH_CONST" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.vert" "data/shader/vulkan/quad_push.vert.spv")
generate_shader_file("-DTW_QUAD_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.frag" "data/shader/vulkan/quad_textured.frag.spv")
generate_shader_file("-DTW_QUAD_TEXTURED" "" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.vert" "data/shader/vulkan/quad_textured.vert.spv")
generate_shader_file("-DTW_QUAD_TEXTURED" "-DTW_PUSH_CONST" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.frag" "data/shader/vulkan/quad_push_textured.frag.spv")
generate_shader_file("-DTW_QUAD_TEXTURED" "-DTW_PUSH_CONST" "${PROJECT_SOURCE_DIR}/data/shader/vulkan/quad.vert" "data/shader/vulkan/quad_push_textured.vert.spv")
execute_process(${GLSLANG_VALIDATOR_COMMAND_LIST} RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
message(FATAL_ERROR "${GLSLANG_VALIDATOR_COMMAND_LIST} failed")
endif()
if(SPIRV_OPTIMIZER_PROGRAM_FOUND)
execute_process(${SPIRV_OPTIMIZER_COMMAND_LIST} RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
message(FATAL_ERROR "${SPIRV_OPTIMIZER_COMMAND_LIST} failed")
endif()
file(REMOVE ${GLSLANG_VALIDATOR_DELETE_LIST})
endif()
set(VULKAN_SHADER_FILE_LIST ${VULKAN_SHADER_FILE_LIST} CACHE STRING "Vulkan shader file list" FORCE)
message(STATUS "Finished building vulkan shaders")
set(VULKAN_SHADER_FILE_SHA256 ${GLSL_SHADER_SHA256} CACHE STRING "Vulkan shader file hash" FORCE)
endif()

57
cmake/CheckAtomic.cmake Executable file
View File

@ -0,0 +1,57 @@
include(CheckCXXSourceCompiles)
include(CheckLibraryExists)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.
function(check_working_cxx_atomics varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<int> x1;
std::atomic<short> x2;
std::atomic<char> x3;
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
(void)i;
++x3;
++x2;
return ++x1;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction(check_working_cxx_atomics)
if(NOT DEFINED COMPILER_IS_GCC_COMPATIBLE)
if(MSVC OR APPLE)
set(COMPILER_IS_GCC_COMPATIBLE OFF)
else()
set(COMPILER_IS_GCC_COMPATIBLE ON)
endif()
endif()
if(NOT COMPILER_IS_GCC_COMPATIBLE)
set(HAVE_ATOMICS_WITHOUT_LIB ON)
else()
# Check for 64 bit atomic operations.
# First check if atomics work without the library.
check_working_cxx_atomics(HAVE_ATOMICS_WITHOUT_LIB)
# If not, check if the library exists, and atomics work with it.
if(NOT HAVE_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
mark_as_advanced(HAVE_LIBATOMICS)
if(NOT HAVE_LIBATOMICS)
message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics(HAVE_ATOMICS_WITH_LIB)
if(NOT HAVE_ATOMICS_WITH_LIB)
message(FATAL_ERROR "Host compiler must support std::atomic!")
endif()
list(APPEND CMAKE_C_STANDARD_LIBRARIES "-latomic")
list(APPEND CMAKE_CXX_STANDARD_LIBRARIES "-latomic")
endif()
endif()

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 2.8.12...3.19.1)
project(googletest-download NONE)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG "${DDNET_GTEST_VERSION}"
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
TLS_VERIFY ON
)

30
cmake/FindAndroid.cmake Executable file
View File

@ -0,0 +1,30 @@
# the android toolchain sets the paths right
FIND_LIBRARY(ANDROID_LIBRARY_EGL
EGL
)
FIND_LIBRARY(ANDROID_LIBRARY_GLES1
GLESv1_CM
)
FIND_LIBRARY(ANDROID_LIBRARY_GLES2
GLESv2
)
FIND_LIBRARY(ANDROID_LIBRARY_GLES3
GLESv3
)
FIND_LIBRARY(ANDROID_LIBRARY_LOG
log
)
FIND_LIBRARY(ANDROID_LIBRARY_ANDROID
android
)
FIND_LIBRARY(ANDROID_LIBRARY_OPENSLES
OpenSLES
)
set(TW_ANDROID_LIBS ${ANDROID_LIBRARY_EGL} ${ANDROID_LIBRARY_GLES1} ${ANDROID_LIBRARY_GLES2} ${ANDROID_LIBRARY_GLES3} ${ANDROID_LIBRARY_LOG} ${ANDROID_LIBRARY_ANDROID} ${ANDROID_LIBRARY_OPENSLES})

52
cmake/FindCrypto.cmake Executable file
View File

@ -0,0 +1,52 @@
if(NOT PREFER_BUNDLED_LIBS)
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(CRYPTO_FOUND ON)
set(CRYPTO_BUNDLED OFF)
set(CRYPTO_LIBRARY ${OPENSSL_CRYPTO_LIBRARY})
set(CRYPTO_INCLUDEDIR ${OPENSSL_INCLUDE_DIR})
endif()
endif()
if(PREFER_BUNDLED_LIBS AND (TARGET_OS STREQUAL "android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
set_extra_dirs_lib(CRYPTO openssl)
find_library(CRYPTO_LIBRARY1
NAMES crypto
HINTS ${HINTS_CRYPTO_LIBDIR} ${PC_CRYPTO_LIBDIR} ${PC_CRYPTO_LIBRARY_DIRS}
PATHS ${PATHS_CRYPTO_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_library(CRYPTO_LIBRARY2
NAMES ssl
HINTS ${HINTS_CRYPTO_LIBDIR} ${PC_CRYPTO_LIBDIR} ${PC_CRYPTO_LIBRARY_DIRS}
PATHS ${PATHS_CRYPTO_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set(CRYPTO_LIBRARY ${CRYPTO_LIBRARY1} ${CRYPTO_LIBRARY2})
set(CMAKE_FIND_FRAMEWORK FIRST)
set_extra_dirs_include(CRYPTO openssl "${CRYPTO_LIBRARY}")
find_path(CRYPTO_INCLUDEDIR1 openssl/opensslconf.h
PATH_SUFFIXES CRYPTO
HINTS ${HINTS_CRYPTO_INCLUDEDIR} ${PC_CRYPTO_INCLUDEDIR} ${PC_CRYPTO_INCLUDE_DIRS}
PATHS ${PATHS_CRYPTO_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_path(CRYPTO_INCLUDEDIR2 openssl/configuration.h
PATH_SUFFIXES CRYPTO
HINTS ${HINTS_CRYPTO_INCLUDEDIR} ${PC_CRYPTO_INCLUDEDIR} ${PC_CRYPTO_INCLUDE_DIRS}
PATHS ${PATHS_CRYPTO_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set(CRYPTO_INCLUDEDIR ${CRYPTO_INCLUDEDIR1} ${CRYPTO_INCLUDEDIR2})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Crypto DEFAULT_MSG CRYPTO_LIBRARY CRYPTO_INCLUDEDIR)
mark_as_advanced(CRYPTO_LIBRARY CRYPTO_INCLUDEDIR)
if(CRYPTO_FOUND)
set(CRYPTO_LIBRARIES ${CRYPTO_LIBRARY})
set(CRYPTO_INCLUDE_DIRS ${CRYPTO_INCLUDEDIR})
endif()

38
cmake/FindCurl.cmake Executable file
View File

@ -0,0 +1,38 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_CURL libcurl)
endif()
set_extra_dirs_lib(CURL curl)
find_library(CURL_LIBRARY
NAMES curl
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
PATHS ${PATHS_CURL_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(CURL curl "${CURL_LIBRARY}")
find_path(CURL_INCLUDEDIR curl/curl.h
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
PATHS ${PATHS_CURL_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Curl DEFAULT_MSG CURL_LIBRARY CURL_INCLUDEDIR)
mark_as_advanced(CURL_LIBRARY CURL_INCLUDEDIR)
if(CURL_FOUND)
is_bundled(CURL_BUNDLED "${CURL_LIBRARY}")
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDEDIR})
if(CURL_BUNDLED AND TARGET_OS STREQUAL "windows")
set(CURL_COPY_FILES
"${EXTRA_CURL_LIBDIR}/libcurl.dll"
"${EXTRA_CURL_LIBDIR}/zlib1.dll"
)
else()
set(CURL_COPY_FILES)
endif()
endif()

36
cmake/FindDiscordSdk.cmake Executable file
View File

@ -0,0 +1,36 @@
set_extra_dirs_lib(DISCORDSDK discord)
find_library(DISCORDSDK_LIBRARY
NAMES discord_game_sdk.dll.lib discord_game_sdk.dylib discord_game_sdk.so
HINTS ${HINTS_DISCORDSDK_LIBDIR}
PATHS ${PATHS_DISCORDSDK_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(DISCORDSDK discord "${DISCORDSDK_LIBRARY}")
find_path(DISCORDSDK_INCLUDEDIR discord_game_sdk.h
HINTS ${HINTS_DISCORDSDK_INCLUDEDIR}
PATHS ${PATHS_DISCORDSDK_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DiscordSdk DEFAULT_MSG DISCORDSDK_LIBRARY DISCORDSDK_INCLUDEDIR)
mark_as_advanced(DISCORDSDK_LIBRARY DISCORDSDK_INCLUDEDIR)
if(DISCORDSDK_FOUND)
is_bundled(DISCORDSDK_BUNDLED "${DISCORDSDK_LIBRARY}")
set(DISCORDSDK_LIBRARIES ${DISCORDSDK_LIBRARY})
set(DISCORDSDK_INCLUDE_DIRS ${DISCORDSDK_INCLUDEDIR})
if(DISCORDSDK_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.dll")
elseif(TARGET_OS STREQUAL "linux")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.so")
elseif(TARGET_OS STREQUAL "mac")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.dylib")
endif()
else()
set(DISCORDSDK_COPY_FILES)
endif()
endif()

View File

@ -0,0 +1,21 @@
if(TARGET_OS STREQUAL "windows")
set_extra_dirs_lib(EXCEPTION_HANDLING drmingw)
find_file(EXCEPTION_HANDLING_LIBRARY
NAMES exchndl.dll
HINTS ${HINTS_EXCEPTION_HANDLING_LIBDIR}
PATHS ${PATHS_EXCEPTION_HANDLING_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
is_bundled(EXCEPTION_HANDLING_BUNDLED "${EXCEPTION_HANDLING_LIBRARY}")
if(NOT EXCEPTION_HANDLING_BUNDLED)
message(FATAL_ERROR "could not find exception handling paths")
endif()
set(EXCEPTION_HANDLING_COPY_FILES
"${EXTRA_EXCEPTION_HANDLING_LIBDIR}/exchndl.dll"
"${EXTRA_EXCEPTION_HANDLING_LIBDIR}/dbgcore.dll"
"${EXTRA_EXCEPTION_HANDLING_LIBDIR}/dbghelp.dll"
"${EXTRA_EXCEPTION_HANDLING_LIBDIR}/mgwhelp.dll"
"${EXTRA_EXCEPTION_HANDLING_LIBDIR}/symsrv.dll"
)
endif()

168
cmake/FindFFMPEG.cmake Executable file
View File

@ -0,0 +1,168 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_AVCODEC libavcodec)
pkg_check_modules(PC_AVFORMAT libavformat)
pkg_check_modules(PC_AVUTIL libavutil)
pkg_check_modules(PC_SWSCALE libswscale)
pkg_check_modules(PC_SWRESAMPLE libswresample)
if(TARGET_OS STREQUAL "linux")
pkg_search_module(PC_X264 libx264 x264)
endif()
endif()
set_extra_dirs_lib(FFMPEG ffmpeg)
find_library(AVCODEC_LIBRARY
NAMES avcodec.59 avcodec libavcodec
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVCODEC_LIBRARY_DIRS}
PATHS ${PATHS_AVCODEC_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_library(AVFORMAT_LIBRARY
NAMES avformat.59 avformat libavformat
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVFORMAT_LIBRARY_DIRS}
PATHS ${PATHS_AVFORMAT_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_library(AVUTIL_LIBRARY
NAMES avutil.57 avutil libavutil
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_AVUTIL_LIBRARY_DIRS}
PATHS ${PATHS_AVUTIL_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_library(SWSCALE_LIBRARY
NAMES swscale.6 swscale libswscale
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_SWSCALE_LIBRARY_DIRS}
PATHS ${PATHS_SWSCALE_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_library(SWRESAMPLE_LIBRARY
NAMES swresample.4 swresample libswresample
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_SWRESAMPLE_LIBRARY_DIRS}
PATHS ${PATHS_SWRESAMPLE_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
if(TARGET_OS STREQUAL "linux")
find_library(X264_LIBRARY
NAMES x264 libx264
HINTS ${HINTS_FFMPEG_LIBDIR} ${PC_X264_LIBRARY_DIRS}
PATHS ${PATHS_X264_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
endif()
set_extra_dirs_include(AVCODEC ffmpeg "${AVCODEC_LIBRARY}")
find_path(AVCODEC_INCLUDEDIR libavcodec
HINTS ${HINTS_AVCODEC_INCLUDEDIR} ${PC_AVCODEC_INCLUDE_DIRS}
PATHS ${PATHS_AVCODEC_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(AVFORMAT ffmpeg "${AVFORMAT_LIBRARY}")
find_path(AVFORMAT_INCLUDEDIR libavformat
HINTS ${HINTS_AVFORMAT_INCLUDEDIR} ${PC_AVFORMAT_INCLUDE_DIRS}
PATHS ${PATHS_AVFORMAT_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(AVUTIL ffmpeg "${AVUTIL_LIBRARY}")
find_path(AVUTIL_INCLUDEDIR libavutil
HINTS ${HINTS_AVUTIL_INCLUDEDIR} ${PC_AVUTIL_INCLUDE_DIRS}
PATHS ${PATHS_AVUTIL_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(SWSCALE ffmpeg "${SWSCALE_LIBRARY}")
find_path(SWSCALE_INCLUDEDIR libswscale
HINTS ${HINTS_SWSCALE_INCLUDEDIR} ${PC_SWSCALE_INCLUDE_DIRS}
PATHS ${PATHS_SWSCALE_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(SWRESAMPLE ffmpeg "${SWRESAMPLE_LIBRARY}")
find_path(SWRESAMPLE_INCLUDEDIR libswresample
HINTS ${HINTS_SWRESAMPLE_INCLUDEDIR} ${PC_SWRESAMPLE_INCLUDE_DIRS}
PATHS ${PATHS_SWRESAMPLE_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
if(TARGET_OS STREQUAL "linux")
set_extra_dirs_include(X264 x264 "${X264_LIBRARY}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFMPEG DEFAULT_MSG
AVCODEC_LIBRARY
AVFORMAT_LIBRARY
AVUTIL_LIBRARY
SWSCALE_LIBRARY
SWRESAMPLE_LIBRARY
AVCODEC_INCLUDEDIR
AVFORMAT_INCLUDEDIR
AVUTIL_INCLUDEDIR
SWSCALE_INCLUDEDIR
SWRESAMPLE_INCLUDEDIR
)
mark_as_advanced(
AVCODEC_LIBRARY
AVFORMAT_LIBRARY
AVUTIL_LIBRARY
SWSCALE_LIBRARY
SWRESAMPLE_LIBRARY
AVCODEC_INCLUDEDIR
AVFORMAT_INCLUDEDIR
AVUTIL_INCLUDEDIR
SWSCALE_INCLUDEDIR
SWRESAMPLE_INCLUDEDIR
)
set(FFMPEG_LIBRARIES
${AVFORMAT_LIBRARY} # has to come before avcodec
${AVCODEC_LIBRARY}
${AVUTIL_LIBRARY}
${SWSCALE_LIBRARY}
${SWRESAMPLE_LIBRARY}
)
if(TARGET_OS STREQUAL "linux")
list(APPEND FFMPEG_LIBRARIES ${X264_LIBRARY})
endif()
if(NOT TARGET_OS STREQUAL "windows")
list(APPEND FFMPEG_LIBRARIES ${CMAKE_DL_LIBS})
endif()
set(FFMPEG_INCLUDE_DIRS
${AVCODEC_INCLUDEDIR}
${AVFORMAT_INCLUDEDIR}
${AVUTIL_INCLUDEDIR}
${SWSCALE_INCLUDEDIR}
${SWRESAMPLE_INCLUDEDIR}
)
is_bundled(FFMPEG_BUNDLED "${AVCODEC_LIBRARY}")
set(FFMPEG_COPY_FILES)
if(FFMPEG_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(FFMPEG_COPY_FILES
"${EXTRA_FFMPEG_LIBDIR}/avcodec-59.dll"
"${EXTRA_FFMPEG_LIBDIR}/avformat-59.dll"
"${EXTRA_FFMPEG_LIBDIR}/avutil-57.dll"
"${EXTRA_FFMPEG_LIBDIR}/swresample-4.dll"
"${EXTRA_FFMPEG_LIBDIR}/swscale-6.dll"
)
elseif(TARGET_OS STREQUAL "mac")
set(FFMPEG_COPY_FILES
"${EXTRA_FFMPEG_LIBDIR}/libavcodec.59.dylib"
"${EXTRA_FFMPEG_LIBDIR}/libavformat.59.dylib"
"${EXTRA_FFMPEG_LIBDIR}/libavutil.57.dylib"
"${EXTRA_FFMPEG_LIBDIR}/libswresample.4.dylib"
"${EXTRA_FFMPEG_LIBDIR}/libswscale.6.dylib"
)
endif()
endif()

40
cmake/FindFreetype.cmake Executable file
View File

@ -0,0 +1,40 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_FREETYPE freetype2)
endif()
set_extra_dirs_lib(FREETYPE freetype)
find_library(FREETYPE_LIBRARY
NAMES freetype.6 freetype
HINTS ${HINTS_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
PATHS ${PATHS_FREETYPE_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(FREETYPE freetype "${FREETYPE_LIBRARY}")
find_path(FREETYPE_INCLUDEDIR
NAMES freetype/config/ftheader.h config/ftheader.h
PATH_SUFFIXES freetype2
HINTS ${HINTS_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
PATHS ${PATHS_FREETYPE_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDEDIR)
mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDEDIR)
if(FREETYPE_FOUND)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDEDIR})
is_bundled(FREETYPE_BUNDLED "${FREETYPE_LIBRARY}")
set(FREETYPE_COPY_FILES)
if(FREETYPE_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(FREETYPE_COPY_FILES "${EXTRA_FREETYPE_LIBDIR}/libfreetype.dll")
elseif(TARGET_OS STREQUAL "mac")
set(FREETYPE_COPY_FILES "${EXTRA_FREETYPE_LIBDIR}/libfreetype.6.dylib")
endif()
endif()
endif()

32
cmake/FindGLEW.cmake Executable file
View File

@ -0,0 +1,32 @@
if(NOT PREFER_BUNDLED_LIBS)
set(CMAKE_MODULE_PATH ${ORIGINAL_CMAKE_MODULE_PATH})
find_package(GLEW)
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
if(GLEW_FOUND)
set(GLEW_BUNDLED OFF)
set(GLEW_DEP)
if(NOT GLEW_LIBRARIES)
set(GLEW_LIBRARIES GLEW::GLEW)
endif()
endif()
endif()
if(NOT GLEW_FOUND)
set(GLEW_BUNDLED ON)
set(GLEW_SRC_DIR src/engine/external/glew)
set_src(GLEW_SRC GLOB ${GLEW_SRC_DIR} glew.c)
set_src(GLEW_INCLUDES GLOB ${GLEW_SRC_DIR}/GL eglew.h glew.h glxew.h wglew.h)
add_library(glew EXCLUDE_FROM_ALL OBJECT ${GLEW_SRC} ${GLEW_INCLUDES})
set(GLEW_INCLUDEDIR ${GLEW_SRC_DIR})
target_include_directories(glew PRIVATE ${GLEW_INCLUDEDIR})
target_compile_definitions(glew PRIVATE GLEW_STATIC)
set(GLEW_DEP $<TARGET_OBJECTS:glew>)
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDEDIR})
set(GLEW_LIBRARIES)
list(APPEND TARGETS_DEP glew)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDEDIR)
endif()

33
cmake/FindMiniupnpc.cmake Executable file
View File

@ -0,0 +1,33 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_MINIUPNPC miniupnpc)
endif()
set_extra_dirs_lib(MINIUPNPC miniupnpc)
find_library(MINIUPNPC_LIBRARY
NAMES miniupnpc
HINTS ${HINTS_MINIUPNPC_LIBDIR} ${PC_MINIUPNPC_LIBDIR} ${PC_MINIUPNPC_LIBRARY_DIRS}
PATHS ${PATHS_MINIUPNPC_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(MINIUPNPC miniupnpc "${MINIUPNPC_LIBRARY}")
find_path(MINIUPNPC_INCLUDEDIR miniupnpc.h
PATH_SUFFIXES miniupnpc
HINTS ${HINTS_MINIUPNPC_INCLUDEDIR} ${PC_MINIUPNPC_INCLUDEDIR} ${PC_MINIUPNPC_INCLUDE_DIRS}
PATHS ${PATHS_MINIUPNPC_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Miniupnpc DEFAULT_MSG MINIUPNPC_INCLUDEDIR)
mark_as_advanced(MINIUPNPC_INCLUDEDIR MINIUPNPC_LIBRARY)
if(MINIUPNPC_FOUND)
set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDEDIR})
if(MINIUPNPC_LIBRARY)
set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY})
else()
set(MINIUPNPC_LIBRARIES)
endif()
endif()

60
cmake/FindMySQL.cmake Executable file
View File

@ -0,0 +1,60 @@
if(NOT CMAKE_CROSSCOMPILING)
find_program(MYSQL_CONFIG
NAMES mysql_config mariadb_config
)
if(MYSQL_CONFIG)
exec_program(${MYSQL_CONFIG}
ARGS --include
OUTPUT_VARIABLE MY_TMP
)
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
set(MYSQL_CONFIG_INCLUDE_DIR ${MY_TMP} CACHE FILEPATH INTERNAL)
exec_program(${MYSQL_CONFIG}
ARGS --libs_r
OUTPUT_VARIABLE MY_TMP
)
set(MYSQL_CONFIG_LIBRARIES "")
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIB_LIST})
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_CONFIG_LIBRARIES "${LIB}")
endforeach()
set(MYSQL_CONFIG_LIBRARY_PATH "")
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
foreach(LIB ${MYSQL_LIBDIR_LIST})
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
list(APPEND MYSQL_CONFIG_LIBRARY_PATH "${LIB}")
endforeach()
endif()
endif()
set_extra_dirs_lib(MYSQL mysql)
find_library(MYSQL_LIBRARY
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(MYSQL mysql "${MYSQL_LIBRARY}")
find_path(MYSQL_INCLUDEDIR
NAMES "mysql.h"
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MySQL DEFAULT_MSG MYSQL_LIBRARY MYSQL_INCLUDEDIR)
if(MYSQL_FOUND)
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDEDIR})
mark_as_advanced(MYSQL_INCLUDEDIR MYSQL_LIBRARY)
endif()

4
cmake/FindNotify.cmake Executable file
View File

@ -0,0 +1,4 @@
find_package(PkgConfig QUIET)
pkg_check_modules(NOTIFY QUIET libnotify)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Notify DEFAULT_MSG NOTIFY_LIBRARIES NOTIFY_INCLUDE_DIRS)

33
cmake/FindOgg.cmake Executable file
View File

@ -0,0 +1,33 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_OGG ogg)
endif()
set_extra_dirs_lib(OGG opus)
find_library(OGG_LIBRARY
NAMES ogg
HINTS ${HINTS_OGG_LIBDIR} ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
PATHS ${PATHS_OGG_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(OGG opus "${OGG_LIBRARY}")
find_path(OGG_INCLUDEDIR ogg/ogg.h
PATH_SUFFIXES ogg
HINTS ${HINTS_OGG_INCLUDEDIR} ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
PATHS ${PATHS_OGG_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDEDIR)
mark_as_advanced(OGG_INCLUDEDIR OGG_LIBRARY)
if(OGG_FOUND)
set(OGG_INCLUDE_DIRS ${OGG_INCLUDEDIR})
if(OGG_LIBRARY)
set(OGG_LIBRARIES ${OGG_LIBRARY})
else()
set(OGG_LIBRARIES)
endif()
endif()

33
cmake/FindOpus.cmake Executable file
View File

@ -0,0 +1,33 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_OPUS opus)
endif()
set_extra_dirs_lib(OPUS opus)
find_library(OPUS_LIBRARY
NAMES opus
HINTS ${HINTS_OPUS_LIBDIR} ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
PATHS ${PATHS_OPUS_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(OPUS opus "${OPUS_LIBRARY}")
find_path(OPUS_INCLUDEDIR opus.h
PATH_SUFFIXES opus
HINTS ${HINTS_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
PATHS ${PATHS_OPUS_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Opus DEFAULT_MSG OPUS_INCLUDEDIR)
mark_as_advanced(OPUS_INCLUDEDIR OPUS_LIBRARY)
if(OPUS_FOUND)
set(OPUS_INCLUDE_DIRS ${OPUS_INCLUDEDIR})
if(OPUS_LIBRARY)
set(OPUS_LIBRARIES ${OPUS_LIBRARY})
else()
set(OPUS_LIBRARIES)
endif()
endif()

46
cmake/FindOpusfile.cmake Executable file
View File

@ -0,0 +1,46 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_OPUSFILE opusfile)
endif()
set_extra_dirs_lib(OPUSFILE opus)
find_library(OPUSFILE_LIBRARY
NAMES opusfile
HINTS ${HINTS_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
PATHS ${PATHS_OPUSFILE_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(OPUSFILE opus "${OPUSFILE_LIBRARY}")
find_path(OPUSFILE_INCLUDEDIR opusfile.h
PATH_SUFFIXES opus
HINTS ${HINTS_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
PATHS ${PATHS_OPUSFILE_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Opusfile DEFAULT_MSG OPUSFILE_LIBRARY OPUSFILE_INCLUDEDIR)
mark_as_advanced(OPUSFILE_LIBRARY OPUSFILE_INCLUDEDIR)
set(OPUSFILE_LIBRARIES ${OPUSFILE_LIBRARY})
set(OPUSFILE_INCLUDE_DIRS ${OPUSFILE_INCLUDEDIR})
if(OPUSFILE_FOUND)
is_bundled(OPUSFILE_BUNDLED "${OPUSFILE_LIBRARY}")
if(OPUSFILE_BUNDLED AND TARGET_OS STREQUAL "windows")
set(OPUSFILE_COPY_FILES
"${EXTRA_OPUSFILE_LIBDIR}/libogg.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libopus.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libopusfile.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libwinpthread-1.dll"
)
if(TARGET_BITS EQUAL 32)
list(APPEND OPUSFILE_COPY_FILES
"${EXTRA_OPUSFILE_LIBDIR}/libgcc_s_sjlj-1.dll"
)
endif()
else()
set(OPUSFILE_COPY_FILES)
endif()
endif()

49
cmake/FindPNG.cmake Executable file
View File

@ -0,0 +1,49 @@
if(NOT PREFER_BUNDLED_LIBS)
set(CMAKE_MODULE_PATH ${ORIGINAL_CMAKE_MODULE_PATH})
find_package(PNG)
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
if(PNG_FOUND)
set(PNG_BUNDLED OFF)
set(PNG_DEP)
endif()
endif()
if(NOT PNG_FOUND)
set_extra_dirs_lib(PNG png)
find_library(PNG_LIBRARY
NAMES libpng16.16 png16.16 libpng16-16 png16-16 libpng16 png16
HINTS ${HINTS_PNG_LIBDIR} ${PC_PNG_LIBDIR} ${PC_PNG_LIBRARY_DIRS}
PATHS ${PATHS_PNG_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(PNG png "${PNG_LIBRARY}")
find_path(PNG_INCLUDEDIR
NAMES png.h
HINTS ${HINTS_PNG_INCLUDEDIR} ${PC_PNG_INCLUDEDIR} ${PC_PNG_INCLUDE_DIRS}
PATHS ${PATHS_PNG_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
mark_as_advanced(PNG_LIBRARY PNG_INCLUDEDIR)
if(PNG_LIBRARY AND PNG_INCLUDEDIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_INCLUDEDIR)
set(PNG_LIBRARIES ${PNG_LIBRARY})
set(PNG_INCLUDE_DIRS ${PNG_INCLUDEDIR})
endif()
endif()
set(PNG_COPY_FILES)
if(PNG_FOUND)
is_bundled(PNG_BUNDLED "${PNG_LIBRARY}")
if(PNG_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(PNG_COPY_FILES "${EXTRA_PNG_LIBDIR}/libpng16-16.dll")
elseif(TARGET_OS STREQUAL "mac")
set(PNG_COPY_FILES "${EXTRA_PNG_LIBDIR}/libpng16.16.dylib")
endif()
endif()
endif()

29
cmake/FindRust.cmake Executable file
View File

@ -0,0 +1,29 @@
find_program(RUST_RUSTC rustc)
find_program(RUST_CARGO cargo)
if(RUST_RUSTC)
execute_process(COMMAND ${RUST_RUSTC} --version --verbose OUTPUT_VARIABLE RUSTC_VERSION_OUTPUT)
string(REPLACE "\n" ";" RUSTC_VERSION_OUTPUT "${RUSTC_VERSION_OUTPUT}")
set(RUST_NIGHTLY OFF)
foreach(line ${RUSTC_VERSION_OUTPUT})
if(NOT DEFINED RUST_VERSION_STRING)
set(RUST_VERSION_STRING ${line})
endif()
if(line MATCHES "^([^:]+): (.*)$")
set(KEY ${CMAKE_MATCH_1})
set(VALUE ${CMAKE_MATCH_2})
if(KEY STREQUAL "release")
set(RUST_VERSION ${VALUE})
if(VALUE MATCHES "nightly")
set(RUST_NIGHTLY ON)
endif()
elseif(KEY STREQUAL "host")
set(RUST_TARGET_HOST ${VALUE})
endif()
endif()
endforeach()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Rust DEFAULT_MSG RUST_RUSTC RUST_CARGO)
mark_as_advanced(RUST_RUSTC RUST_CARGO)

52
cmake/FindSDL2.cmake Executable file
View File

@ -0,0 +1,52 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_SDL2 sdl2)
endif()
set_extra_dirs_lib(SDL2 sdl)
find_library(SDL2_LIBRARY
NAMES SDL2
HINTS ${HINTS_SDL2_LIBDIR} ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
PATHS ${PATHS_SDL2_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
if(PREFER_BUNDLED_LIBS)
set(CMAKE_FIND_FRAMEWORK FIRST)
else()
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
set_extra_dirs_include(SDL2 sdl "${SDL2_LIBRARY}")
# Looking for 'SDL.h' directly might accidentally find a SDL instead of SDL 2
# installation. Look for a header file only present in SDL 2 instead.
find_path(SDL2_INCLUDEDIR SDL_assert.h
PATH_SUFFIXES SDL2
HINTS ${HINTS_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
PATHS ${PATHS_SDL2_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDEDIR)
mark_as_advanced(SDL2_LIBRARY SDL2_INCLUDEDIR)
if(SDL2_FOUND)
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDEDIR})
is_bundled(SDL2_BUNDLED "${SDL2_LIBRARY}")
set(SDL2_COPY_FILES)
set(SDL2_COPY_DIRS)
if(SDL2_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(SDL2_COPY_FILES "${EXTRA_SDL2_LIBDIR}/SDL2.dll")
if(TARGET_BITS EQUAL 32)
list(APPEND OPUSFILE_COPY_FILES
"${EXTRA_SDL2_LIBDIR}/libgcc_s_dw2-1.dll"
)
endif()
elseif(TARGET_OS STREQUAL "mac")
set(SDL2_COPY_DIRS "${EXTRA_SDL2_LIBDIR}/SDL2.framework")
endif()
endif()
endif()

45
cmake/FindSQLite3.cmake Executable file
View File

@ -0,0 +1,45 @@
if(NOT PREFER_BUNDLED_LIBS)
set(CMAKE_MODULE_PATH ${ORIGINAL_CMAKE_MODULE_PATH})
find_package(SQLite3)
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
endif()
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_SQLite3 sqlite3)
endif()
set_extra_dirs_lib(SQLite3 sqlite3)
find_library(SQLite3_LIBRARY
NAMES sqlite3 sqlite3.0
HINTS ${HINTS_SQLite3_LIBDIR} ${PC_SQLite3_LIBDIR} ${PC_SQLite3_LIBRARY_DIRS}
PATHS ${PATHS_SQLite3_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(SQLite3 sqlite3 "${SQLite3_LIBRARY}")
find_path(SQLite3_INCLUDEDIR sqlite3.h
PATH_SUFFIXES sqlite3
HINTS ${HINTS_SQLite3_INCLUDEDIR} ${PC_SQLite3_INCLUDEDIR} ${PC_SQLite3_INCLUDE_DIRS}
PATHS ${PATHS_SQLite3_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLite3_INCLUDEDIR SQLite3_LIBRARY)
mark_as_advanced(SQLite3_INCLUDEDIR SQLite3_LIBRARY)
if(CMAKE_VERSION VERSION_LESS 3.0 AND SQLITE3_FOUND)
set(SQLite3_FOUND TRUE)
endif()
if(SQLite3_FOUND)
is_bundled(SQLite3_BUNDLED "${SQLite3_LIBRARY}")
set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDEDIR})
is_bundled(SQLite3_BUNDLED "${SQLite3_LIBRARY}")
set(SQLite3_COPY_FILES)
if(SQLite3_BUNDLED AND TARGET_OS STREQUAL "windows")
set(SQLite3_COPY_FILES "${EXTRA_SQLite3_LIBDIR}/sqlite3.dll")
endif()
endif()

61
cmake/FindVulkan.cmake Executable file
View File

@ -0,0 +1,61 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_VULKAN vulkan)
if(PC_VULKAN_FOUND)
set(VULKAN_INCLUDE_DIRS "${PC_VULKAN_INCLUDE_DIRS}")
set(VULKAN_LIBRARIES "${PC_VULKAN_LIBRARIES}")
set(VULKAN_FOUND TRUE)
endif()
endif()
if(NOT VULKAN_FOUND)
if(TARGET_OS STREQUAL "android")
find_library(VULKAN_LIBRARIES
NAMES vulkan
)
find_path(
VULKAN_INCLUDE_DIRS
NAMES vulkan/vulkan.h
)
elseif(TARGET_OS STREQUAL "mac")
find_library(VULKAN_LIBRARIES
NAMES MoltenVK
)
find_path(
VULKAN_INCLUDE_DIRS
NAMES vulkan/vulkan.h
)
else()
set_extra_dirs_lib(VULKAN vulkan)
find_library(VULKAN_LIBRARIES
NAMES vulkan vulkan-1
HINTS ${HINTS_VULKAN_LIBDIR} ${PC_VULKAN_LIBDIR} ${PC_VULKAN_LIBRARY_DIRS}
PATHS ${PATHS_VULKAN_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(VULKAN vulkan "${VULKAN_LIBRARIES}")
find_path(
VULKAN_INCLUDE_DIRS
NAMES vulkan/vulkan.h
HINTS ${HINTS_VULKAN_INCLUDEDIR} ${PC_VULKAN_INCLUDEDIR} ${PC_VULKAN_INCLUDE_DIRS}
PATHS ${PATHS_VULKAN_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
endif()
if(VULKAN_INCLUDE_DIRS AND VULKAN_LIBRARIES)
set(VULKAN_FOUND TRUE)
else(VULKAN_INCLUDE_DIRS AND VULKAN_LIBRARIES)
set(VULKAN_FOUND FALSE)
endif(VULKAN_INCLUDE_DIRS AND VULKAN_LIBRARIES)
endif()
if(TARGET_OS STREQUAL "windows")
is_bundled(VULKAN_BUNDLED "${VULKAN_LIBRARIES}")
if(VULKAN_BUNDLED)
set(VULKAN_COPY_FILES "${EXTRA_VULKAN_LIBDIR}/vulkan-1.dll")
endif()
endif()

52
cmake/FindWavpack.cmake Executable file
View File

@ -0,0 +1,52 @@
if(NOT PREFER_BUNDLED_LIBS)
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_WAVPACK wavpack)
endif()
find_library(WAVPACK_LIBRARY
NAMES wavpack
HINTS ${PC_WAVPACK_LIBDIR} ${PC_WAVPACK_LIBRARY_DIRS}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_path(WAVPACK_INCLUDEDIR
NAMES wavpack.h
PATH_SUFFIXES wavpack
HINTS ${PC_WAVPACK_INCLUDEDIR} ${PC_WAVPACK_INCLUDE_DIRS}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
mark_as_advanced(WAVPACK_LIBRARY WAVPACK_INCLUDEDIR)
if(WAVPACK_LIBRARY AND WAVPACK_INCLUDEDIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Wavpack DEFAULT_MSG WAVPACK_LIBRARY WAVPACK_INCLUDEDIR)
set(WAVPACK_LIBRARIES ${WAVPACK_LIBRARY})
set(WAVPACK_INCLUDE_DIRS ${WAVPACK_INCLUDEDIR})
set(WAVPACK_BUNDLED OFF)
endif()
endif()
if(NOT WAVPACK_FOUND)
set(WAVPACK_SRC_DIR src/engine/external/wavpack)
set_src(WAVPACK_SRC GLOB ${WAVPACK_SRC_DIR}
bits.c
float.c
metadata.c
unpack.c
wavpack.h
words.c
wputils.c
)
add_library(wavpack EXCLUDE_FROM_ALL OBJECT ${WAVPACK_SRC})
set(WAVPACK_DEP $<TARGET_OBJECTS:wavpack>)
set(WAVPACK_INCLUDEDIR ${WAVPACK_SRC_DIR})
set(WAVPACK_INCLUDE_DIRS ${WAVPACK_INCLUDEDIR})
list(APPEND TARGETS_DEP wavpack)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Wavpack DEFAULT_MSG WAVPACK_INCLUDEDIR)
set(WAVPACK_BUNDLED ON)
endif()

39
cmake/FindWebsockets.cmake Executable file
View File

@ -0,0 +1,39 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_WEBSOCKETS libwebsockets)
endif()
set_extra_dirs_lib(WEBSOCKETS websockets)
find_library(WEBSOCKETS_LIBRARY
NAMES websockets websockets.17
HINTS ${HINTS_WEBSOCKETS_LIBDIR} ${PC_WEBSOCKETS_LIBDIR} ${PC_WEBSOCKETS_LIBRARY_DIRS}
PATHS ${PATHS_WEBSOCKETS_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(WEBSOCKETS websockets "${WEBSOCKETS_LIBRARY}")
find_path(WEBSOCKETS_INCLUDEDIR
NAMES libwebsockets.h
HINTS ${HINTS_WEBSOCKETS_INCLUDEDIR} ${PC_WEBSOCKETS_INCLUDEDIR} ${PC_WEBSOCKETS_INCLUDE_DIRS}
PATHS ${PATHS_WEBSOCKETS_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Websockets DEFAULT_MSG WEBSOCKETS_LIBRARY WEBSOCKETS_INCLUDEDIR)
mark_as_advanced(WEBSOCKETS_LIBRARY WEBSOCKETS_INCLUDEDIR)
if(WEBSOCKETS_FOUND)
set(WEBSOCKETS_LIBRARIES ${WEBSOCKETS_LIBRARY})
set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDEDIR})
is_bundled(WEBSOCKETS_BUNDLED "${WEBSOCKETS_LIBRARY}")
set(WEBSOCKETS_COPY_FILES)
if(WEBSOCKETS_BUNDLED)
if(TARGET_OS STREQUAL "windows")
set(WEBSOCKETS_COPY_FILES "${EXTRA_WEBSOCKETS_LIBDIR}/libwebsockets.dll")
elseif(TARGET_OS STREQUAL "mac")
set(WEBSOCKETS_COPY_FILES "${EXTRA_WEBSOCKETS_LIBDIR}/libwebsockets.19.dylib")
endif()
endif()
endif()

83
cmake/FindZLIB.cmake Executable file
View File

@ -0,0 +1,83 @@
if(NOT PREFER_BUNDLED_LIBS)
set(CMAKE_MODULE_PATH ${ORIGINAL_CMAKE_MODULE_PATH})
find_package(ZLIB)
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
if(ZLIB_FOUND)
set(ZLIB_BUNDLED OFF)
set(ZLIB_DEP)
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set_extra_dirs_lib(ZLIB zlib)
find_library(ZLIB_LIBRARY
NAMES z
HINTS ${HINTS_ZLIB_LIBDIR} ${PC_ZLIB_LIBDIR} ${PC_ZLIB_LIBRARY_DIRS}
PATHS ${PATHS_ZLIB_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(ZLIB zlib "${ZLIB_LIBRARY}")
find_path(ZLIB_INCLUDEDIR1 zlib.h
PATH_SUFFIXES zlib
HINTS ${HINTS_ZLIB_INCLUDEDIR} ${PC_ZLIB_INCLUDEDIR} ${PC_ZLIB_INCLUDE_DIRS}
PATHS ${PATHS_ZLIB_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
find_path(ZLIB_INCLUDEDIR2 zconf.h
PATH_SUFFIXES zlib
HINTS ${HINTS_ZLIB_INCLUDEDIR} ${PC_ZLIB_INCLUDEDIR} ${PC_ZLIB_INCLUDE_DIRS}
PATHS ${PATHS_ZLIB_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
if(ZLIB_LIBRARY AND ZLIB_INCLUDEDIR1 AND ZLIB_INCLUDEDIR2)
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDEDIR1} ${ZLIB_INCLUDEDIR2})
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
set(ZLIB_FOUND TRUE)
endif()
endif()
if(NOT ZLIB_FOUND)
set(ZLIB_BUNDLED ON)
set(ZLIB_SRC_DIR src/engine/external/zlib)
set_src(ZLIB_SRC GLOB ${ZLIB_SRC_DIR}
adler32.c
compress.c
crc32.c
crc32.h
deflate.c
deflate.h
gzclose.c
gzguts.h
gzlib.c
gzread.c
gzwrite.c
infback.c
inffast.c
inffast.h
inffixed.h
inflate.c
inflate.h
inftrees.c
inftrees.h
trees.c
trees.h
uncompr.c
zconf.h
zlib.h
zutil.c
zutil.h
)
add_library(zlib EXCLUDE_FROM_ALL OBJECT ${ZLIB_SRC})
set(ZLIB_INCLUDEDIR ${ZLIB_SRC_DIR})
target_include_directories(zlib PRIVATE ${ZLIB_INCLUDEDIR})
set(ZLIB_DEP $<TARGET_OBJECTS:zlib>)
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDEDIR})
set(ZLIB_LIBRARIES)
list(APPEND TARGETS_DEP zlib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_INCLUDEDIR)
endif()

View File

@ -0,0 +1,38 @@
set(WASM_CXX_ENGINE_FLAGS "")
set(WASM_ENGINE_FLAGS "")
set(WASM_ENGINE_FLAGS "-s LLD_REPORT_UNDEFINED -s USE_PTHREADS=1")
# needed for loading files in a c-like style
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s FILESYSTEM=1 -s FORCE_FILESYSTEM=1")
# load data directory to the filesystem
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} --preload-file data")
# remove some annoyance for now, TODO
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} --allow-multiple-definition -Wl,--shared-memory,--no-check-features")
# TODO
#set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -lwebsocket.js -s PROXY_POSIX_SOCKETS=1")
# use Web Assembly & a WebGL2 compatible GLES3 implementation
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s WASM=1")
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s USE_WEBGL2=1")
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s FULL_ES3=1")
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[\"$autoResumeAudioContext, $dynCall\"]")
# this flag is the most important one. It tells SDL2 to call emscripten functions when polling event
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s ASYNCIFY=1")
# TODO, has to be fixed in SDL2, can improve responsivness of the site
#set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s PROXY_TO_PTHREAD=1")
# SDL2 is compiled by the gen_libs.sh script for easy up to date code
#set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s USE_SDL=2")
#set(WASM_CXX_ENGINE_FLAGS "${WASM_CXX_ENGINE_FLAGS} -s USE_SDL=2")
# even if slower, memory growth has the advantage of using less resources, keep it on for now (instead of a static memory pool)
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
#set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s INITIAL_MEMORY=2000MB")
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s MAXIMUM_MEMORY=2000MB")
# not optimal but required so that threads are created on fly (instead of delayed when the next javascript calls come in)
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s PTHREAD_POOL_SIZE=10")
if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
# will drastically reduce code size
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -flto")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -D_REENTRANT -g -O3 ${WASM_CXX_ENGINE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -pthread -D_REENTRANT -g -O3 ${WASM_CXX_ENGINE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread ${WASM_ENGINE_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${WASM_ENGINE_FLAGS}")
set(CMAKE_RUST_COMPILER_TARGET wasm32-unknown-emscripten)

View File

@ -0,0 +1,19 @@
if(NOT DEFINED ENV{OSXCROSS_TARGET} OR NOT DEFINED ENV{OSXCROSS_SDK})
message(FATAL_ERROR "Run eval `osxcross-conf` before compilation")
endif()
set(CMAKE_OSX_SYSROOT $ENV{OSXCROSS_SDK} CACHE INTERNAL "")
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER oa64-clang)
set(CMAKE_CXX_COMPILER oa64-clang++)
set(CMAKE_INSTALL_NAME_TOOL aarch64-apple-$ENV{OSXCROSS_TARGET}-install_name_tool)
set(CMAKE_OTOOL aarch64-apple-$ENV{OSXCROSS_TARGET}-otool)
set(CMAKE_RUST_COMPILER_TARGET aarch64-apple-darwin)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,19 @@
if(NOT DEFINED ENV{OSXCROSS_TARGET} OR NOT DEFINED ENV{OSXCROSS_SDK})
message(FATAL_ERROR "Run eval `osxcross-conf` before compilation")
endif()
set(CMAKE_OSX_SYSROOT $ENV{OSXCROSS_SDK} CACHE INTERNAL "")
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER o64-clang)
set(CMAKE_CXX_COMPILER o64-clang++)
set(CMAKE_INSTALL_NAME_TOOL x86_64-apple-$ENV{OSXCROSS_TARGET}-install_name_tool)
set(CMAKE_OTOOL x86_64-apple-$ENV{OSXCROSS_TARGET}-otool)
set(CMAKE_RUST_COMPILER_TARGET x86_64-apple-darwin)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,11 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(CMAKE_RUST_COMPILER_TARGET i686-pc-windows-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,11 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_RUST_COMPILER_TARGET x86_64-pc-windows-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

1
codecov.yml Executable file
View File

@ -0,0 +1 @@
comment: false

BIN
data/arrow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@ -0,0 +1,3 @@
comfort:
Copyright louis
CC BY-SA 3.0 license (https://creativecommons.org/licenses/by-sa/3.0/)

BIN
data/assets/game/game_06.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/audio/foley_body_splat-01.wv Executable file

Binary file not shown.

BIN
data/audio/foley_body_splat-02.wv Executable file

Binary file not shown.

BIN
data/audio/foley_body_splat-03.wv Executable file

Binary file not shown.

BIN
data/audio/foley_body_splat-04.wv Executable file

Binary file not shown.

BIN
data/audio/foley_dbljump-01.wv Executable file

Binary file not shown.

BIN
data/audio/foley_dbljump-02.wv Executable file

Binary file not shown.

BIN
data/audio/foley_dbljump-03.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_left-01.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_left-02.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_left-03.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_left-04.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_right-01.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_right-02.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_right-03.wv Executable file

Binary file not shown.

BIN
data/audio/foley_foot_right-04.wv Executable file

Binary file not shown.

BIN
data/audio/foley_land-01.wv Executable file

Binary file not shown.

BIN
data/audio/foley_land-02.wv Executable file

Binary file not shown.

BIN
data/audio/foley_land-03.wv Executable file

Binary file not shown.

BIN
data/audio/foley_land-04.wv Executable file

Binary file not shown.

BIN
data/audio/hook_attach-01.wv Executable file

Binary file not shown.

BIN
data/audio/hook_attach-02.wv Executable file

Binary file not shown.

BIN
data/audio/hook_attach-03.wv Executable file

Binary file not shown.

BIN
data/audio/hook_loop-01.wv Executable file

Binary file not shown.

BIN
data/audio/hook_loop-02.wv Executable file

Binary file not shown.

BIN
data/audio/hook_noattach-01.wv Executable file

Binary file not shown.

BIN
data/audio/hook_noattach-02.wv Executable file

Binary file not shown.

BIN
data/audio/hook_noattach-03.wv Executable file

Binary file not shown.

BIN
data/audio/music_menu.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_ctf_cap_pl.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_ctf_drop.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_ctf_grab_en.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_ctf_grab_pl.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_ctf_rtn.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_hit_strong-01.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_hit_strong-02.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_hit_weak-01.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_hit_weak-02.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_hit_weak-03.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_msg-client.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_msg-highlight.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_msg-server.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_pickup_arm-01.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_pickup_arm-02.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_pickup_arm-03.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_pickup_arm-04.wv Executable file

Binary file not shown.

BIN
data/audio/sfx_pickup_gun.wv Executable file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More