ddnet/CMakeLists.txt

3421 lines
102 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.12...3.27.4)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE INTERNAL "Minimum macOS deployment version")
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
message(WARNING "Building for macOS < 10.15 is not supported")
2020-04-13 08:46:30 +00:00
endif()
file(STRINGS src/game/version.h VERSION_LINE
LIMIT_COUNT 1
REGEX "^#define GAME_RELEASE_VERSION "
)
if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"")
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})
elseif(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\"")
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH "0")
else()
message(FATAL_ERROR "Couldn't parse version from src/game/version.h")
endif()
if(VERSION_PATCH STREQUAL "0")
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
else()
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
endif()
set(ORIGINAL_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(ORIGINAL_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
set(ORIGINAL_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(OWN_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(TARGET_BITS "32")
else()
set(TARGET_BITS "64")
endif()
2021-08-24 11:21:29 +00:00
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
2021-08-24 10:18:20 +00:00
if(TARGET_BITS STREQUAL "32")
set(TARGET_CPU_ARCHITECTURE "arm")
else()
set(TARGET_CPU_ARCHITECTURE "arm64")
endif()
else()
if(TARGET_BITS STREQUAL "32")
set(TARGET_CPU_ARCHITECTURE "x86")
else()
set(TARGET_CPU_ARCHITECTURE "x86_64")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_OS "windows")
2022-03-25 08:26:37 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(TARGET_OS "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_OS "mac")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
set(TARGET_OS "haiku")
2021-08-24 10:18:20 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(TARGET_OS "android")
endif()
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
include(CheckLinkerFlag)
endif()
include(CheckSymbolExists)
2022-03-25 08:26:37 +00:00
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
include(CheckAtomic)
endif()
check_symbol_exists(__i386 "" TARGET_ARCH_X86_i386)
if(TARGET_ARCH_X86_i386)
set(TARGET_ARCH x86)
else()
set(TARGET_ARCH)
endif()
set(AUTO_DEPENDENCIES_DEFAULT OFF)
2022-03-20 17:04:00 +00:00
set(AUTO_VULKAN_BACKEND ON)
if(TARGET_OS STREQUAL "windows")
set(AUTO_DEPENDENCIES_DEFAULT ON)
2022-03-20 17:04:00 +00:00
if(TARGET_CPU_ARCHITECTURE STREQUAL "x86")
set(AUTO_VULKAN_BACKEND OFF)
endif()
elseif(TARGET_OS STREQUAL "mac")
set(AUTO_VULKAN_BACKEND OFF)
endif()
option(WEBSOCKETS "Enable websockets support" OFF)
option(MYSQL "Enable mysql support" OFF)
option(TEST_MYSQL "Test mysql support in unit tests (also sets -DMYSQL=ON)" OFF)
2020-09-17 19:11:28 +00:00
option(AUTOUPDATE "Enable the autoupdater" OFF)
option(INFORM_UPDATE "Inform about available updates" ON)
option(VIDEORECORDER "Enable video recording support via FFmpeg" ON)
2020-04-14 10:11:50 +00:00
option(UPNP "Enable UPnP support" OFF)
option(ANTIBOT "Enable support for a dynamic anticheat library (not provided, see src/antibot for interface if you want to implement your own)" OFF)
option(HEADLESS_CLIENT "Build the client without graphics" OFF)
option(CLIENT "Compile client" ON)
2021-08-24 10:18:20 +00:00
option(SERVER "Compile server" ON)
option(TOOLS "Compile tools" ON)
option(DOWNLOAD_GTEST "Download and compile GTest" ${AUTO_DEPENDENCIES_DEFAULT})
option(STEAM "Build the Steam release version" OFF)
option(DISCORD "Enable Discord rich presence support" OFF)
option(DISCORD_DYNAMIC "Enable discovering Discord rich presence libraries at runtime (Linux only)" OFF)
option(PREFER_BUNDLED_LIBS "Prefer bundled libraries over system libraries" ${AUTO_DEPENDENCIES_DEFAULT})
option(DEV "Don't generate stuff necessary for packaging" OFF)
2022-03-20 17:04:00 +00:00
option(VULKAN "Enable the vulkan backend" ${AUTO_VULKAN_BACKEND})
2022-02-18 09:46:05 +00:00
option(EXCEPTION_HANDLING "Enable exception handling (only works with Windows as of now)" OFF)
option(IPO "Enable interprocedural optimizations" OFF)
option(FUSE_LD "Linker to use" OFF)
option(SECURITY_COMPILER_FLAGS "Whether to set security-relevant compiler flags like -D_FORTIFY_SOURCE=2 and -fstack-protector-strong" ON)
2022-02-18 09:46:05 +00:00
2022-03-25 08:26:37 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
include(${PROJECT_SOURCE_DIR}/cmake/toolchains/Emscripten.toolchain)
endif()
if(TEST_MYSQL)
set(MYSQL ON)
endif()
# Set version if not explicitly set
if(NOT VERSION)
set(VERSION ${PROJECT_VERSION})
endif()
2019-05-11 10:00:21 +00:00
set(OpenGL_GL_PREFERENCE LEGACY)
# Set the default build type to Release
if(NOT(CMAKE_BUILD_TYPE))
if(NOT(DEV))
set(CMAKE_BUILD_TYPE Release)
else()
set(CMAKE_BUILD_TYPE Debug)
endif()
endif()
if(NOT(CMAKE_BUILD_TYPE MATCHES "^(Release|Debug|RelWithDebInfo|MinSizeRel)$"))
message(WARNING "Unknown CMAKE_BUILD_TYPE, should be one of Release, Debug, RelWithDebInfo or MinSizeRel")
endif()
set(DBG $<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>)
2017-09-21 13:11:09 +00:00
2022-05-07 09:23:29 +00:00
if(IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
if(ipo_supported)
message(STATUS "IPO is enabled")
set(ENABLE_IPO TRUE)
2022-05-07 09:23:29 +00:00
else()
message(WARNING "IPO is not supported: ${ipo_output}")
2022-05-07 09:23:29 +00:00
endif()
endif()
if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
# Remove version.h generated by previous build code
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/src/game/version.h)
endif()
2023-09-07 20:03:29 +00:00
set(SERVER_EXECUTABLE DDNet-Server CACHE STRING "Name of the built server executable")
set(CLIENT_EXECUTABLE DDNet CACHE STRING "Name of the build client executable")
########################################################################
# Compiler flags
########################################################################
function(add_c_compiler_flag_if_supported VARIABLE FLAG)
if(ARGC GREATER 2)
set(CHECKED_FLAG "${ARGV2}")
else()
set(CHECKED_FLAG "${FLAG}")
endif()
string(REGEX REPLACE "[^A-Za-z0-9]" "_" CONFIG_VARIABLE "FLAG_SUPPORTED${CHECKED_FLAG}")
check_c_compiler_flag("${CHECKED_FLAG}" ${CONFIG_VARIABLE})
if(${CONFIG_VARIABLE})
if(${VARIABLE})
set("${VARIABLE}" "${${VARIABLE}};${FLAG}" PARENT_SCOPE)
else()
set("${VARIABLE}" "${FLAG}" PARENT_SCOPE)
endif()
endif()
endfunction()
function(add_cxx_compiler_flag_if_supported VARIABLE FLAG)
if(ARGC GREATER 2)
set(CHECKED_FLAG "${ARGV2}")
else()
set(CHECKED_FLAG "${FLAG}")
endif()
string(REGEX REPLACE "[^A-Za-z0-9]" "_" CONFIG_VARIABLE "FLAG_SUPPORTED${CHECKED_FLAG}")
check_cxx_compiler_flag("${CHECKED_FLAG}" ${CONFIG_VARIABLE})
if(${CONFIG_VARIABLE})
if(${VARIABLE})
set("${VARIABLE}" "${${VARIABLE}};${FLAG}" PARENT_SCOPE)
else()
set("${VARIABLE}" "${FLAG}" PARENT_SCOPE)
endif()
endif()
endfunction()
function(add_linker_flag_if_supported VARIABLE FLAG)
if(ARGC GREATER 2)
set(CHECKED_FLAG "${ARGV2}")
else()
set(CHECKED_FLAG "${FLAG}")
endif()
string(REGEX REPLACE "[^A-Za-z0-9]" "_" CONFIG_VARIABLE "FLAG_SUPPORTED${CHECKED_FLAG}")
if(CMAKE_VERSION VERSION_LESS 3.18)
set(${CONFIG_VARIABLE} OFF)
else()
check_linker_flag(C "${CHECKED_FLAG}" ${CONFIG_VARIABLE})
endif()
if(${CONFIG_VARIABLE})
if(${VARIABLE})
set("${VARIABLE}" "${${VARIABLE}};${FLAG}" PARENT_SCOPE)
else()
set("${VARIABLE}" "${FLAG}" PARENT_SCOPE)
endif()
endif()
endfunction()
2019-04-10 20:37:58 +00:00
# Force compiler colors on when using ninja. Ninja filters the colors out when
# it's not printing to a terminal on its own.
if(CMAKE_GENERATOR STREQUAL "Ninja")
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fdiagnostics-color=always)
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fcolor-diagnostics)
2019-04-10 20:37:58 +00:00
endif()
if(NOT MSVC AND NOT HAIKU)
2023-01-09 16:58:46 +00:00
if(NOT TARGET_OS STREQUAL "mac")
if(NOT FUSE_LD STREQUAL OFF)
add_linker_flag_if_supported(OUR_FLAGS_LINK -fuse-ld=${FUSE_LD})
if(FLAG_SUPPORTED_fuse_ld_${FUSE_LD})
message(STATUS "Using ${FUSE_LD} linker")
endif()
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR NOT ENABLE_IPO)
# GCC+LTO: pthread_create has failed: Resource temporarily unavailable
add_linker_flag_if_supported(OUR_FLAGS_LINK -fuse-ld=mold)
if(FLAG_SUPPORTED_fuse_ld_mold)
message(STATUS "Using mold linker")
else()
# Does not support GCC+LTO
add_linker_flag_if_supported(OUR_FLAGS_LINK -fuse-ld=lld)
if(FLAG_SUPPORTED_fuse_ld_lld)
message(STATUS "Using lld linker")
else()
add_linker_flag_if_supported(OUR_FLAGS_LINK -fuse-ld=gold)
if(FLAG_SUPPORTED_fuse_ld_gold)
message(STATUS "Using gold linker")
endif()
endif()
endif()
else()
add_linker_flag_if_supported(OUR_FLAGS_LINK -fuse-ld=gold)
if(FLAG_SUPPORTED_fuse_ld_gold)
message(STATUS "Using gold linker")
endif()
endif()
endif()
endif()
if(TARGET_OS STREQUAL "mac")
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -std=gnu++17)
endif()
if(SECURITY_COMPILER_FLAGS)
# Protect the stack pointer.
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fstack-protector-strong)
if(MINGW)
add_linker_flag_if_supported(OUR_FLAGS_LINK -lssp)
endif()
endif()
# Disable exceptions as DDNet does not use them.
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fno-exceptions)
# Inaccurate floating point numbers cause problems on mingw-w64-gcc when
# compiling for x86, might cause problems elsewhere. So don't store floats
# in registers but keep them at higher accuracy.
if(TARGET_ARCH STREQUAL "x86")
add_cxx_compiler_flag_if_supported(OUR_FLAGS -ffloat-store)
endif()
# Don't insert timestamps into PEs to keep the build reproducible.
if(TARGET_OS STREQUAL "windows")
add_cxx_compiler_flag_if_supported(OUR_FLAGS_LINK -Wl,--no-insert-timestamp)
endif()
if(TARGET_OS STREQUAL "mac")
add_cxx_compiler_flag_if_supported(OUR_FLAGS -stdlib=libc++)
endif()
2022-02-18 09:46:05 +00:00
if(EXCEPTION_HANDLING)
add_cxx_compiler_flag_if_supported(OUR_FLAGS -DCONF_EXCEPTION_HANDLING)
2022-02-18 10:53:25 +00:00
# use the frame pointer (frame pointer usage is disabled by default in
# some architectures like x86_64 and for some optimization levels; and it
# may be impossible to walk the call stack without it)
add_cxx_compiler_flag_if_supported(OUR_FLAGS -fno-omit-frame-pointer)
2022-02-18 09:46:05 +00:00
endif()
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wall)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wextra)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-psabi) # parameter passing for argument of type __gnu_cxx::__normal_iterator<CCommandProcessorFragment_Vulkan::SMemoryBlock<1>*, std::vector<CCommandProcessorFragment_Vulkan::SMemoryBlock<1>, std::allocator<CCommandProcessorFragment_Vulkan::SMemoryBlock<1> > > > changed in GCC 7.1
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-unused-parameter)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-missing-field-initializers)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wformat=2) # Warn about format strings.
add_c_compiler_flag_if_supported(OUR_FLAGS_DEP -Wno-implicit-function-declaration)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-nullability-completeness) # Mac OS build on github
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-cond)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wduplicated-branches)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wlogical-op)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wrestrict)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wshadow-all) # clang
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wshadow=global) # gcc
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety-negative)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wsuggest-override)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wdynamic-class-memaccess) # clang
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wclass-memaccess) # gcc
add_linker_flag_if_supported(OUR_FLAGS_LINK -Wno-alloc-size-larger-than) # save.cpp with LTO
2022-10-25 16:51:56 +00:00
# add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wdouble-promotion) # Many occurrences
# add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wnull-dereference) # Many occurrences
# add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wuseless-cast) # TODO: Enable for C++ code except gtest
endif()
2022-02-18 09:46:05 +00:00
if(MSVC)
if(EXCEPTION_HANDLING)
add_cxx_compiler_flag_if_supported(OUR_FLAGS /DCONF_EXCEPTION_HANDLING)
2022-02-18 09:46:05 +00:00
endif()
endif()
if(NOT MSVC AND NOT HAIKU AND SECURITY_COMPILER_FLAGS)
check_c_compiler_flag("-O2;-Wp,-Werror;-D_FORTIFY_SOURCE=2" DEFINE_FORTIFY_SOURCE) # Some distributions define _FORTIFY_SOURCE by themselves.
endif()
########################################################################
# COMMON FUNCTIONS
########################################################################
function(set_glob VAR GLOBBING EXTS DIRECTORY) # ...
set(GLOBS)
foreach(ext ${EXTS})
list(APPEND GLOBS "${DIRECTORY}/*.${ext}")
endforeach()
file(${GLOBBING} GLOB_RESULT ${GLOBS})
list(SORT GLOB_RESULT)
set(FILES)
foreach(file ${ARGN})
list(APPEND FILES "${PROJECT_SOURCE_DIR}/${DIRECTORY}/${file}")
endforeach()
if(NOT FILES STREQUAL GLOB_RESULT)
message(AUTHOR_WARNING "${VAR} does not contain every file from directory ${DIRECTORY}")
set(LIST_BUT_NOT_GLOB)
foreach(file ${FILES})
if(NOT file IN_LIST GLOB_RESULT)
list(APPEND LIST_BUT_NOT_GLOB ${file})
endif()
endforeach()
if(LIST_BUT_NOT_GLOB)
message(AUTHOR_WARNING "Entries only present in ${VAR}: ${LIST_BUT_NOT_GLOB}")
endif()
set(GLOB_BUT_NOT_LIST)
foreach(file ${GLOB_RESULT})
if(NOT file IN_LIST FILES)
list(APPEND GLOB_BUT_NOT_LIST ${file})
endif()
endforeach()
if(GLOB_BUT_NOT_LIST)
message(AUTHOR_WARNING "Entries only present in ${DIRECTORY}: ${GLOB_BUT_NOT_LIST}")
endif()
if(NOT LIST_BUT_NOT_GLOB AND NOT GLOB_BUT_NOT_LIST)
message(AUTHOR_WARNING "${VAR} is not alphabetically sorted")
endif()
endif()
set(${VAR} ${FILES} PARENT_SCOPE)
endfunction()
function(set_src VAR GLOBBING DIRECTORY) # ...
set_glob(${VAR} ${GLOBBING} "c;cpp;h" ${DIRECTORY} ${ARGN})
set(${VAR} ${${VAR}} PARENT_SCOPE)
set(CHECKSUM_SRC ${CHECKSUM_SRC} ${${VAR}} PARENT_SCOPE)
endfunction()
set(CHECKSUM_SRC)
2020-08-20 10:17:44 +00:00
function(set_own_rpath TARGET)
if(NOT TARGET_OS STREQUAL "windows" AND NOT TARGET_OS STREQUAL "mac")
set_property(TARGET ${TARGET} PROPERTY BUILD_RPATH "$ORIGIN")
2020-08-20 10:17:44 +00:00
set_property(TARGET ${TARGET} PROPERTY INSTALL_RPATH "$ORIGIN/../lib/ddnet")
endif()
endfunction()
########################################################################
2018-07-10 09:29:02 +00:00
# INITIALIZE TARGET LISTS
########################################################################
set(TARGETS_OWN)
set(TARGETS_DEP)
set(TARGETS_LINK) # Targets with a linking stage.
########################################################################
# DEPENDENCIES
########################################################################
if((CMAKE_OSX_ARCHITECTURES STREQUAL "arm64;x86_64" OR CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64;arm64") AND TARGET_OS STREQUAL "mac")
set(FAT ON)
else()
set(FAT OFF)
endif()
if(FAT)
set(LIB_DIR "${TARGET_OS}/libfat")
2022-03-25 08:26:37 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(LIB_DIR "webasm/libwasm")
elseif(TARGET_CPU_ARCHITECTURE STREQUAL "arm" OR TARGET_CPU_ARCHITECTURE STREQUAL "arm64")
set(LIB_DIR "${TARGET_OS}/lib${TARGET_CPU_ARCHITECTURE}")
else()
set(LIB_DIR "${TARGET_OS}/lib${TARGET_BITS}")
endif()
function(set_extra_dirs_lib VARIABLE NAME)
set("PATHS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
set("HINTS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
if(PREFER_BUNDLED_LIBS)
set(TYPE HINTS)
else()
set(TYPE PATHS)
endif()
if(TARGET_BITS AND TARGET_OS)
set(DIR "ddnet-libs/${NAME}/${LIB_DIR}")
set("${TYPE}_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
set("EXTRA_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
endif()
endfunction()
function(set_extra_dirs_include VARIABLE NAME LIBRARY)
set("PATHS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
set("HINTS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
is_bundled(IS_BUNDLED "${LIBRARY}")
if(IS_BUNDLED)
2022-03-25 08:26:37 +00:00
set(TMP_TARGET_OS ${TARGET_OS})
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(TMP_TARGET_OS webasm)
endif()
set("HINTS_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" "ddnet-libs/${NAME}/include/${TMP_TARGET_OS}" PARENT_SCOPE)
endif()
endfunction()
if(CMAKE_CROSSCOMPILING)
2022-03-25 08:26:37 +00:00
if(TARGET_OS STREQUAL "android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
2021-08-24 10:18:20 +00:00
# be more aggressive with android toolchain
set(CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
set(CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PATH)
endif()
else()
set(CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH)
endif()
function(is_bundled VARIABLE PATH)
if(PATH)
string(FIND "${PATH}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_BITS AND TARGET_OS)
set("${VARIABLE}" ON PARENT_SCOPE)
else()
set("${VARIABLE}" OFF PARENT_SCOPE)
endif()
else()
set("${VARIABLE}" OFF PARENT_SCOPE)
endif()
endfunction()
if(NOT CMAKE_CROSSCOMPILING)
# Check for PkgConfig once so all the other `find_package` calls can do it
# quietly.
find_package(PkgConfig)
endif()
2021-08-24 10:18:20 +00:00
if(TARGET_OS STREQUAL "android")
find_package(Android)
endif()
find_package(ZLIB)
find_package(Crypto)
find_package(Curl)
if(CLIENT AND VIDEORECORDER)
2020-07-09 19:10:54 +00:00
find_package(FFMPEG)
endif()
2020-04-06 10:23:22 +00:00
find_package(Freetype)
if(DOWNLOAD_GTEST)
find_package(Git)
endif()
2021-08-24 10:18:20 +00:00
if(NOT(TARGET_OS STREQUAL "android"))
find_package(GLEW)
endif()
find_package(GTest)
2020-07-09 19:10:54 +00:00
if(UPNP)
find_package(Miniupnpc)
endif()
if(MYSQL)
find_package(MySQL)
else()
set(MYSQL_LIBRARIES)
endif()
find_package(Ogg)
find_package(Opus)
find_package(Opusfile)
find_package(PNG)
find_package(Python3)
find_package(Rust)
find_package(SDL2)
2020-07-07 17:29:44 +00:00
find_package(SQLite3)
2021-01-02 16:10:31 +00:00
if(DISCORD)
find_package(DiscordSdk)
endif()
if(UNIX)
# Use -pthread instead of -lpthread to draw dependencies other than libpthread
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads)
find_package(Wavpack)
if(WEBSOCKETS)
find_package(Websockets)
else()
set(WEBSOCKETS_LIBRARIES)
set(WEBSOCKETS_INCLUDE_DIRS)
endif()
2022-02-18 09:46:05 +00:00
if(EXCEPTION_HANDLING)
find_package(ExceptionHandling)
endif()
2023-07-28 12:28:22 +00:00
if(SECURITY_COMPILER_FLAGS)
find_package(SSP)
endif()
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
find_program(CMAKE_OTOOL otool)
find_program(DMGBUILD dmgbuild)
endif()
2022-03-20 17:04:00 +00:00
set(VULKAN_SHADER_FILE_LIST "" CACHE STRING "Vulkan shader file list")
set(VULKAN_SHADER_FILE_SHA256 "" CACHE STRING "Vulkan shader file hash")
if(CLIENT AND VULKAN)
2022-03-20 17:04:00 +00:00
find_package(Vulkan)
include(cmake/BuildVulkanShaders.cmake)
else()
set(VULKAN_LIBRARIES)
set(VULKAN_INCLUDE_DIRS)
endif()
message(STATUS "******** ${CMAKE_PROJECT_NAME} ********")
set(TARGET "Target OS: ${TARGET_OS} ${CMAKE_SYSTEM_PROCESSOR}")
if(TARGET_OS STREQUAL "mac")
set(TARGET "${TARGET} (SDK: ${CMAKE_OSX_SYSROOT}, architectures: ${CMAKE_OSX_ARCHITECTURES})")
2020-04-13 08:46:30 +00:00
endif()
message(STATUS ${TARGET})
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "Rust version: ${RUST_VERSION_STRING}")
2017-07-26 02:30:56 +00:00
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Dependencies:")
function(show_dependency_status OUTPUT_NAME NAME)
if(${NAME}_FOUND)
if(${NAME}_BUNDLED)
message(STATUS " * ${OUTPUT_NAME} not found (using bundled version)")
else()
message(STATUS " * ${OUTPUT_NAME} found")
endif()
else()
message(STATUS " * ${OUTPUT_NAME} not found")
endif()
endfunction()
show_dependency_status("Curl" CURL)
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
show_dependency_status("Dmg tools" DMGTOOLS)
endif()
if(CLIENT AND VIDEORECORDER)
2020-07-09 19:10:54 +00:00
show_dependency_status("FFmpeg" FFMPEG)
endif()
show_dependency_status("Freetype" FREETYPE)
if(DOWNLOAD_GTEST)
show_dependency_status("Git" GIT)
endif()
show_dependency_status("Glew" GLEW)
show_dependency_status("GTest" GTEST)
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
show_dependency_status("Dmgbuild" DMGBUILD)
endif()
2020-07-09 19:10:54 +00:00
if(UPNP)
show_dependency_status("Miniupnpc" MINIUPNPC)
endif()
if(MYSQL)
show_dependency_status("MySQL" MYSQL)
endif()
show_dependency_status("Ogg" OGG)
show_dependency_status("OpenSSL Crypto" CRYPTO)
show_dependency_status("Opus" OPUS)
show_dependency_status("Opusfile" OPUSFILE)
show_dependency_status("PNG" PNG)
show_dependency_status("Python3" Python3)
show_dependency_status("SDL2" SDL2)
2020-07-07 17:29:44 +00:00
show_dependency_status("SQLite3" SQLite3)
show_dependency_status("Wavpack" WAVPACK)
show_dependency_status("Zlib" ZLIB)
2021-01-02 16:10:31 +00:00
if(DISCORD)
show_dependency_status("DiscordSdk" DiscordSdk)
endif()
if(WEBSOCKETS)
show_dependency_status("Websockets" WEBSOCKETS)
endif()
if(CLIENT AND VULKAN)
2022-03-20 17:04:00 +00:00
show_dependency_status("Vulkan" VULKAN)
endif()
if(NOT(CURL_FOUND))
message(SEND_ERROR "You must install Curl to compile ${CMAKE_PROJECT_NAME}")
endif()
if(NOT(Python3_FOUND))
message(SEND_ERROR "You must install Python to compile ${CMAKE_PROJECT_NAME}")
endif()
if(NOT(RUST_FOUND))
message(SEND_ERROR "You must install Rust and Cargo to compile ${CMAKE_PROJECT_NAME}")
endif()
2020-07-07 17:29:44 +00:00
if(NOT(SQLite3_FOUND))
message(SEND_ERROR "You must install SQLite3 to compile ${CMAKE_PROJECT_NAME}")
2020-07-07 17:29:44 +00:00
endif()
if(MYSQL AND NOT(MYSQL_FOUND))
message(SEND_ERROR "You must install MySQL to compile the ${CMAKE_PROJECT_NAME} server with MySQL support")
endif()
if(WEBSOCKETS AND NOT(WEBSOCKETS_FOUND))
message(SEND_ERROR "You must install libwebsockets to compile the ${CMAKE_PROJECT_NAME} server with websocket support")
endif()
2020-04-14 10:11:50 +00:00
if(UPNP AND NOT(MINIUPNPC_FOUND))
message(SEND_ERROR "You must install miniupnpc to compile the ${CMAKE_PROJECT_NAME} server with UPnP support")
2020-04-14 10:11:50 +00:00
endif()
2021-01-02 16:10:31 +00:00
if(DISCORD AND NOT(DISCORDSDK_FOUND))
message(SEND_ERROR "You must install the Discord SDK to compile the ${CMAKE_PROJECT_NAME} client with Discord support")
2021-01-02 16:10:31 +00:00
endif()
if(DISCORD_DYNAMIC)
if(TARGET_OS STREQUAL "windows" OR TARGET_OS STREQUAL "mac")
message(SEND_ERROR "Dynamically loading the Discord SDK is only supported on Linux")
endif()
if(NOT DISCORD)
message(SEND_ERROR "You must enable the DISCORD flag if you want to link the Discord SDK")
endif()
endif()
if(NOT(PNG_FOUND))
2022-10-11 12:51:07 +00:00
message(SEND_ERROR "You must install libpng to compile ${CMAKE_PROJECT_NAME}")
endif()
if(CLIENT AND NOT(FREETYPE_FOUND))
message(SEND_ERROR "You must install Freetype to compile the ${CMAKE_PROJECT_NAME} client")
endif()
if(CLIENT AND NOT(OGG_FOUND))
message(SEND_ERROR "You must install Ogg to compile the ${CMAKE_PROJECT_NAME} client")
endif()
if(CLIENT AND NOT(OPUS_FOUND))
message(SEND_ERROR "You must install Opus to compile the ${CMAKE_PROJECT_NAME} client")
endif()
if(CLIENT AND NOT(OPUSFILE_FOUND))
message(SEND_ERROR "You must install Opusfile to compile the ${CMAKE_PROJECT_NAME} client")
endif()
if(CLIENT AND NOT(SDL2_FOUND))
message(SEND_ERROR "You must install SDL2 to compile the ${CMAKE_PROJECT_NAME} client")
endif()
2021-08-24 10:18:20 +00:00
if(TARGET_OS STREQUAL "android" AND CLIENT AND NOT(CRYPTO_FOUND))
message(SEND_ERROR "You must install OpenSSL to compile the ${CMAKE_PROJECT_NAME} client")
2021-08-24 10:18:20 +00:00
endif()
if(NOT(GTEST_FOUND))
if(DOWNLOAD_GTEST)
if(GIT_FOUND)
message(STATUS "Automatically downloading GTest to be able to run tests")
else()
set(DOWNLOAD_GTEST OFF)
message(WARNING "To automatically download GTest, you have to install Git")
endif()
else()
message(STATUS "To run the tests, you have to install GTest")
endif()
endif()
if(CLIENT AND VULKAN AND NOT(VULKAN_FOUND))
message(SEND_ERROR "You must install Vulkan libraries to compile the ${CMAKE_PROJECT_NAME} client")
2022-03-20 17:04:00 +00:00
endif()
if(TARGET_OS STREQUAL "windows")
2017-07-26 02:30:56 +00:00
set(PLATFORM_CLIENT)
Port line input and IME support from 0.7 Port the line input (UI edit boxes, chat, console) and Input Method Editor (IME) support from upstream. Closes #4397. General ------------------------------ Fix issues with the text input. Closes #4346. Closes #4524. Word skipping (when holding Ctrl) is overhauled to be consistent with the Windows / Firefox experience that I took as reference. Improve usability by not blinking (i.e. always rendering) the caret shortly after is has been moved. UI text input ------------------------------ Fix inconsistent mouse-based left and right scrolling (closes #4347). Support smooth left and right scrolling. Chat ------------------------------ Support keyboard-based text selection of the chat input. Mouse-based selection could be support in the future when we decide to add something like an ingame UI cursor. Support smooth up and down scrolling of the chat input, removing the old hack that offsets the input string to simulate scrolling. Console ------------------------------ Also support mouse-based text selection of the command input. Only text from either the command input or the console log can be selected at the same time. This ensures that Ctrl+C will always copy the text that is currently visually selected in the console. Check for Ctrl+C input event in event handler instead of in render function, to hopefully fix the issue that copying does not work sometimes (closes #5974 until further notice). When Ctrl+C is used to copy text from the console log, the selection is cleared. This should make it more clear when text was copied from the log. Fix an issue that was preventing the console log selection from being cleared, when all log lines are selected. Remove Ctrl+A/E hotkeys that move cursor to beginning/end respectively. Ctrl+A now selectes all text like for all other inputs. Home and End keys can still be used to go the beginning and end. Remove Ctrl+U/K hotkeys that clear everything before/after the cursor respectively. Hold shift and use Home/End to select everything instead. IME support ------------------------------ Render list of IME candidates in the client on Windows, so the candidate list can also be viewed in fullscreen mode. There is no API available to retrieve a candidate list on the other operating systems. Improve composition rendering by underlining the composition text instead of putting it in square brackets. Track active input globally to properly activate and deactivate IME through the SDL functions. Closes #1030. Closes #1008. Password rendering ------------------------------ Fix rendering of passwords containing unicode. Instead of rendering one star character for each UTF-8 `char`, render on star for every unicode codepoint. Show the composition text also for passwords. Without seeing the composition text it's hard to type a password containing those characters. The candidate window exposes the composition anyway. If you don't want to expose your password this way, e.g. while streaming, you could: 1. Use a latin password and switch off the IME for the password input with the IME hotkey. 2. Blank your screen with an external program while you are streaming and entering passwords. 3. Use binds to authenticate in rcon or to set the server browser password. Refactoring ------------------------------ Move all text input logic and general rendering to `CLineInput`. A `CLineInput` is associated with a particular `char` buffer given as a pointer either in the constructor or with `SetBuffer`. The maximum byte size of the buffer must also be specified. The maximum length in unicode codepoints can also be specified separately (e.g. on upstream, name are limited by the number of unicode codepoints instead). Add `CLineInputBuffered`, which is a `CLineInput` that own a `char` buffer of a fixed size, which is specified as a template argument. As `CLineInput` does not own a buffer anymore, this reduces duplicate code for line inputs that need their own buffer. Add `CLineInputNumber` which has additional convenience functions to consider the text as an `int` or `float`, to reduce duplicate code in those cases. In the future we could also add an input filter function so that only numbers can be entered in the number input. Add `CLineInput::SetClipboardLineCallback` to handle the case that multiple lines of text are pasted into a lineinput. This reduces duplicate code, as this behavior was previously implemented separately for chat and console. The behavior is also fixed to be consistent with the console on Windows, so the first line being pasted edits the current input text and then sends it instead of being sent on its own without the existing input text. Add `CalcFontSizeAndBoundingBox` to UI to reduce duplicate code. Expose `CalcAlignedCursorPos` as static member function to reuse it for line input. Dispatch input events to UI inputs through the event handler instead of storing them in a duplicate buffer. Use `size_t` for line input cursor position, length etc. and for `str_utf8_stats`. Add `IButtonColorFunction` to UI to describe a functions that defines colors for the Default, Active and Hovered states of UI elements. Add some default button color functions. Use button color function to reduce duplicate code in scrollbar rendering. Use `vec2` instead of two `floats` to represent the mouse positions in the text renderer. Remove `CaretPosition` again, as it does not calculate the correct Y position near line breaks due to the wrapping being different when not rendering the entire string. Instead, calculate the exact caret position when rending a text container and store the caret position in the text cursor for later use. IME usage guide (Windows) ------------------------------ 1. Install the respective language and the Microsoft-IME keyboard (e.g. for Chinese, Japanese or Korean). 2. Launch the game (or a text editor to first try out the IME). Note that Windows may track the input language separately for every application. You can change this in the Windows input settings so the input language is changed globally. 2. Switch the input language using the hotkey Windows+Space or another hotkey that you configured in the Windows input settings (Alt+Shift is the default, but you should consider disabling it, to avoid accidentally changing the input language while playing). 3. Switch from Latin/English input mode to the respective asian input mode. - Chinese: Use Ctrl+Space to switch between English and Chinese input mode. You can change this hotkey in the IME's settings. - Japanese: Use Ctrl+Space to switch between Alphanumeric and Hiragana/Katakana input mode. You can change this hotkey in the IME's settings. - Korean: Use Right Alt to switch between English and Hangul input mode. You cannot change this hotkey as of yet. - Note that the input mode is also tracked per application, but there is no setting to change this behavior as far as I know, so you'll need to switch for every application separately. 4. Start typing. The underlined text is the current composition text. While a composition is active, you can only edit the composition text. Confirm the composition with Space or by selecting a candidate from the candidate list with the arrow keys. Cancel the composition with Escape or by using Backspace to delete the composition text. Note that not all languages offer a candidate list. SDL version-specific issues ------------------------------ - 2.26.5, 2.24.2, 2.0.22: IME candidates work. But there are minor bugs when moving the composition cursor. - 2.0.18, 2.0.20: IME candidates work. - 2.0.16 (our current version): IME candidates cannot be determined with Windows API. Windows tries to draw the composition window like before, so this does not work in fullscreen mode. - 2.0.8 (upstream 0.7): IME candidates work. But this SDL version is too old for us.
2023-01-03 21:28:38 +00:00
set(PLATFORM_CLIENT_LIBS opengl32 winmm imm32)
set(PLATFORM_LIBS)
list(APPEND PLATFORM_LIBS shlwapi) # PathIsRelativeW
list(APPEND PLATFORM_LIBS version ws2_32) # Windows sockets
list(APPEND PLATFORM_LIBS bcrypt userenv) # for Rust (https://github.com/rust-lang/rust/issues/91974)
list(APPEND PLATFORM_LIBS ole32) # CoInitialize(Ex)
list(APPEND PLATFORM_LIBS shell32)
2023-06-10 11:57:19 +00:00
list(APPEND PLATFORM_LIBS ntdll) # https://github.com/ddnet/ddnet/issues/6725
2017-07-26 02:30:56 +00:00
elseif(TARGET_OS STREQUAL "mac")
find_library(CARBON Carbon)
find_library(COCOA Cocoa)
find_library(OPENGL OpenGL)
find_library(SECURITY Security)
2017-07-26 02:30:56 +00:00
set(PLATFORM_CLIENT
src/macos/client.mm
src/macos/notifications.mm
2017-07-26 02:30:56 +00:00
)
set(PLATFORM_CLIENT_LIBS ${COCOA} ${OPENGL})
set(PLATFORM_LIBS ${CARBON} ${SECURITY})
elseif(TARGET_OS STREQUAL "haiku")
set(PLATFORM_CLIENT)
find_package(OpenGL)
set(PLATFORM_LIBS GL network)
set(PLATFORM_CLIENT_LIBS ${OPENGL_gl_LIBRARY})
set(PLATFORM_CLIENT_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
2021-08-24 10:18:20 +00:00
elseif(TARGET_OS STREQUAL "android")
set(PLATFORM_CLIENT
src/android/android_main.cpp
)
set(PLATFORM_LIBS ${TW_ANDROID_LIBS})
set(PLATFORM_CLIENT_LIBS ${PLATFORM_LIBS})
set(PLATFORM_CLIENT_INCLUDE_DIRS)
else()
find_package(Notify)
find_package(OpenGL)
set(PLATFORM_CLIENT_LIBS ${OPENGL_gl_LIBRARY} ${NOTIFY_LIBRARIES})
set(PLATFORM_CLIENT_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR} ${NOTIFY_INCLUDE_DIRS})
set(PLATFORM_CLIENT)
if(TARGET_OS STREQUAL "linux")
set(PLATFORM_LIBS)
list(APPEND PLATFORM_LIBS rt) # clock_gettime for glibc < 2.17
list(APPEND PLATFORM_LIBS dl) # for Rust
else()
set(PLATFORM_LIBS)
endif()
endif()
2022-03-25 08:26:37 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(PLATFORM_CLIENT_LIBS GL)
set(PLATFORM_CLIENT_INCLUDE_DIRS "")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()
########################################################################
# DOWNLOAD GTEST
########################################################################
if(NOT(GTEST_FOUND) AND DOWNLOAD_GTEST)
set(DDNET_GTEST_VERSION v1.13.0)
configure_file(cmake/Download_GTest_CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
)
if(result)
message(WARNING "CMake step for googletest failed: ${result}")
set(DOWNLOAD_GTEST OFF)
else()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
)
if(result)
message(WARNING "Build step for googletest failed: ${result}")
set(DOWNLOAD_GTEST OFF)
else()
# Prevent overriding the parent project's compiler/linker settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines the gtest target.
add_subdirectory(
${PROJECT_BINARY_DIR}/googletest-src
${PROJECT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL
)
if(MSVC)
foreach(target gtest gmock)
set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded$<${DBG}:Debug>)
# `/w` disables all warnings. This is needed because `gtest` enables
# `/WX` (equivalent of `-Werror`) for some reason, breaking builds
# when MSVS adds new warnings.
target_compile_options(${target} PRIVATE /w)
endforeach()
endif()
set(GTEST_LIBRARIES gtest gmock)
set(GTEST_INCLUDE_DIRS)
endif()
endif()
endif()
########################################################################
# DEPENDENCY COMPILATION
########################################################################
set_src(DEP_JSON_SRC GLOB src/engine/external/json-parser json.c json.h)
add_library(json EXCLUDE_FROM_ALL OBJECT ${DEP_JSON_SRC})
set_src(DEP_MD5_SRC GLOB src/engine/external/md5 md5.c md5.h)
add_library(md5 EXCLUDE_FROM_ALL OBJECT ${DEP_MD5_SRC})
list(APPEND TARGETS_DEP json md5)
set(DEP_JSON $<TARGET_OBJECTS:json>)
set(DEP_MD5)
if(NOT CRYPTO_FOUND)
set(DEP_MD5 $<TARGET_OBJECTS:md5>)
endif()
2017-03-02 11:31:20 +00:00
########################################################################
# RUST
########################################################################
set_glob(RUST_BASE GLOB_RECURSE "rs;toml" src/base
Cargo.toml
color.rs
lib.rs
rust.rs
)
set_glob(RUST_ENGINE_INTERFACE GLOB "rs;toml" src/engine
Cargo.toml
console.rs
lib.rs
)
set_glob(RUST_ENGINE_SHARED GLOB_RECURSE "rs;toml" src/engine/shared
Cargo.toml
build.rs
config.rs
lib.rs
rust_version.rs
)
set_src(RUST_BRIDGE_SHARED GLOB_RECURSE src/rust-bridge
cpp/console.cpp
cpp/console.h
engine/shared/rust_version.cpp
engine/shared/rust_version.h
)
set_glob(RUST_MASTERSRV GLOB "rs;toml" src/mastersrv/src
addr.rs
locations.rs
main.rs
)
add_library(rust-bridge-shared EXCLUDE_FROM_ALL OBJECT ${RUST_BRIDGE_SHARED})
list(APPEND TARGETS_OWN rust-bridge-shared)
set(CARGO_BUILD_DIR "")
set(CARGO_BUILD ${CMAKE_COMMAND} -E env CARGO_TARGET_DIR=${PROJECT_BINARY_DIR} DDNET_TEST_NO_LINK=1 ${RUST_CARGO} build)
set(CARGO_TEST ${CMAKE_COMMAND} -E env CARGO_TARGET_DIR=${PROJECT_BINARY_DIR} ${RUST_CARGO} test)
if(MSVC)
list(INSERT CARGO_BUILD 0 ${CMAKE_COMMAND} -E env $<$<CONFIG:Debug>:CFLAGS=/MTd> $<$<CONFIG:Debug>:CXXFLAGS=/MTd>)
list(INSERT CARGO_TEST 0 ${CMAKE_COMMAND} -E env RUSTFLAGS=-Ctarget-feature=+crt-static)
endif()
if(RUST_NIGHTLY)
list(APPEND CARGO_BUILD -Z build-std=std,panic_abort)
endif()
if(NOT CMAKE_OSX_ARCHITECTURES AND (DEFINED CMAKE_RUST_COMPILER_TARGET OR RUST_NIGHTLY))
if(DEFINED CMAKE_RUST_COMPILER_TARGET)
list(APPEND CARGO_TEST --target ${CMAKE_RUST_COMPILER_TARGET})
set(RUST_TARGET ${CMAKE_RUST_COMPILER_TARGET})
else()
set(RUST_TARGET ${RUST_TARGET_HOST})
endif()
list(APPEND CARGO_BUILD --target ${RUST_TARGET})
set(CARGO_BUILD_DIR "${RUST_TARGET}/")
endif()
set(CARGO_BUILD_DIR_DEBUG "${CARGO_BUILD_DIR}debug")
set(CARGO_BUILD_DIR_RELEASE "${CARGO_BUILD_DIR}release")
if(GENERATOR_IS_MULTI_CONFIG)
if(CMAKE_VERSION VERSION_LESS 3.20)
message(SEND_ERROR "Multi-config generators only supported from CMake 3.20 and up")
else()
set(CARGO_BUILD_DIR "${CARGO_BUILD_DIR}$<$<CONFIG:Debug>:debug>$<$<NOT:$<CONFIG:Debug>>:release>")
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CARGO_BUILD_DIR "${CARGO_BUILD_DIR_DEBUG}")
else()
set(CARGO_BUILD_DIR "${CARGO_BUILD_DIR_RELEASE}")
endif()
endif()
list(APPEND CARGO_BUILD $<$<NOT:$<CONFIG:Debug>>:--release>)
if(CMAKE_OSX_ARCHITECTURES)
set(RUST_OSX_ARCHITECTURES)
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
if(${arch} STREQUAL arm64)
list(APPEND RUST_OSX_ARCHITECTURES aarch64-apple-darwin)
elseif(${arch} STREQUAL x86_64)
list(APPEND RUST_OSX_ARCHITECTURES x86_64-apple-darwin)
else()
message(SEND_ERROR "CMAKE_OSX_ARCHITECTURES' architecture ${arch} unknown, can't build Rust code (known: arm64, x86_64)")
endif()
endforeach()
endif()
set(RUST_SRC
${RUST_BASE}
${RUST_ENGINE_INTERFACE}
${RUST_ENGINE_SHARED}
Cargo.toml
Cargo.lock
)
set(RUST_TARGETS engine_shared)
if(NOT CMAKE_OSX_ARCHITECTURES)
set(RUST_OUTPUTS)
foreach(rust_target ${RUST_TARGETS})
set(LIBRARY_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}ddnet_${rust_target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
add_library(rust_${rust_target} STATIC IMPORTED GLOBAL)
add_custom_target(rust_${rust_target}_target DEPENDS "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}")
add_dependencies(rust_${rust_target} rust_${rust_target}_target)
set_target_properties(rust_${rust_target} PROPERTIES
IMPORTED_LOCATION "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR_RELEASE}/${LIBRARY_NAME}"
IMPORTED_LOCATION_DEBUG "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR_DEBUG}/${LIBRARY_NAME}"
)
list(APPEND RUST_OUTPUTS "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}")
endforeach()
add_custom_command(
OUTPUT ${RUST_OUTPUTS}
COMMAND ${CARGO_BUILD}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
USES_TERMINAL
DEPENDS ${RUST_SRC}
)
else()
foreach(rust_target ${RUST_TARGETS})
set(LIBRARY_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}ddnet_${rust_target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
add_library(rust_${rust_target} STATIC IMPORTED GLOBAL)
set_target_properties(rust_${rust_target} PROPERTIES
IMPORTED_LOCATION "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR_RELEASE}/${LIBRARY_NAME}"
IMPORTED_LOCATION_DEBUG "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR_DEBUG}/${LIBRARY_NAME}"
)
add_custom_target(rust_${rust_target}_target DEPENDS "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}")
add_dependencies(rust_${rust_target} rust_${rust_target}_target)
set(ARCH_LIBRARIES)
foreach(arch ${RUST_OSX_ARCHITECTURES})
list(APPEND ARCH_LIBRARIES "${PROJECT_BINARY_DIR}/${arch}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}")
endforeach()
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}"
COMMAND lipo ${ARCH_LIBRARIES} -create -output "${PROJECT_BINARY_DIR}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}"
DEPENDS ${ARCH_LIBRARIES}
)
endforeach()
foreach(arch ${RUST_OSX_ARCHITECTURES})
set(RUST_OUTPUTS)
foreach(rust_target ${RUST_TARGETS})
set(LIBRARY_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}ddnet_${rust_target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
list(APPEND RUST_OUTPUTS "${PROJECT_BINARY_DIR}/${arch}/${CARGO_BUILD_DIR}/${LIBRARY_NAME}")
endforeach()
add_custom_command(
OUTPUT ${RUST_OUTPUTS}
COMMAND ${CARGO_BUILD} --target=${arch}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
USES_TERMINAL
DEPENDS ${RUST_SRC}
)
endforeach()
endif()
########################################################################
# DATA
########################################################################
set(EXPECTED_DATA
arrow.png
2020-10-07 03:11:38 +00:00
assets/entities/comfort/ddnet.png
assets/entities/license.txt
assets/game/game_06.png
audio/foley_body_impact-01.wv
audio/foley_body_impact-02.wv
audio/foley_body_impact-03.wv
audio/foley_body_splat-01.wv
audio/foley_body_splat-02.wv
audio/foley_body_splat-03.wv
audio/foley_body_splat-04.wv
audio/foley_dbljump-01.wv
audio/foley_dbljump-02.wv
audio/foley_dbljump-03.wv
audio/foley_foot_left-01.wv
audio/foley_foot_left-02.wv
audio/foley_foot_left-03.wv
audio/foley_foot_left-04.wv
audio/foley_foot_right-01.wv
audio/foley_foot_right-02.wv
audio/foley_foot_right-03.wv
audio/foley_foot_right-04.wv
audio/foley_land-01.wv
audio/foley_land-02.wv
audio/foley_land-03.wv
audio/foley_land-04.wv
audio/hook_attach-01.wv
audio/hook_attach-02.wv
audio/hook_attach-03.wv
audio/hook_loop-01.wv
audio/hook_loop-02.wv
audio/hook_noattach-01.wv
audio/hook_noattach-02.wv
audio/hook_noattach-03.wv
audio/music_menu.wv
audio/sfx_ctf_cap_pl.wv
audio/sfx_ctf_drop.wv
audio/sfx_ctf_grab_en.wv
audio/sfx_ctf_grab_pl.wv
audio/sfx_ctf_rtn.wv
audio/sfx_hit_strong-01.wv
audio/sfx_hit_strong-02.wv
audio/sfx_hit_weak-01.wv
audio/sfx_hit_weak-02.wv
audio/sfx_hit_weak-03.wv
audio/sfx_msg-client.wv
audio/sfx_msg-highlight.wv
audio/sfx_msg-server.wv
audio/sfx_pickup_arm-01.wv
audio/sfx_pickup_arm-02.wv
audio/sfx_pickup_arm-03.wv
audio/sfx_pickup_arm-04.wv
audio/sfx_pickup_gun.wv
audio/sfx_pickup_hrt-01.wv
audio/sfx_pickup_hrt-02.wv
audio/sfx_pickup_launcher.wv
audio/sfx_pickup_ninja.wv
audio/sfx_pickup_sg.wv
audio/sfx_skid-01.wv
audio/sfx_skid-02.wv
audio/sfx_skid-03.wv
audio/sfx_skid-04.wv
audio/sfx_spawn_wpn-01.wv
audio/sfx_spawn_wpn-02.wv
audio/sfx_spawn_wpn-03.wv
audio/vo_teefault_cry-01.wv
audio/vo_teefault_cry-02.wv
audio/vo_teefault_ninja-01.wv
audio/vo_teefault_ninja-02.wv
audio/vo_teefault_ninja-03.wv
audio/vo_teefault_ninja-04.wv
audio/vo_teefault_pain_long-01.wv
audio/vo_teefault_pain_long-02.wv
audio/vo_teefault_pain_short-01.wv
audio/vo_teefault_pain_short-02.wv
audio/vo_teefault_pain_short-03.wv
audio/vo_teefault_pain_short-04.wv
audio/vo_teefault_pain_short-05.wv
audio/vo_teefault_pain_short-06.wv
audio/vo_teefault_pain_short-07.wv
audio/vo_teefault_pain_short-08.wv
audio/vo_teefault_pain_short-09.wv
audio/vo_teefault_pain_short-10.wv
audio/vo_teefault_pain_short-11.wv
audio/vo_teefault_pain_short-12.wv
audio/vo_teefault_sledge-01.wv
audio/vo_teefault_sledge-02.wv
audio/vo_teefault_sledge-03.wv
audio/vo_teefault_spawn-01.wv
audio/vo_teefault_spawn-02.wv
audio/vo_teefault_spawn-03.wv
audio/vo_teefault_spawn-04.wv
audio/vo_teefault_spawn-05.wv
audio/vo_teefault_spawn-06.wv
audio/vo_teefault_spawn-07.wv
audio/wp_flump_explo-01.wv
audio/wp_flump_explo-02.wv
audio/wp_flump_explo-03.wv
audio/wp_flump_launch-01.wv
audio/wp_flump_launch-02.wv
audio/wp_flump_launch-03.wv
audio/wp_gun_fire-01.wv
audio/wp_gun_fire-02.wv
audio/wp_gun_fire-03.wv
audio/wp_hammer_hit-01.wv
audio/wp_hammer_hit-02.wv
audio/wp_hammer_hit-03.wv
audio/wp_hammer_swing-01.wv
audio/wp_hammer_swing-02.wv
audio/wp_hammer_swing-03.wv
audio/wp_laser_bnce-01.wv
audio/wp_laser_bnce-02.wv
audio/wp_laser_bnce-03.wv
audio/wp_laser_fire-01.wv
audio/wp_laser_fire-02.wv
audio/wp_laser_fire-03.wv
audio/wp_ninja_attack-01.wv
audio/wp_ninja_attack-02.wv
audio/wp_ninja_attack-03.wv
audio/wp_ninja_attack-04.wv
audio/wp_ninja_hit-01.wv
audio/wp_ninja_hit-02.wv
audio/wp_ninja_hit-03.wv
audio/wp_ninja_hit-04.wv
audio/wp_noammo-01.wv
audio/wp_noammo-02.wv
audio/wp_noammo-03.wv
audio/wp_noammo-04.wv
audio/wp_noammo-05.wv
audio/wp_shotty_fire-01.wv
audio/wp_shotty_fire-02.wv
audio/wp_shotty_fire-03.wv
audio/wp_switch-01.wv
audio/wp_switch-02.wv
audio/wp_switch-03.wv
autoexec_server.cfg
blob.png
2020-09-18 15:37:27 +00:00
censorlist.txt
Add tabs for favorite communities, separate country/type filters Support adding up to three communities as favorites in the server browser. Favorites can be changed with favorite buttons which are shown in the community filter on the Internet and Favorites tabs. The commands `add_favorite_community` and `remove_favorite_community` are added to change the favorite communities via the console and for saving the favorite communities to the config file. For the favorite communities, additional tabs using the communities' icons are shown in the server browser next to the Internet, LAN and Favorites tabs. Each community tab shows only the servers from the respective community, hence the community filters UI is not shown on the community tabs but only on the Internet and Favorites tabs. The country and type filters on community tabs cover only the countries and types from the respective community. Favorite communities are added from left to right. When more than three favorite communities are added, the oldest (leftmost) favorite community will be removed from the list. When starting the client for the first time, i.e. with `cl_show_welcome 1`, the DDNet tab will be created as the only favorite community and selected initially. The community, country and type filters are unset when starting for the first time, so the Internet tab now shows all servers per default. When starting with a `ui_page` for a favorite community that is not configured, the page is reset to the Internet tab. This also affects those who upgrade from versions with the old DDNet and KoG tabs. The server browser is now also correctly updated when changing `ui_page` via the console. Track country and type filters for every community separately, to avoid filters resetting when switching between community tabs or changing the community filter. The commands `add_excluded_community`, `remove_excluded_community`, `add_excluded_country`, `remove_excluded_country`, `add_excluded_type` and `remove_excluded_type` are added to change the exclusion filters via the console and for saving the exclusion filters to the config file. Render community filters above the toolbox (filter, info and friends) tabs when on the Internet and Favorites tab, so this setting is more visible and can be changed also when the other toolbox tabs are selected. Add icon for the none community, based on the tee country flag color. This icon is hard-coded in the client, as the none community also is, so fetching the icon from the server would be inconvenient. Load community icons already when rendering the menu instead of only when rendering the server browser, so the icons are immediately available when using the start menu. Find tutorial server by searching for community type "Tutorial" instead of searching for "(Tutorial)" in the server name. Avoid cleaning favorite communities and filters when there are no communities, i.e. when the DDNet info failed to be loaded or does not contain any communities, to avoid losing all favorite communities and filters in this case. Closes #7774.
2024-01-21 10:06:25 +00:00
communityicons/none.png
console.png
console_bar.png
countryflags/AD.png
countryflags/AE.png
countryflags/AF.png
countryflags/AG.png
countryflags/AI.png
countryflags/AL.png
countryflags/AM.png
countryflags/AO.png
countryflags/AR.png
countryflags/AS.png
countryflags/AT.png
countryflags/AU.png
countryflags/AW.png
countryflags/AX.png
countryflags/AZ.png
countryflags/BA.png
countryflags/BB.png
countryflags/BD.png
countryflags/BE.png
countryflags/BF.png
countryflags/BG.png
countryflags/BH.png
countryflags/BI.png
countryflags/BJ.png
countryflags/BL.png
countryflags/BM.png
countryflags/BN.png
countryflags/BO.png
countryflags/BR.png
countryflags/BS.png
countryflags/BT.png
countryflags/BW.png
countryflags/BY.png
countryflags/BZ.png
countryflags/CA.png
countryflags/CC.png
countryflags/CD.png
countryflags/CF.png
countryflags/CG.png
countryflags/CH.png
countryflags/CI.png
countryflags/CK.png
countryflags/CL.png
countryflags/CM.png
countryflags/CN.png
countryflags/CO.png
countryflags/CR.png
countryflags/CU.png
countryflags/CV.png
countryflags/CW.png
countryflags/CX.png
countryflags/CY.png
countryflags/CZ.png
countryflags/DE.png
countryflags/DJ.png
countryflags/DK.png
countryflags/DM.png
countryflags/DO.png
countryflags/DZ.png
countryflags/EC.png
countryflags/EE.png
countryflags/EG.png
countryflags/EH.png
countryflags/ER.png
countryflags/ES-CT.png
countryflags/ES-GA.png
countryflags/ES.png
countryflags/ET.png
countryflags/EU.png
countryflags/FI.png
countryflags/FJ.png
countryflags/FK.png
countryflags/FM.png
countryflags/FO.png
countryflags/FR.png
countryflags/GA.png
countryflags/GB-ENG.png
countryflags/GB-NIR.png
countryflags/GB-SCT.png
countryflags/GB-WLS.png
countryflags/GB.png
countryflags/GD.png
countryflags/GE.png
countryflags/GF.png
countryflags/GG.png
countryflags/GH.png
countryflags/GI.png
countryflags/GL.png
countryflags/GM.png
countryflags/GN.png
countryflags/GP.png
countryflags/GQ.png
countryflags/GR.png
countryflags/GS.png
countryflags/GT.png
countryflags/GU.png
countryflags/GW.png
countryflags/GY.png
countryflags/HK.png
countryflags/HN.png
countryflags/HR.png
countryflags/HT.png
countryflags/HU.png
countryflags/ID.png
countryflags/IE.png
countryflags/IL.png
countryflags/IM.png
countryflags/IN.png
countryflags/IO.png
countryflags/IQ.png
countryflags/IR.png
countryflags/IS.png
countryflags/IT.png
countryflags/JE.png
countryflags/JM.png
countryflags/JO.png
countryflags/JP.png
countryflags/KE.png
countryflags/KG.png
countryflags/KH.png
countryflags/KI.png
countryflags/KM.png
countryflags/KN.png
countryflags/KP.png
countryflags/KR.png
countryflags/KW.png
countryflags/KY.png
countryflags/KZ.png
countryflags/LA.png
countryflags/LB.png
countryflags/LC.png
countryflags/LI.png
countryflags/LK.png
countryflags/LR.png
countryflags/LS.png
countryflags/LT.png
countryflags/LU.png
countryflags/LV.png
countryflags/LY.png
countryflags/MA.png
countryflags/MC.png
countryflags/MD.png
countryflags/ME.png
countryflags/MF.png
countryflags/MG.png
countryflags/MH.png
countryflags/MK.png
countryflags/ML.png
countryflags/MM.png
countryflags/MN.png
countryflags/MO.png
countryflags/MP.png
countryflags/MQ.png
countryflags/MR.png
countryflags/MS.png
countryflags/MT.png
countryflags/MU.png
countryflags/MV.png
countryflags/MW.png
countryflags/MX.png
countryflags/MY.png
countryflags/MZ.png
countryflags/NA.png
countryflags/NC.png
countryflags/NE.png
countryflags/NF.png
countryflags/NG.png
countryflags/NI.png
countryflags/NL.png
countryflags/NO.png
countryflags/NP.png
countryflags/NR.png
countryflags/NU.png
countryflags/NZ.png
countryflags/OM.png
countryflags/PA.png
countryflags/PE.png
countryflags/PF.png
countryflags/PG.png
countryflags/PH.png
countryflags/PK.png
countryflags/PL.png
countryflags/PM.png
countryflags/PN.png
countryflags/PR.png
countryflags/PS.png
countryflags/PT.png
countryflags/PW.png
countryflags/PY.png
countryflags/QA.png
countryflags/RE.png
countryflags/RO.png
countryflags/RS.png
countryflags/RU.png
countryflags/RW.png
countryflags/SA.png
countryflags/SB.png
countryflags/SC.png
countryflags/SD.png
countryflags/SE.png
countryflags/SG.png
countryflags/SH.png
countryflags/SI.png
countryflags/SK.png
countryflags/SL.png
countryflags/SM.png
countryflags/SN.png
countryflags/SO.png
countryflags/SR.png
countryflags/SS.png
countryflags/ST.png
countryflags/SV.png
countryflags/SX.png
countryflags/SY.png
countryflags/SZ.png
countryflags/TC.png
countryflags/TD.png
countryflags/TF.png
countryflags/TG.png
countryflags/TH.png
countryflags/TJ.png
countryflags/TK.png
countryflags/TL.png
countryflags/TM.png
countryflags/TN.png
countryflags/TO.png
countryflags/TR.png
countryflags/TT.png
countryflags/TV.png
countryflags/TW.png
countryflags/TZ.png
countryflags/UA.png
countryflags/UG.png
countryflags/US.png
countryflags/UY.png
countryflags/UZ.png
countryflags/VA.png
countryflags/VC.png
countryflags/VE.png
countryflags/VG.png
countryflags/VI.png
countryflags/VN.png
countryflags/VU.png
countryflags/WF.png
countryflags/WS.png
countryflags/YE.png
countryflags/ZA.png
countryflags/ZM.png
countryflags/ZW.png
countryflags/default.png
countryflags/index.txt
debug_font.png
editor/audio_source.png
editor/automap/basic_freeze.rules
editor/automap/ddmax_freeze.rules
editor/automap/ddnet_tiles.rules
editor/automap/ddnet_walls.rules
editor/automap/desert_main.rules
editor/automap/fadeout.rules
editor/automap/generic_clear.rules
editor/automap/generic_unhookable.rules
editor/automap/generic_unhookable_0.7.rules
editor/automap/grass_main.rules
editor/automap/grass_main_0.7.rules
editor/automap/jungle_main.rules
editor/automap/jungle_midground.rules
editor/automap/round_tiles.rules
editor/automap/water.rules
editor/automap/winter_main.rules
editor/background.png
editor/checker.png
editor/cursor.png
editor/cursor_resize.png
editor/entities/DDNet.png
editor/entities/FNG.png
editor/entities/Race.png
editor/entities/Vanilla.png
editor/entities/blockworlds.png
editor/entities_clear/blockworlds.png
editor/entities_clear/ddnet.png
editor/entities_clear/ddrace.png
2020-12-21 15:45:19 +00:00
editor/entities_clear/f-ddrace.png
editor/entities_clear/fng.png
editor/entities_clear/race.png
editor/entities_clear/vanilla.png
editor/front.png
editor/speed_arrow.png
editor/speed_arrow_array.png
editor/speedup.png
editor/switch.png
editor/tele.png
editor/tune.png
emoticons.png
2022-06-14 17:28:51 +00:00
extras.png
2020-08-20 09:21:45 +00:00
fonts/DejaVuSans.ttf
Add font index, support font family variants depending on language Add `fonts/index.json` which specifies: - List of all font files that should be loaded (filenames). - Default font (specified by family name or by family and style name). - Font variants for different languages, using the name of the language file as key. - Fallback fonts. - Icon font. There are characters (e.g. all in `刃直海角骨入`) that look different depending on the language of the content being Japanese, Simplified Chinese, Traditional Chinese and Hangul, because Unicode uses the same codepoint for characters regardless of the language. To render these characters correctly, the active variant font is switched depending on the selected language. The `ITextRender` interface is changed so the current language variant can be set using `SetFontLanguageVariant` and the default and icon fonts can be toggled using `SetFontPreset`. The class `CFont` is removed entirely. The text render is restructured: The font faces and font atlas are now managed by a separate class `CGlyphMap` like on upstream. As the text fill and outline textures always have the same size, the texture skyline only needs to be stored once and free positions in the atlas only need to be calculated once for each glyph instead of separately for the fill and outline textures. The font files and their licenses are also updated: - Update Source Han Sans to version 2.001. - Update Glow Sans Japanese Compressed to version 0.93. - Update Deja Vu Sans to version 2.37. - Update Font Awesome icons font to March 2023 version. Closes #6881.
2023-07-17 13:49:41 +00:00
fonts/Font_Awesome_6_Free-Solid-900.otf
fonts/GlowSansJ-Compressed-Book.otf
fonts/SourceHanSans.ttc
fonts/index.json
game.png
gui_buttons.png
gui_cursor.png
gui_icons.png
gui_logo.png
hud.png
2021-01-31 08:33:01 +00:00
languages/arabic.txt
languages/belarusian.txt
languages/bosnian.txt
languages/brazilian_portuguese.txt
languages/bulgarian.txt
languages/catalan.txt
languages/chuvash.txt
languages/czech.txt
languages/danish.txt
languages/dutch.txt
2022-07-19 19:21:38 +00:00
languages/esperanto.txt
languages/finnish.txt
languages/french.txt
languages/galician.txt
languages/german.txt
languages/greek.txt
languages/hungarian.txt
languages/index.txt
languages/italian.txt
languages/japanese.txt
languages/korean.txt
languages/kyrgyz.txt
languages/license.txt
languages/norwegian.txt
languages/persian.txt
languages/polish.txt
languages/portuguese.txt
languages/romanian.txt
languages/russian.txt
languages/serbian.txt
2020-10-03 21:50:27 +00:00
languages/serbian_cyrillic.txt
languages/simplified_chinese.txt
languages/slovak.txt
languages/spanish.txt
languages/swedish.txt
languages/traditional_chinese.txt
languages/turkish.txt
languages/ukrainian.txt
mapres/basic_freeze.png
mapres/bg_cloud1.png
mapres/bg_cloud2.png
mapres/bg_cloud3.png
mapres/ddmax_freeze.png
mapres/ddnet_start.png
mapres/ddnet_tiles.png
mapres/ddnet_walls.png
mapres/desert_background.png
mapres/desert_doodads.png
mapres/desert_main.png
mapres/desert_mountains.png
mapres/desert_mountains2.png
mapres/desert_mountains_new_background.png
mapres/desert_mountains_new_foreground.png
mapres/desert_sun.png
mapres/entities.png
mapres/fadeout.png
mapres/font_teeworlds.png
mapres/font_teeworlds_alt.png
mapres/generic_clear.png
mapres/generic_deathtiles.png
mapres/generic_lamps.png
mapres/generic_unhookable.png
mapres/generic_unhookable_0.7.png
mapres/grass_doodads.png
mapres/grass_doodads_0.7.png
mapres/grass_main.png
mapres/grass_main_0.7.png
mapres/jungle_background.png
mapres/jungle_deathtiles.png
mapres/jungle_doodads.png
mapres/jungle_main.png
mapres/jungle_midground.png
mapres/jungle_unhookables.png
mapres/light.png
mapres/mixed_tiles.png
mapres/moon.png
mapres/mountains.png
mapres/round_tiles.png
mapres/snow.png
mapres/snow_mountain.png
mapres/stars.png
mapres/sun.png
mapres/water.png
mapres/winter_doodads.png
mapres/winter_main.png
mapres/winter_mountains.png
mapres/winter_mountains2.png
mapres/winter_mountains3.png
maps/Gold\ Mine.map
maps/LearnToPlay.map
maps/Sunny\ Side\ Up.map
maps/Tsunami.map
maps/Tutorial.map
maps/coverage.map
maps/ctf1.map
maps/ctf2.map
maps/ctf3.map
maps/ctf4.map
maps/ctf5.map
maps/ctf6.map
maps/ctf7.map
maps/dm1.map
maps/dm2.map
maps/dm6.map
maps/dm7.map
maps/dm8.map
maps/dm9.map
maps/license.txt
maps7/Gold\ Mine.map
maps7/LearnToPlay.map
maps7/Sunny\ Side\ Up.map
maps7/Tsunami.map
maps7/Tutorial.map
maps7/readme.txt
menuimages/demos.png
menuimages/editor.png
menuimages/local_server.png
menuimages/play_game.png
menuimages/settings.png
particles.png
2023-11-20 11:23:56 +00:00
race_flag.png
shader/pipeline.frag
shader/pipeline.vert
shader/prim.frag
shader/prim.vert
shader/primex.frag
shader/primex.vert
shader/quad.frag
shader/quad.vert
shader/spritemulti.frag
shader/spritemulti.vert
shader/text.frag
shader/text.vert
shader/tile.frag
shader/tile.vert
shader/tile_border.frag
shader/tile_border.vert
2022-03-20 17:04:00 +00:00
shader/vulkan/prim.frag
shader/vulkan/prim.vert
shader/vulkan/prim3d.frag
shader/vulkan/prim3d.vert
shader/vulkan/primex.frag
shader/vulkan/primex.vert
shader/vulkan/quad.frag
shader/vulkan/quad.vert
shader/vulkan/spritemulti.frag
shader/vulkan/spritemulti.vert
shader/vulkan/text.frag
shader/vulkan/text.vert
shader/vulkan/tile.frag
shader/vulkan/tile.vert
shader/vulkan/tile_border.frag
shader/vulkan/tile_border.vert
skins/PaladiN.png
skins/antiantey.png
skins/beast.png
skins/blacktee.png
skins/bluekitty.png
skins/bluestripe.png
skins/bomb.png
skins/brownbear.png
skins/cammo.png
skins/cammostripes.png
skins/chinese_by_whis.png
skins/coala.png
skins/coala_bluekitty.png
skins/coala_bluestripe.png
skins/coala_cammo.png
skins/coala_cammostripes.png
skins/coala_default.png
skins/coala_limekitty.png
skins/coala_pinky.png
skins/coala_redbopp.png
skins/coala_redstripe.png
skins/coala_saddo.png
skins/coala_toptri.png
skins/coala_twinbop.png
skins/coala_twintri.png
skins/coala_warpaint.png
skins/coala_x_ninja.png
skins/default.png
skins/demonlimekitty.png
skins/dino.png
skins/dragon.png
skins/evil.png
skins/evilwolfe.png
skins/ghost.png
skins/ghostjtj.png
skins/giraffe.png
skins/greensward.png
skins/greyfox.png
skins/greyfox_2.png
skins/hammie-chew.png
skins/hammie-whis.png
skins/jeet.png
skins/kintaro_2.png
skins/kitty_bluestripe.png
skins/kitty_brownbear.png
skins/kitty_cammo.png
skins/kitty_cammostripes.png
skins/kitty_coala.png
skins/kitty_default.png
skins/kitty_pinky.png
skins/kitty_redbopp.png
skins/kitty_redstripe.png
skins/kitty_saddo.png
skins/kitty_toptri.png
skins/kitty_twinbop.png
skins/kitty_twintri.png
skins/kitty_warpaint.png
skins/kitty_x_ninja.png
skins/license.txt
skins/limekitty.png
skins/mermydon-coala.png
skins/mermydon.png
skins/mouse.png
skins/musmann.png
skins/nanami.png
skins/nanas.png
skins/nersif.png
skins/oldman.png
skins/oldschool.png
skins/penguin.png
skins/pinky.png
skins/random.png
skins/redbopp.png
skins/redstripe.png
skins/saddo.png
skins/santa_bluekitty.png
skins/santa_bluestripe.png
skins/santa_brownbear.png
skins/santa_cammo.png
skins/santa_cammostripes.png
skins/santa_coala.png
skins/santa_default.png
skins/santa_limekitty.png
skins/santa_pinky.png
skins/santa_redbopp.png
skins/santa_redstripe.png
skins/santa_saddo.png
skins/santa_toptri.png
skins/santa_twinbop.png
skins/santa_twintri.png
skins/santa_warpaint.png
skins/teerasta.png
skins/toptri.png
skins/twinbop.png
skins/twintri.png
skins/veteran.png
skins/voodoo_tee.png
skins/warpaint.png
skins/wartee.png
skins/whis.png
skins/x_ninja.png
skins/x_spec.png
2021-08-14 13:40:58 +00:00
strong_weak.png
2020-09-18 16:45:42 +00:00
themes/auto.png
themes/autumn.png
themes/autumn_day.map
themes/autumn_night.map
2020-09-18 16:45:42 +00:00
themes/heavens.png
themes/heavens_day.map
themes/heavens_night.map
themes/jungle.png
themes/jungle_day.map
themes/jungle_night.map
themes/newyear.map
themes/newyear.png
2020-09-18 16:45:42 +00:00
themes/none.png
themes/rand.png
themes/winter.png
themes/winter_day.map
themes/winter_night.map
wordlist.txt
)
Add font index, support font family variants depending on language Add `fonts/index.json` which specifies: - List of all font files that should be loaded (filenames). - Default font (specified by family name or by family and style name). - Font variants for different languages, using the name of the language file as key. - Fallback fonts. - Icon font. There are characters (e.g. all in `刃直海角骨入`) that look different depending on the language of the content being Japanese, Simplified Chinese, Traditional Chinese and Hangul, because Unicode uses the same codepoint for characters regardless of the language. To render these characters correctly, the active variant font is switched depending on the selected language. The `ITextRender` interface is changed so the current language variant can be set using `SetFontLanguageVariant` and the default and icon fonts can be toggled using `SetFontPreset`. The class `CFont` is removed entirely. The text render is restructured: The font faces and font atlas are now managed by a separate class `CGlyphMap` like on upstream. As the text fill and outline textures always have the same size, the texture skyline only needs to be stored once and free positions in the atlas only need to be calculated once for each glyph instead of separately for the fill and outline textures. The font files and their licenses are also updated: - Update Source Han Sans to version 2.001. - Update Glow Sans Japanese Compressed to version 0.93. - Update Deja Vu Sans to version 2.37. - Update Font Awesome icons font to March 2023 version. Closes #6881.
2023-07-17 13:49:41 +00:00
set_glob(DATA GLOB_RECURSE "cfg;frag;json;map;otf;png;rules;ttc;ttf;txt;vert;wv" data ${EXPECTED_DATA})
########################################################################
# COPY DATA AND SHARED LIBS
########################################################################
foreach(datafile ${DATA})
file(RELATIVE_PATH OUT ${PROJECT_SOURCE_DIR}/data ${datafile})
get_filename_component(DESTINATION data/${OUT} PATH)
file(MAKE_DIRECTORY ${DESTINATION})
file(COPY ${datafile} DESTINATION ${DESTINATION})
endforeach()
set(INTEGRATION_TEST_COPY_FILES
lsan.supp
memcheck.supp
ubsan.supp
valgrind.supp
scripts/integration_test.sh
)
set(COPY_FILES
${CURL_COPY_FILES}
${FREETYPE_COPY_FILES}
${OPUSFILE_COPY_FILES}
${PNG_COPY_FILES}
${SDL2_COPY_FILES}
2020-08-10 21:43:10 +00:00
${SQLite3_COPY_FILES}
2017-10-26 22:42:33 +00:00
${FFMPEG_COPY_FILES}
${WEBSOCKETS_COPY_FILES}
2021-01-02 16:10:31 +00:00
${DISCORDSDK_COPY_FILES}
2022-03-20 17:04:00 +00:00
${VULKAN_COPY_FILES}
2022-02-18 09:46:05 +00:00
${EXCEPTION_HANDLING_COPY_FILES}
2023-07-28 12:28:22 +00:00
${SSP_COPY_FILES}
)
file(COPY ${COPY_FILES} DESTINATION .)
2022-11-04 14:09:01 +00:00
# Don't add integration test files to COPY_FILES since we don't want to add
# them in cpack.
file(COPY ${INTEGRATION_TEST_COPY_FILES} DESTINATION .)
set(COPY_DIRS ${SDL2_COPY_DIRS})
file(COPY ${COPY_DIRS} DESTINATION .)
########################################################################
# CODE GENERATION
########################################################################
function(generate_source output_file script_parameter)
add_custom_command(OUTPUT ${output_file}
COMMAND ${Python3_EXECUTABLE} datasrc/compile.py ${script_parameter}
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
datasrc/compile.py
datasrc/content.py
datasrc/datatypes.py
datasrc/network.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endfunction()
2020-04-16 08:46:43 +00:00
function(generate_source7 output_file script_parameter)
add_custom_command(OUTPUT ${output_file}
COMMAND ${Python3_EXECUTABLE} -m datasrc.seven.compile ${script_parameter}
2020-04-16 08:46:43 +00:00
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
datasrc/seven/compile.py
datasrc/seven/content.py
datasrc/seven/datatypes.py
datasrc/seven/network.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endfunction()
2022-04-03 00:20:53 +00:00
function(generate_maps output_file script_parameter)
2020-04-16 08:46:43 +00:00
add_custom_command(OUTPUT ${output_file}
COMMAND ${Python3_EXECUTABLE} datasrc/crosscompile.py ${script_parameter}
2020-04-16 08:46:43 +00:00
> "${PROJECT_BINARY_DIR}/${output_file}"
DEPENDS
2022-04-03 00:20:53 +00:00
datasrc/crosscompile.py
2020-04-16 08:46:43 +00:00
datasrc/compile.py
datasrc/content.py
datasrc/datatypes.py
datasrc/network.py
datasrc/seven/compile.py
datasrc/seven/content.py
datasrc/seven/datatypes.py
datasrc/seven/network.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endfunction()
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/game/generated/")
execute_process(COMMAND git rev-parse --git-dir
ERROR_QUIET
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE PROJECT_GIT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE PROJECT_GIT_DIR_ERROR
)
if(NOT PROJECT_GIT_DIR_ERROR)
set(GIT_REVISION_EXTRA_DEPS
${PROJECT_GIT_DIR}/index
${PROJECT_GIT_DIR}/logs/HEAD
)
endif()
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src/game/generated/git_revision.cpp
COMMAND ${Python3_EXECUTABLE}
scripts/git_revision.py
> ${PROJECT_BINARY_DIR}/src/game/generated/git_revision.cpp
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS
${GIT_REVISION_EXTRA_DEPS}
scripts/git_revision.py
)
generate_source("src/game/generated/client_data.cpp" "client_content_source")
generate_source("src/game/generated/client_data.h" "client_content_header")
generate_source("src/game/generated/data_types.h" "content_types_header")
generate_source("src/game/generated/protocol.cpp" "network_source")
generate_source("src/game/generated/protocol.h" "network_header")
generate_source("src/game/generated/server_data.cpp" "server_content_source")
generate_source("src/game/generated/server_data.h" "server_content_header")
2020-04-16 08:46:43 +00:00
generate_source7("src/game/generated/protocol7.cpp" "network_source")
generate_source7("src/game/generated/protocol7.h" "network_header")
generate_source7("src/game/generated/client_data7.cpp" "client_content_source")
generate_source7("src/game/generated/client_data7.h" "client_content_header")
2020-04-16 08:46:43 +00:00
2022-04-03 00:20:53 +00:00
generate_maps("src/game/generated/protocolglue.h" "map_header")
generate_maps("src/game/generated/protocolglue.cpp" "map_source")
add_custom_command(OUTPUT "src/game/generated/wordlist.h"
COMMAND ${Python3_EXECUTABLE} scripts/wordlist.py > ${PROJECT_BINARY_DIR}/src/game/generated/wordlist.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS
scripts/wordlist.py
)
########################################################################
# SHARED
########################################################################
# Sources
set_src(BASE GLOB_RECURSE src/base
bezier.cpp
bezier.h
color.cpp
color.h
detect.h
2020-08-20 10:17:44 +00:00
dynamic.h
2021-06-15 01:24:23 +00:00
hash.cpp
hash.h
2021-06-15 01:24:23 +00:00
hash_bundled.cpp
hash_ctxt.h
2021-06-15 01:24:23 +00:00
hash_libtomcrypt.cpp
hash_openssl.cpp
lock.h
log.cpp
log.h
logger.h
math.h
rust.h
2021-06-15 01:24:23 +00:00
system.cpp
system.h
tl/threading.h
types.h
2021-06-15 01:24:23 +00:00
unicode/confusables.cpp
unicode/confusables.h
unicode/confusables_data.h
2021-06-15 01:24:23 +00:00
unicode/tolower.cpp
unicode/tolower.h
unicode/tolower_data.h
vmath.h
)
set_src(ENGINE_INTERFACE GLOB src/engine
antibot.h
client.h
config.h
console.h
demo.h
discord.h
editor.h
engine.h
favorites.h
friends.h
ghost.h
graphics.h
2023-12-18 19:01:26 +00:00
http.h
input.h
kernel.h
keys.h
map.h
message.h
notifications.h
rust.h
server.h
serverbrowser.h
sound.h
2021-04-21 11:21:25 +00:00
sqlite.h
2020-08-20 10:17:44 +00:00
steam.h
storage.h
textrender.h
updater.h
uuid.h
warning.h
)
2022-03-12 12:01:19 +00:00
set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
2022-03-02 13:28:37 +00:00
assertion_logger.cpp
assertion_logger.h
compression.cpp
compression.h
config.cpp
config.h
config_variables.h
console.cpp
console.h
csv.cpp
csv.h
datafile.cpp
datafile.h
demo.cpp
demo.h
econ.cpp
econ.h
engine.cpp
fifo.cpp
fifo.h
filecollection.cpp
filecollection.h
global_uuid_manager.cpp
host_lookup.cpp
host_lookup.h
http.cpp
http.h
huffman.cpp
huffman.h
jobs.cpp
jobs.h
2018-12-12 08:59:42 +00:00
json.cpp
json.h
jsonwriter.cpp
jsonwriter.h
kernel.cpp
linereader.cpp
linereader.h
2022-12-09 15:15:19 +00:00
localization.h
map.cpp
2020-09-18 16:45:42 +00:00
map.h
masterserver.cpp
Add HTTP masterserver registering and HTTP masterserver Registering ----------- The idea is that game servers push their server info to the masterservers every 15 seconds or when the server info changes, but not more than once per second. The game servers do not support the old registering protocol anymore, the backward compatibility is handled by the masterserver. The register call is a HTTP POST to a URL like `https://master1.ddnet.tw/ddnet/15/register` and looks like this: ```json POST /ddnet/15/register HTTP/1.1 Address: tw-0.6+udp://connecting-address.invalid:8303 Secret: 81fa3955-6f83-4290-818d-31c0906b1118 Challenge-Secret: 81fa3955-6f83-4290-818d-31c0906b1118:tw0.6/ipv6 Info-Serial: 0 { "max_clients": 64, "max_players": 64, "passworded": false, "game_type": "TestDDraceNetwork", "name": "My DDNet server", "map": { "name": "dm1", "sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf", "size": 5805 }, "version": "0.6.4, 16.0.3", "clients": [] } ``` The `Address` header declares that the server wants to register itself as a `tw-0.6+udp` server, i.e. a server speaking a Teeworlds-0.6-compatible protocol. The free-form `Secret` header is used as a server identity, the server list will be deduplicated via this secret. The free-form `Challenge-Secret` is sent back via UDP for a port forward check. This might have security implications as the masterserver can be asked to send a UDP packet containing some user-controlled bytes. This is somewhat mitigated by the fact that it can only go to an attacker-controlled IP address. The `Info-Serial` header is an integer field that should increase each time the server info (in the body) changes. The masterserver uses that field to ensure that it doesn't use old server infos. The body is a free-form JSON object set by the game server. It should contain certain keys in the correct form to be accepted by clients. The body is optional if the masterserver already confirmed the reception of the info with the given `Info-Serial`. Not shown in this payload is the `Connless-Token` header that is used for Teeworlds 0.7 style communication. Also not shown is the `Challenge-Token` that should be included once the server receives the challenge token via UDP. The masterserver responds with a `200 OK` with a body like this: ``` {"status":"success"} ``` The `status` field can be `success` if the server was successfully registered on the masterserver, `need_challenge` if the masterserver wants the correct `Challenge-Token` header before the register process is successful, `need_info` if the server sent an empty body but the masterserver doesn't actually know the server info. It can also be `error` if the request was malformed, only in this case an HTTP status code except `200 OK` is sent. Synchronization --------------- The masterserver keeps state and outputs JSON files every second. ```json { "servers": [ { "addresses": [ "tw-0.6+udp://127.0.0.1:8303", "tw-0.6+udp://[::1]:8303" ], "info_serial": 0, "info": { "max_clients": 64, "max_players": 64, "passworded": false, "game_type": "TestDDraceNetwork", "name": "My DDNet server", "map": { "name": "dm1", "sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf", "size": 5805 }, "version": "0.6.4, 16.0.3", "clients": [] } } ] } ``` `servers.json` (or configured by `--out`) is a server list that is compatible with DDNet 15.5+ clients. It is a JSON object containing a single key `servers` with a list of game servers. Each game server is represented by a JSON object with an `addresses` key containing a list of all known addresses of the server and an `info` key containing the free-form server info sent by the game server. The free-form `info` JSON object re-encoded by the master server and thus canonicalized and stripped of any whitespace characters outside strings. ```json { "kind": "mastersrv", "now": 1816002, "secrets": { "tw-0.6+udp://127.0.0.1:8303": { "ping_time": 1811999, "secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb" }, "tw-0.6+udp://[::1]:8303": { "ping_time": 1811999, "secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb" } }, "servers": { "42d8f991-f2fa-46e5-a9ae-ebcc93846feb": { "info_serial": 0, "info": { "max_clients": 64, "max_players": 64, "passworded": false, "game_type": "TestDDraceNetwork", "name": "My DDNet server", "map": { "name": "dm1", "sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf", "size": 5805 }, "version": "0.6.4, 16.0.3", "clients": [] } } } } ``` `--write-dump` outputs a JSON file compatible with `--read-dump-dir`, this can be used to synchronize servers across different masterservers. `--read-dump-dir` is also used to ingest servers from the backward compatibility layer that pings each server for their server info using the old protocol. The `kind` field describe that this is `mastersrv` output and not from a `backcompat`. This is used for prioritizing `mastersrv` information over `backcompat` information. The `now` field contains an integer describing the current time in milliseconds relative an unspecified epoch that is fixed for each JSON file. This is done instead of using the current time as the epoch for better compression of non-changing data. `secrets` is a map from each server address and to a JSON object containing the last ping time (`ping_time`) in milliseconds relative to the same epoch as before, and the server secret (`secret`) that is used to unify server infos from different addresses of the same logical server. `servers` is a map from the aforementioned `secret`s to the corresponding `info_serial` and `info`. ```json [ "tw-0.6+udp://127.0.0.1:8303", "tw-0.6+udp://[::1]:8303" ] ``` `--write-addresses` outputs a JSON file containing all addresses corresponding to servers that are registered to HTTP masterservers. It does not contain the servers that are obtained via backward compatibility measures. This file can be used by an old-style masterserver to also list new-style servers without the game servers having to register there. An implementation of this can be found at https://github.com/heinrich5991/teeworlds/tree/mastersrv_6_backcompat for Teeworlds 0.5/0.6 masterservers and at https://github.com/heinrich5991/teeworlds/tree/mastersrv_7_backcompat for Teeworlds 0.7 masterservers. All these JSON files can be sent over the network in an efficient way using https://github.com/heinrich5991/twmaster-collect. It establishes a zstd-compressed TCP connection authenticated by a string token that is sent in plain-text. It watches the specified file and transmits it every time it changes. Due to the zstd-compression, the data sent over the network is similar to the size of a diff. Implementation -------------- The masterserver implementation was done in Rust. The current gameserver register implementation doesn't support more than one masterserver for registering.
2022-05-19 20:03:17 +00:00
masterserver.h
memheap.cpp
memheap.h
netban.cpp
netban.h
network.cpp
network.h
network_client.cpp
network_conn.cpp
network_console.cpp
network_console_conn.cpp
network_server.cpp
network_stun.cpp
packer.cpp
packer.h
protocol.h
2023-02-14 10:34:15 +00:00
protocol7.h
protocol_ex.cpp
protocol_ex.h
protocol_ex_msgs.h
ringbuffer.cpp
ringbuffer.h
Add client-side HTTP server info Summary ======= The idea of this is that clients will not have to ping each server for server infos which takes long, leaks the client's IP address even to servers the user does not join and is a DoS vector of the game servers for attackers. For the Internet, DDNet and KoG tab, the server list is entirely fetched from the master server, filtering out servers that don't belong into the list. The favorites tab is also supposed to work that way, except for servers that are marked as "also ping this server if it's not in the master server list". The LAN tab continues to broadcast the server info packet to find servers in the LAN. How does it work? ================= The client ships with a list of master server list URLs. On first start, the client checks which of these work and selects the fastest one. Querying the server list is a HTTP GET request on that URL. The response is a JSON document that contains server infos, server addresses as URLs and an approximate location. It can also contain a legacy server list which is a list of bare IP addresses similar to the functionality the old master servers provided via UDP. This allows us to backtrack on the larger update if it won't work out. Lost functionality ================== (also known as user-visible changes) Since the client doesn't ping each server in the list anymore, it has no way of knowing its latency to the servers. This is alleviated a bit by providing an approximate location for each server (continent) so the client only has to know its own location for approximating pings.
2018-07-11 20:46:04 +00:00
serverinfo.cpp
serverinfo.h
snapshot.cpp
snapshot.h
storage.cpp
stun.cpp
stun.h
2018-01-11 15:01:13 +00:00
teehistorian_ex.cpp
teehistorian_ex.h
teehistorian_ex_chunks.h
uuid_manager.cpp
uuid_manager.h
2017-10-26 22:42:33 +00:00
video.cpp
video.h
websockets.cpp
websockets.h
)
set_src(ENGINE_GFX GLOB src/engine/gfx
image_loader.cpp
image_loader.h
image_manipulation.cpp
image_manipulation.h
)
set_src(GAME_SHARED GLOB src/game
alloc.h
collision.cpp
collision.h
gamecore.cpp
gamecore.h
layers.cpp
layers.h
localization.cpp
localization.h
mapbugs.cpp
mapbugs.h
mapbugs_list.h
mapitems.cpp
mapitems.h
mapitems_ex.cpp
mapitems_ex.h
mapitems_ex_types.h
prng.cpp
prng.h
teamscore.cpp
teamscore.h
tuning.h
version.h
voting.h
)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "src/game/version.h")
# A bit hacky, but these are needed to register all the UUIDs, even for stuff
# that doesn't link game.
set(ENGINE_UUID_SHARED
2022-04-03 00:20:53 +00:00
src/game/generated/protocolglue.cpp
2020-04-16 08:46:43 +00:00
src/game/generated/protocolglue.h
src/game/generated/protocol7.cpp
src/game/generated/protocol7.h
src/game/generated/protocol.cpp
src/game/generated/protocol.h
src/game/mapitems_ex.cpp
src/game/mapitems_ex.h
src/game/mapitems_ex_types.h
)
foreach(s ${GAME_SHARED})
if(s MATCHES "mapitems_(ex.cpp|ex.h|ex_types.h)$")
list(REMOVE_ITEM GAME_SHARED ${s})
endif()
endforeach()
list(REMOVE_ITEM GAME_SHARED ${ENGINE_UUID_SHARED})
set(GAME_GENERATED_SHARED
src/game/generated/data_types.h
src/game/generated/git_revision.cpp
src/game/generated/protocol.h
2020-04-16 08:46:43 +00:00
src/game/generated/protocol7.h
src/game/generated/protocolglue.h
)
set(DEPS ${DEP_JSON} ${DEP_MD5} ${ZLIB_DEP})
# Libraries
2018-12-23 22:18:56 +00:00
set(LIBS
${CRYPTO_LIBRARIES}
${CURL_LIBRARIES}
2021-04-21 11:21:25 +00:00
${SQLite3_LIBRARIES}
2018-12-23 22:18:56 +00:00
${WEBSOCKETS_LIBRARIES}
${ZLIB_LIBRARIES}
${PLATFORM_LIBS}
# Add pthreads (on non-Windows) at the end, so that other libraries can depend
# on it.
${CMAKE_THREAD_LIBS_INIT}
)
# Targets
add_library(engine-gfx EXCLUDE_FROM_ALL OBJECT ${ENGINE_GFX})
target_include_directories(engine-gfx PRIVATE ${PNG_INCLUDE_DIRS})
add_library(engine-shared EXCLUDE_FROM_ALL OBJECT ${ENGINE_INTERFACE} ${ENGINE_SHARED} ${ENGINE_UUID_SHARED} ${BASE})
add_library(game-shared EXCLUDE_FROM_ALL OBJECT ${GAME_SHARED} ${GAME_GENERATED_SHARED})
list(APPEND TARGETS_OWN engine-gfx engine-shared game-shared)
if(DISCORD AND NOT DISCORD_DYNAMIC)
2021-01-02 16:10:31 +00:00
add_library(discord-shared SHARED IMPORTED)
set_target_properties(discord-shared PROPERTIES
IMPORTED_LOCATION "${DISCORDSDK_LIBRARIES}"
IMPORTED_IMPLIB "${DISCORDSDK_LIBRARIES}"
2021-01-02 16:10:31 +00:00
)
endif()
########################################################################
# CLIENT
########################################################################
if(CLIENT)
# Sources
2020-08-20 10:17:44 +00:00
set_src(STEAMAPI_SRC GLOB_RECURSE src/steam
steam_api_flat.h
steam_api_stub.cpp
)
if(STEAM OR TARGET_OS STREQUAL "windows" OR TARGET_OS STREQUAL "mac")
set(STEAMAPI_KIND SHARED)
else()
set(STEAMAPI_KIND STATIC)
endif()
2020-08-20 10:17:44 +00:00
set(TARGET_STEAMAPI steam_api)
add_library(${TARGET_STEAMAPI} ${STEAMAPI_KIND} ${STEAMAPI_SRC})
2020-08-20 10:17:44 +00:00
list(APPEND TARGETS_OWN ${TARGET_STEAMAPI})
2021-04-30 22:42:37 +00:00
set_src(ENGINE_CLIENT GLOB_RECURSE src/engine/client
2022-03-20 17:03:25 +00:00
backend/backend_base.cpp
backend/backend_base.h
backend/glsl_shader_compiler.cpp
backend/glsl_shader_compiler.h
backend/null/backend_null.cpp
backend/null/backend_null.h
backend/opengl/backend_opengl.cpp
backend/opengl/backend_opengl.h
backend/opengl/backend_opengl3.cpp
backend/opengl/backend_opengl3.h
backend/opengl/opengl_sl.cpp
backend/opengl/opengl_sl.h
backend/opengl/opengl_sl_program.cpp
backend/opengl/opengl_sl_program.h
backend/opengles/backend_opengles.cpp
backend/opengles/backend_opengles3.cpp
backend/opengles/backend_opengles3.h
backend/opengles/gles_class_defines.h
backend/opengles/opengles_sl.cpp
backend/opengles/opengles_sl_program.cpp
2022-03-20 17:04:00 +00:00
backend/vulkan/backend_vulkan.cpp
backend/vulkan/backend_vulkan.h
backend_sdl.cpp
backend_sdl.h
blocklist_driver.cpp
blocklist_driver.h
checksum.h
client.cpp
client.h
demoedit.cpp
demoedit.h
discord.cpp
favorites.cpp
friends.cpp
friends.h
ghost.cpp
ghost.h
graph.cpp
graph.h
2021-05-01 21:33:42 +00:00
graphics_defines.h
graphics_threaded.cpp
graphics_threaded.h
input.cpp
input.h
keynames.h
notifications.cpp
notifications.h
serverbrowser.cpp
serverbrowser.h
Add client-side HTTP server info Summary ======= The idea of this is that clients will not have to ping each server for server infos which takes long, leaks the client's IP address even to servers the user does not join and is a DoS vector of the game servers for attackers. For the Internet, DDNet and KoG tab, the server list is entirely fetched from the master server, filtering out servers that don't belong into the list. The favorites tab is also supposed to work that way, except for servers that are marked as "also ping this server if it's not in the master server list". The LAN tab continues to broadcast the server info packet to find servers in the LAN. How does it work? ================= The client ships with a list of master server list URLs. On first start, the client checks which of these work and selects the fastest one. Querying the server list is a HTTP GET request on that URL. The response is a JSON document that contains server infos, server addresses as URLs and an approximate location. It can also contain a legacy server list which is a list of bare IP addresses similar to the functionality the old master servers provided via UDP. This allows us to backtrack on the larger update if it won't work out. Lost functionality ================== (also known as user-visible changes) Since the client doesn't ping each server in the list anymore, it has no way of knowing its latency to the servers. This is alleviated a bit by providing an approximate location for each server (continent) so the client only has to know its own location for approximating pings.
2018-07-11 20:46:04 +00:00
serverbrowser_http.cpp
serverbrowser_http.h
2021-04-17 14:05:24 +00:00
serverbrowser_ping_cache.cpp
serverbrowser_ping_cache.h
smooth_time.cpp
smooth_time.h
sound.cpp
sound.h
2021-04-21 11:21:25 +00:00
sqlite.cpp
2020-08-20 10:17:44 +00:00
steam.cpp
text.cpp
updater.cpp
updater.h
2017-10-26 22:42:33 +00:00
video.cpp
video.h
warning.cpp
)
set_src(GAME_CLIENT GLOB_RECURSE src/game/client
animstate.cpp
animstate.h
2021-07-12 09:29:59 +00:00
component.cpp
component.h
components/background.cpp
components/background.h
components/binds.cpp
components/binds.h
components/broadcast.cpp
components/broadcast.h
components/camera.cpp
components/camera.h
components/chat.cpp
components/chat.h
components/console.cpp
components/console.h
components/controls.cpp
components/controls.h
components/countryflags.cpp
components/countryflags.h
components/damageind.cpp
components/damageind.h
components/debughud.cpp
components/debughud.h
components/effects.cpp
components/effects.h
components/emoticon.cpp
components/emoticon.h
components/flow.cpp
components/flow.h
2022-03-25 11:54:11 +00:00
components/freezebars.cpp
components/freezebars.h
components/ghost.cpp
components/ghost.h
components/hud.cpp
components/hud.h
2023-11-20 11:23:56 +00:00
components/infomessages.cpp
components/infomessages.h
components/items.cpp
components/items.h
components/mapimages.cpp
components/mapimages.h
components/maplayers.cpp
components/maplayers.h
components/mapsounds.cpp
components/mapsounds.h
2020-09-18 16:45:42 +00:00
components/menu_background.cpp
components/menu_background.h
components/menus.cpp
components/menus.h
components/menus_browser.cpp
components/menus_demo.cpp
components/menus_ingame.cpp
components/menus_settings.cpp
2020-09-26 07:37:35 +00:00
components/menus_settings_assets.cpp
components/menus_start.cpp
components/motd.cpp
components/motd.h
components/nameplates.cpp
components/nameplates.h
components/particles.cpp
components/particles.h
components/players.cpp
components/players.h
components/race_demo.cpp
components/race_demo.h
components/scoreboard.cpp
components/scoreboard.h
components/skins.cpp
components/skins.h
components/sounds.cpp
components/sounds.h
components/spectator.cpp
components/spectator.h
components/statboard.cpp
components/statboard.h
components/tooltips.cpp
components/tooltips.h
components/voting.cpp
components/voting.h
gameclient.cpp
gameclient.h
laser_data.cpp
laser_data.h
lineinput.cpp
lineinput.h
pickup_data.cpp
pickup_data.h
prediction/entities/character.cpp
prediction/entities/character.h
2023-06-03 16:51:38 +00:00
prediction/entities/dragger.cpp
prediction/entities/dragger.h
prediction/entities/laser.cpp
prediction/entities/laser.h
prediction/entities/pickup.cpp
prediction/entities/pickup.h
prediction/entities/projectile.cpp
prediction/entities/projectile.h
prediction/entity.cpp
prediction/entity.h
prediction/gameworld.cpp
prediction/gameworld.h
projectile_data.cpp
projectile_data.h
2017-10-06 20:10:29 +00:00
race.cpp
race.h
render.cpp
render.h
render_map.cpp
skin.h
ui.cpp
ui.h
ui_listbox.cpp
ui_listbox.h
ui_rect.cpp
ui_rect.h
ui_scrollregion.cpp
ui_scrollregion.h
)
set_src(GAME_EDITOR GLOB_RECURSE src/game/editor
auto_map.cpp
auto_map.h
component.cpp
component.h
editor.cpp
editor.h
2023-10-02 13:14:38 +00:00
editor_action.h
editor_actions.cpp
editor_actions.h
editor_history.cpp
editor_history.h
editor_object.cpp
editor_object.h
2023-10-02 13:14:38 +00:00
editor_props.cpp
editor_server_settings.cpp
editor_server_settings.h
2023-10-02 13:14:38 +00:00
editor_trackers.cpp
editor_trackers.h
editor_ui.h
explanations.cpp
layer_selector.cpp
layer_selector.h
map_grid.cpp
map_grid.h
map_view.cpp
map_view.h
2023-10-02 13:14:38 +00:00
mapitems.h
mapitems/envelope.cpp
2023-10-05 20:42:24 +00:00
mapitems/envelope.h
mapitems/image.cpp
mapitems/image.h
mapitems/layer.h
mapitems/layer_front.cpp
mapitems/layer_front.h
mapitems/layer_game.cpp
mapitems/layer_game.h
mapitems/layer_group.cpp
mapitems/layer_group.h
mapitems/layer_quads.cpp
mapitems/layer_quads.h
mapitems/layer_sounds.cpp
mapitems/layer_sounds.h
mapitems/layer_speedup.cpp
mapitems/layer_speedup.h
mapitems/layer_switch.cpp
mapitems/layer_switch.h
mapitems/layer_tele.cpp
mapitems/layer_tele.h
mapitems/layer_tiles.cpp
mapitems/layer_tiles.h
mapitems/layer_tune.cpp
mapitems/layer_tune.h
mapitems/map.cpp
2023-08-28 15:47:19 +00:00
mapitems/map_io.cpp
mapitems/sound.cpp
mapitems/sound.h
popups.cpp
proof_mode.cpp
proof_mode.h
smooth_value.cpp
smooth_value.h
2023-08-12 10:13:27 +00:00
tileart.cpp
)
set(GAME_GENERATED_CLIENT
src/game/generated/checksum.cpp
src/game/generated/client_data.cpp
src/game/generated/client_data.h
src/game/generated/client_data7.cpp
src/game/generated/client_data7.h
)
2017-07-26 02:30:56 +00:00
set(CLIENT_SRC ${ENGINE_CLIENT} ${PLATFORM_CLIENT} ${GAME_CLIENT} ${GAME_EDITOR} ${GAME_GENERATED_CLIENT})
set(DEPS_CLIENT ${DEPS} ${GLEW_DEP} ${WAVPACK_DEP})
# Libraries
set(LIBS_CLIENT
${FREETYPE_LIBRARIES}
${GLEW_LIBRARIES}
${PNG_LIBRARIES}
${SDL2_LIBRARIES}
${WAVPACK_LIBRARIES}
2017-10-26 22:42:33 +00:00
${FFMPEG_LIBRARIES}
# Order of these three is important.
${OPUSFILE_LIBRARIES}
${OPUS_LIBRARIES}
${OGG_LIBRARIES}
2022-03-20 17:04:00 +00:00
${VULKAN_LIBRARIES}
2020-08-20 10:17:44 +00:00
${TARGET_STEAMAPI}
rust_engine_shared
2020-08-20 10:17:44 +00:00
2017-03-02 11:31:20 +00:00
${PLATFORM_CLIENT_LIBS}
${LIBS}
)
2021-01-02 16:10:31 +00:00
if(DISCORD)
if(NOT DISCORD_DYNAMIC)
list(APPEND LIBS_CLIENT discord-shared)
else()
list(APPEND LIBS_CLIENT ${CMAKE_DL_LIBS})
endif()
2021-01-02 16:10:31 +00:00
endif()
if(TARGET_OS STREQUAL "windows")
configure_file("other/manifest/client.manifest.in" "client.manifest")
set(CLIENT_ICON "other/icons/DDNet.rc")
if(NOT MINGW)
set(CLIENT_MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/client.manifest")
else()
set(CLIENT_MANIFEST "other/manifest/client.rc")
set_target_properties(${TARGET_STEAMAPI} PROPERTIES PREFIX "")
endif()
else()
set(CLIENT_ICON)
set(CLIENT_MANIFEST)
endif()
# Target
2021-08-24 10:18:20 +00:00
if(TARGET_OS STREQUAL "android")
add_library(game-client SHARED
2021-08-24 10:18:20 +00:00
${CLIENT_SRC}
${CLIENT_ICON}
${CLIENT_MANIFEST}
${DEPS_CLIENT}
$<TARGET_OBJECTS:engine-gfx>
2021-08-24 10:18:20 +00:00
$<TARGET_OBJECTS:engine-shared>
$<TARGET_OBJECTS:game-shared>
$<TARGET_OBJECTS:rust-bridge-shared>
2021-08-24 10:18:20 +00:00
)
else()
add_executable(game-client WIN32
2021-08-24 10:18:20 +00:00
${CLIENT_SRC}
${CLIENT_ICON}
${CLIENT_MANIFEST}
${DEPS_CLIENT}
$<TARGET_OBJECTS:engine-gfx>
2021-08-24 10:18:20 +00:00
$<TARGET_OBJECTS:engine-shared>
$<TARGET_OBJECTS:game-shared>
$<TARGET_OBJECTS:rust-bridge-shared>
2021-08-24 10:18:20 +00:00
)
endif()
set_property(TARGET game-client
PROPERTY OUTPUT_NAME ${CLIENT_EXECUTABLE}
)
target_link_libraries(game-client ${LIBS_CLIENT})
2021-03-05 16:36:20 +00:00
if(MSVC)
target_link_options(game-client PRIVATE /ENTRY:mainCRTStartup)
2021-03-05 16:36:20 +00:00
endif()
target_include_directories(game-client SYSTEM PRIVATE
${FREETYPE_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${OGG_INCLUDE_DIRS}
${OPUSFILE_INCLUDE_DIRS}
${OPUS_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}
${WAVPACK_INCLUDE_DIRS}
2017-10-26 22:42:33 +00:00
${FFMPEG_INCLUDE_DIRS}
2021-01-02 16:10:31 +00:00
${DISCORDSDK_INCLUDE_DIRS}
2022-03-20 17:04:00 +00:00
${VULKAN_INCLUDE_DIRS}
${PLATFORM_CLIENT_INCLUDE_DIRS}
)
if(STEAMAPI_KIND STREQUAL SHARED OR DISCORD_DYNAMIC)
set_own_rpath(game-client)
endif()
set(PARAMS "${WAVPACK_INCLUDE_DIRS};${WAVPACK_INCLUDE_DIRS}")
if(NOT(WAVPACK_OPEN_FILE_INPUT_EX_PARAMS STREQUAL PARAMS))
unset(WAVPACK_OPEN_FILE_INPUT_EX CACHE)
endif()
set(WAVPACK_OPEN_FILE_INPUT_EX_PARAMS "${PARAMS}" CACHE INTERNAL "")
set(CMAKE_REQUIRED_INCLUDES ${ORIGINAL_CMAKE_REQUIRED_INCLUDES} ${WAVPACK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ORIGINAL_CMAKE_REQUIRED_LIBRARIES} ${WAVPACK_LIBRARIES})
check_symbol_exists(WavpackOpenFileInputEx wavpack.h WAVPACK_OPEN_FILE_INPUT_EX)
2020-04-11 11:17:14 +00:00
check_symbol_exists(WavpackCloseFile wavpack.h WAVPACK_CLOSE_FILE)
set(CMAKE_REQUIRED_INCLUDES ${ORIGINAL_CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_LIBRARIES ${ORIGINAL_CMAKE_REQUIRED_LIBRARIES})
if(WAVPACK_OPEN_FILE_INPUT_EX)
target_compile_definitions(game-client PRIVATE CONF_WAVPACK_OPEN_FILE_INPUT_EX)
endif()
2020-04-11 11:17:14 +00:00
if(WAVPACK_CLOSE_FILE)
target_compile_definitions(game-client PRIVATE CONF_WAVPACK_CLOSE_FILE)
2020-04-11 11:17:14 +00:00
endif()
2021-08-23 10:31:41 +00:00
if(GLEW_BUNDLED)
target_compile_definitions(game-client PRIVATE CONF_GLEW_HAS_CONTEXT_INIT)
2021-08-23 10:31:41 +00:00
endif()
2022-03-20 17:04:00 +00:00
if(VULKAN)
target_compile_definitions(game-client PRIVATE CONF_BACKEND_VULKAN)
2022-03-20 17:04:00 +00:00
endif()
list(APPEND TARGETS_OWN game-client)
list(APPEND TARGETS_LINK game-client)
endif()
########################################################################
# SERVER
########################################################################
2021-08-24 10:18:20 +00:00
if(SERVER)
# Sources
set_src(ANTIBOT_SRC GLOB src/antibot
antibot_data.h
antibot_interface.h
antibot_null.cpp
)
2021-08-24 10:18:20 +00:00
set_src(ENGINE_SERVER GLOB_RECURSE src/engine/server
antibot.cpp
antibot.h
authmanager.cpp
authmanager.h
databases/connection.cpp
databases/connection.h
databases/connection_pool.cpp
databases/connection_pool.h
databases/mysql.cpp
databases/sqlite.cpp
main.cpp
2021-08-24 10:18:20 +00:00
name_ban.cpp
name_ban.h
register.cpp
register.h
server.cpp
server.h
server_logger.cpp
server_logger.h
snap_id_pool.cpp
snap_id_pool.h
2021-08-24 10:18:20 +00:00
sql_string_helpers.cpp
sql_string_helpers.h
upnp.cpp
upnp.h
)
set_src(GAME_SERVER GLOB_RECURSE src/game/server
ddracechat.cpp
ddracecommands.cpp
entities/character.cpp
entities/character.h
entities/door.cpp
entities/door.h
entities/dragger.cpp
entities/dragger.h
2022-05-02 18:31:17 +00:00
entities/dragger_beam.cpp
entities/dragger_beam.h
2021-08-24 10:18:20 +00:00
entities/gun.cpp
entities/gun.h
entities/laser.cpp
entities/laser.h
entities/light.cpp
entities/light.h
entities/pickup.cpp
entities/pickup.h
entities/plasma.cpp
entities/plasma.h
entities/projectile.cpp
entities/projectile.h
entity.cpp
entity.h
eventhandler.cpp
eventhandler.h
gamecontext.cpp
gamecontext.h
gamecontroller.cpp
gamecontroller.h
gamemodes/DDRace.cpp
gamemodes/DDRace.h
2023-11-16 10:39:55 +00:00
gamemodes/mod.cpp
gamemodes/mod.h
2021-08-24 10:18:20 +00:00
gameworld.cpp
gameworld.h
player.cpp
player.h
save.cpp
save.h
score.cpp
score.h
scoreworker.cpp
scoreworker.h
2021-08-24 10:18:20 +00:00
teams.cpp
teams.h
teehistorian.cpp
teehistorian.h
teeinfo.cpp
teeinfo.h
)
set(GAME_GENERATED_SERVER
"src/game/generated/server_data.cpp"
"src/game/generated/server_data.h"
"src/game/generated/wordlist.h"
)
set(SERVER_SRC ${ENGINE_SERVER} ${GAME_SERVER} ${GAME_GENERATED_SERVER})
if(TARGET_OS STREQUAL "windows")
set(SERVER_ICON "other/icons/DDNet-Server.rc")
2021-08-24 10:18:20 +00:00
else()
set(SERVER_ICON)
endif()
2021-08-24 10:18:20 +00:00
# Antibot
if(ANTIBOT)
set(TARGET_ANTIBOT antibot)
add_library(${TARGET_ANTIBOT} SHARED ${ANTIBOT_SRC})
list(APPEND TARGETS_OWN ${TARGET_ANTIBOT})
endif()
2021-08-24 10:18:20 +00:00
# Libraries
set(LIBS_SERVER
${MINIUPNPC_LIBRARIES}
2021-08-24 10:18:20 +00:00
${MYSQL_LIBRARIES}
${TARGET_ANTIBOT}
rust_engine_shared
${LIBS}
2021-08-24 10:18:20 +00:00
)
2021-08-24 10:18:20 +00:00
# Target
add_executable(game-server
2021-08-24 10:18:20 +00:00
${DEPS}
${SERVER_SRC}
${SERVER_ICON}
$<TARGET_OBJECTS:engine-shared>
$<TARGET_OBJECTS:game-shared>
$<TARGET_OBJECTS:rust-bridge-shared>
2021-08-24 10:18:20 +00:00
)
set_property(TARGET game-server
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}
)
target_link_libraries(game-server ${LIBS_SERVER})
target_include_directories(game-server PRIVATE ${PNG_INCLUDE_DIRS})
list(APPEND TARGETS_OWN game-server)
list(APPEND TARGETS_LINK game-server)
2021-08-24 10:18:20 +00:00
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
set(SERVER_LAUNCHER_SRC src/macos/server.mm)
add_executable(game-server-launcher ${SERVER_LAUNCHER_SRC})
set_property(TARGET game-server-launcher
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}-Launcher
)
target_link_libraries(game-server-launcher ${COCOA})
list(APPEND TARGETS_OWN game-server-launcher)
list(APPEND TARGETS_LINK game-server-launcher)
2021-08-24 10:18:20 +00:00
endif()
endif()
# Targets for compatibility with build commands previously available with Makefiles
if(CMAKE_GENERATOR MATCHES ".*Makefiles.*")
if(TARGET game-client)
add_custom_target(${CLIENT_EXECUTABLE})
add_dependencies(${CLIENT_EXECUTABLE} game-client)
endif()
if(TARGET game-server)
add_custom_target(${SERVER_EXECUTABLE})
add_dependencies(${SERVER_EXECUTABLE} game-server)
endif()
endif()
########################################################################
# VARIOUS TARGETS
########################################################################
2021-08-24 10:18:20 +00:00
if(TOOLS)
set(TARGETS_TOOLS)
set_src(TOOLS_SRC GLOB src/tools
2021-08-24 10:18:20 +00:00
config_common.h
config_retrieve.cpp
config_store.cpp
crapnet.cpp
2023-10-25 14:03:24 +00:00
demo_extract_chat.cpp
2021-08-24 10:18:20 +00:00
dilate.cpp
dummy_map.cpp
map_convert_07.cpp
2022-08-23 16:12:15 +00:00
map_create_pixelart.cpp
2021-08-24 10:18:20 +00:00
map_diff.cpp
map_extract.cpp
map_find_env.cpp
2021-08-24 10:18:20 +00:00
map_optimize.cpp
2022-03-16 18:03:28 +00:00
map_replace_area.cpp
2021-08-24 10:18:20 +00:00
map_replace_image.cpp
map_resave.cpp
packetgen.cpp
stun.cpp
2022-06-24 23:28:05 +00:00
twping.cpp
2021-08-24 10:18:20 +00:00
unicode_confusables.cpp
uuid.cpp
)
foreach(ABS_T ${TOOLS_SRC})
2021-08-24 10:18:20 +00:00
file(RELATIVE_PATH T "${PROJECT_SOURCE_DIR}/src/tools/" ${ABS_T})
if(T MATCHES "\\.cpp$")
string(REGEX REPLACE "\\.cpp$" "" TOOL "${T}")
set(TOOL_DEPS ${DEPS})
set(TOOL_LIBS ${LIBS})
unset(EXTRA_TOOL_SRC)
2022-08-23 16:12:15 +00:00
if(TOOL MATCHES "^(dilate|map_convert_07|map_create_pixelart|map_optimize|map_extract|map_replace_image)$")
list(APPEND TOOL_INCLUDE_DIRS ${PNG_INCLUDE_DIRS})
list(APPEND TOOL_DEPS $<TARGET_OBJECTS:engine-gfx>)
list(APPEND TOOL_LIBS ${PNG_LIBRARIES})
2021-08-24 10:18:20 +00:00
endif()
if(TOOL MATCHES "^config_")
list(APPEND EXTRA_TOOL_SRC "src/tools/config_common.h")
endif()
set(EXCLUDE_FROM_ALL)
if(DEV)
set(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
endif()
add_executable(${TOOL} ${EXCLUDE_FROM_ALL}
${TOOL_DEPS}
src/tools/${TOOL}.cpp
${EXTRA_TOOL_SRC}
$<TARGET_OBJECTS:engine-shared>
)
target_include_directories(${TOOL} SYSTEM PRIVATE ${TOOL_INCLUDE_DIRS})
2021-08-24 10:18:20 +00:00
target_link_libraries(${TOOL} ${TOOL_LIBS})
list(APPEND TARGETS_TOOLS ${TOOL})
endif()
2021-08-24 10:18:20 +00:00
endforeach()
2017-03-01 14:49:22 +00:00
2021-08-24 10:18:20 +00:00
list(APPEND TARGETS_OWN ${TARGETS_TOOLS})
list(APPEND TARGETS_LINK ${TARGETS_TOOLS})
2017-03-03 14:23:18 +00:00
2021-08-24 10:18:20 +00:00
add_custom_target(tools DEPENDS ${TARGETS_TOOLS})
endif()
add_custom_target(everything DEPENDS ${TARGETS_OWN})
########################################################################
# CHECKSUM
########################################################################
if(DEV)
# Only do minimal checksumming in a DEV build.
set(CHECKSUM_SRC)
endif()
list(APPEND CHECKSUM_SRC
${PROJECT_SOURCE_DIR}/CMakeLists.txt
${PROJECT_SOURCE_DIR}/scripts/checksum.py
)
configure_file(cmake/checksummed_extra.txt checksummed_extra.txt)
string(REPLACE ";" "\n" CHECKSUM_SRC_FILE "${CHECKSUM_SRC}")
file(WRITE ${PROJECT_BINARY_DIR}/checksummed_files.txt ${CHECKSUM_SRC_FILE})
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src/game/generated/checksum.cpp
COMMAND ${Python3_EXECUTABLE}
scripts/checksum.py
${PROJECT_BINARY_DIR}/checksummed_files.txt
${PROJECT_BINARY_DIR}/checksummed_extra.txt
> ${PROJECT_BINARY_DIR}/src/game/generated/checksum.cpp
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS
${CHECKSUM_SRC}
${PROJECT_BINARY_DIR}/checksummed_files.txt
${PROJECT_BINARY_DIR}/checksummed_extra.txt
scripts/checksum.py
)
########################################################################
# TESTS
########################################################################
if(GTEST_FOUND OR DOWNLOAD_GTEST)
set_src(TESTS GLOB src/test
aio.cpp
2020-07-02 09:07:30 +00:00
bezier.cpp
blocklist_driver.cpp
bytes_be.cpp
2019-04-24 20:47:03 +00:00
color.cpp
compression.cpp
csv.cpp
datafile.cpp
fs.cpp
git_revision.cpp
hash.cpp
2022-10-25 10:28:04 +00:00
huffman.cpp
io.cpp
2017-11-24 09:33:42 +00:00
jobs.cpp
json.cpp
jsonwriter.cpp
linereader.cpp
mapbugs.cpp
math.cpp
memory.cpp
name_ban.cpp
net.cpp
netaddr.cpp
2022-01-27 01:35:08 +00:00
os.cpp
2020-09-03 16:50:23 +00:00
packer.cpp
prng.cpp
score.cpp
secure_random.cpp
2021-04-17 14:05:24 +00:00
serverbrowser.cpp
Add client-side HTTP server info Summary ======= The idea of this is that clients will not have to ping each server for server infos which takes long, leaks the client's IP address even to servers the user does not join and is a DoS vector of the game servers for attackers. For the Internet, DDNet and KoG tab, the server list is entirely fetched from the master server, filtering out servers that don't belong into the list. The favorites tab is also supposed to work that way, except for servers that are marked as "also ping this server if it's not in the master server list". The LAN tab continues to broadcast the server info packet to find servers in the LAN. How does it work? ================= The client ships with a list of master server list URLs. On first start, the client checks which of these work and selects the fastest one. Querying the server list is a HTTP GET request on that URL. The response is a JSON document that contains server infos, server addresses as URLs and an approximate location. It can also contain a legacy server list which is a list of bare IP addresses similar to the functionality the old master servers provided via UDP. This allows us to backtrack on the larger update if it won't work out. Lost functionality ================== (also known as user-visible changes) Since the client doesn't ping each server in the list anymore, it has no way of knowing its latency to the servers. This is alleviated a bit by providing an approximate location for each server (continent) so the client only has to know its own location for approximating pings.
2018-07-11 20:46:04 +00:00
serverinfo.cpp
str.cpp
strip_path_and_extension.cpp
swap_endian.cpp
teehistorian.cpp
test.cpp
test.h
2017-10-09 22:08:24 +00:00
thread.cpp
timestamp.cpp
2017-12-20 15:56:44 +00:00
unix.cpp
uuid.cpp
)
set(TESTS_EXTRA
src/engine/client/blocklist_driver.cpp
src/engine/client/blocklist_driver.h
Add client-side HTTP server info Summary ======= The idea of this is that clients will not have to ping each server for server infos which takes long, leaks the client's IP address even to servers the user does not join and is a DoS vector of the game servers for attackers. For the Internet, DDNet and KoG tab, the server list is entirely fetched from the master server, filtering out servers that don't belong into the list. The favorites tab is also supposed to work that way, except for servers that are marked as "also ping this server if it's not in the master server list". The LAN tab continues to broadcast the server info packet to find servers in the LAN. How does it work? ================= The client ships with a list of master server list URLs. On first start, the client checks which of these work and selects the fastest one. Querying the server list is a HTTP GET request on that URL. The response is a JSON document that contains server infos, server addresses as URLs and an approximate location. It can also contain a legacy server list which is a list of bare IP addresses similar to the functionality the old master servers provided via UDP. This allows us to backtrack on the larger update if it won't work out. Lost functionality ================== (also known as user-visible changes) Since the client doesn't ping each server in the list anymore, it has no way of knowing its latency to the servers. This is alleviated a bit by providing an approximate location for each server (continent) so the client only has to know its own location for approximating pings.
2018-07-11 20:46:04 +00:00
src/engine/client/serverbrowser.cpp
src/engine/client/serverbrowser.h
src/engine/client/serverbrowser_http.cpp
src/engine/client/serverbrowser_http.h
2021-04-17 14:05:24 +00:00
src/engine/client/serverbrowser_ping_cache.cpp
src/engine/client/serverbrowser_ping_cache.h
2021-04-21 11:21:25 +00:00
src/engine/client/sqlite.cpp
src/engine/server/databases/connection.cpp
src/engine/server/databases/connection.h
src/engine/server/databases/sqlite.cpp
2021-11-28 00:29:38 +00:00
src/engine/server/databases/mysql.cpp
src/engine/server/name_ban.cpp
src/engine/server/name_ban.h
src/engine/server/sql_string_helpers.cpp
src/engine/server/sql_string_helpers.h
src/game/server/teehistorian.cpp
src/game/server/teehistorian.h
src/game/server/scoreworker.cpp
src/game/server/scoreworker.h
)
set(TARGET_TESTRUNNER testrunner)
add_executable(${TARGET_TESTRUNNER} EXCLUDE_FROM_ALL
${TESTS}
${TESTS_EXTRA}
$<TARGET_OBJECTS:engine-gfx>
$<TARGET_OBJECTS:engine-shared>
$<TARGET_OBJECTS:game-shared>
${DEPS}
)
target_link_libraries(${TARGET_TESTRUNNER} ${MYSQL_LIBRARIES} ${PNG_LIBRARIES} ${GTEST_LIBRARIES} ${LIBS})
target_include_directories(${TARGET_TESTRUNNER} SYSTEM PRIVATE ${GTEST_INCLUDE_DIRS})
list(APPEND TARGETS_OWN ${TARGET_TESTRUNNER})
list(APPEND TARGETS_LINK ${TARGET_TESTRUNNER})
add_custom_target(run_cxx_tests
COMMAND $<TARGET_FILE:${TARGET_TESTRUNNER}> ${TESTRUNNER_ARGS}
COMMENT Running unit tests
DEPENDS ${TARGET_TESTRUNNER}
USES_TERMINAL
)
add_custom_target(run_tests
DEPENDS run_cxx_tests
)
if(NOT MSVC OR CMAKE_BUILD_TYPE STREQUAL Release)
# On MSVC, Rust tests only work in the release mode because we link our C++
# code with the debug C standard library (/MTd) but Rust only supports
# linking to the release C standard library (/MT).
#
# See also https://github.com/rust-lang/rust/issues/39016.
add_dependencies(run_tests run_rust_tests)
endif()
endif()
add_library(rust_test STATIC EXCLUDE_FROM_ALL
$<TARGET_OBJECTS:engine-gfx>
$<TARGET_OBJECTS:engine-shared>
$<TARGET_OBJECTS:game-shared>
$<TARGET_OBJECTS:rust-bridge-shared>
${DEPS}
)
list(APPEND TARGETS_OWN rust_test)
list(APPEND TARGETS_LINK rust_test)
set(RUST_TEST_LIBS ${LIBS} $<TARGET_FILE:rust_test>)
list(REMOVE_ITEM RUST_TEST_LIBS "-pthread")
add_custom_target(run_rust_tests
COMMAND ${CMAKE_COMMAND} -E env "DDNET_TEST_LIBRARIES=${RUST_TEST_LIBS}" ${CARGO_TEST}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
USES_TERMINAL
DEPENDS rust_test
VERBATIM
)
add_custom_target(run_integration_tests
COMMAND ${PROJECT_BINARY_DIR}/integration_test.sh ${INTEGRATIONTESTRUNNER_ARGS}
COMMENT Running integration tests
DEPENDS game-client game-server
USES_TERMINAL
)
########################################################################
# INSTALLATION
########################################################################
function(escape_regex VAR STRING)
string(REGEX REPLACE "([][^$.+*?|()\\\\])" "\\\\\\1" ESCAPED "${STRING}")
set(${VAR} ${ESCAPED} PARENT_SCOPE)
endfunction()
function(escape_backslashes VAR STRING)
string(REGEX REPLACE "\\\\" "\\\\\\\\" ESCAPED "${STRING}")
set(${VAR} ${ESCAPED} PARENT_SCOPE)
endfunction()
function(max_length VAR)
set(MAX_LENGTH 0)
foreach(str ${ARGN})
string(LENGTH ${str} LENGTH)
if(LENGTH GREATER MAX_LENGTH)
set(MAX_LENGTH ${LENGTH})
endif()
endforeach()
set(${VAR} ${MAX_LENGTH} PARENT_SCOPE)
endfunction()
# Tries to generate a list of regex that matches everything except the given
# parameters.
function(regex_inverted VAR)
max_length(MAX_LENGTH ${ARGN})
math(EXPR UPPER_BOUND "${MAX_LENGTH}-1")
set(REMAINING ${ARGN})
set(RESULT)
foreach(i RANGE ${UPPER_BOUND})
set(TEMP ${REMAINING})
set(REMAINING)
foreach(str ${TEMP})
string(LENGTH ${str} LENGTH)
if(i LESS LENGTH)
list(APPEND REMAINING ${str})
endif()
endforeach()
set(ADDITIONAL)
foreach(outer ${REMAINING})
string(SUBSTRING ${outer} 0 ${i} OUTER_PREFIX)
set(CHARS "")
foreach(inner ${REMAINING})
string(SUBSTRING ${inner} 0 ${i} INNER_PREFIX)
if(OUTER_PREFIX STREQUAL INNER_PREFIX)
string(SUBSTRING ${inner} ${i} 1 INNER_NEXT)
set(CHARS "${CHARS}${INNER_NEXT}")
endif()
endforeach()
escape_regex(OUTER_PREFIX_ESCAPED "${OUTER_PREFIX}")
list(APPEND ADDITIONAL "${OUTER_PREFIX_ESCAPED}([^${CHARS}]|$)")
endforeach()
list(REMOVE_DUPLICATES ADDITIONAL)
list(APPEND RESULT ${ADDITIONAL})
endforeach()
set(${VAR} ${RESULT} PARENT_SCOPE)
endfunction()
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR TGZ TXZ)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
if(TARGET_OS STREQUAL "mac")
set(CPACK_STRIP_FILES FALSE)
else()
set(CPACK_STRIP_FILES TRUE)
endif()
set(CPACK_COMPONENTS_ALL portable)
set(CPACK_SOURCE_GENERATOR ZIP TGZ TBZ2 TXZ)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
if(TARGET_OS AND TARGET_BITS)
if(TARGET_OS STREQUAL "windows")
set(CPACK_SYSTEM_NAME "win${TARGET_BITS}")
set(CPACK_GENERATOR ZIP)
elseif(TARGET_OS STREQUAL "linux")
# Let compiler tell its arch
# Both gcc and clang support -dumpmachine
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE ARCHITECTURE_TUPLE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ARCHITECTURE_TUPLE)
# If you're really using a weird compiler, then assume Intel here.
message(WARNING "Your compiler doesn't support -dumpmachine, this is weird")
if(TARGET_BITS EQUAL 32)
set(ARCHITECTURE "x86")
elseif(TARGET_BITS EQUAL 64)
set(ARCHITECTURE "x86_64")
endif()
else()
string(REGEX MATCH "^[^-]*" ARCHITECTURE "${ARCHITECTURE_TUPLE}")
if(ARCHITECTURE MATCHES "i.86")
set(ARCHITECTURE "x86")
endif()
endif()
set(CPACK_SYSTEM_NAME "linux_${ARCHITECTURE}")
elseif(TARGET_OS STREQUAL "mac")
2021-12-04 12:26:12 +00:00
set(CPACK_SYSTEM_NAME "macos")
set(CPACK_GENERATOR DMG)
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME})
set(CPACK_ARCHIVE_PORTABLE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-src)
set(CPACK_SOURCE_FILES
CMakeLists.txt
README.md
cmake/
data/
datasrc/
ddnet-libs/
license.txt
lsan.supp
memcheck.supp
other/
scripts/
src/
storage.cfg
ubsan.supp
valgrind.supp
)
set(CPACK_SOURCE_IGNORE_FILES
"\\\\.pyc$"
"/\\\\.git"
"/__pycache__/"
)
regex_inverted(CPACK_SOURCE_FILES_INVERTED ${CPACK_SOURCE_FILES})
escape_regex(PROJECT_SOURCE_DIR_ESCAPED ${PROJECT_SOURCE_DIR})
foreach(str ${CPACK_SOURCE_FILES_INVERTED})
escape_backslashes(STR_ESCAPED "${PROJECT_SOURCE_DIR_ESCAPED}/${str}")
list(APPEND CPACK_SOURCE_IGNORE_FILES "${STR_ESCAPED}")
endforeach()
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ${PROJECT_NAME})
2021-08-24 10:18:20 +00:00
if(TOOLS)
set(TARGET_TOOLS
config_retrieve
config_store
2023-10-25 19:35:26 +00:00
demo_extract_chat
2021-08-24 10:18:20 +00:00
dilate
map_convert_07
map_diff
map_extract
)
else()
set(TARGET_TOOLS)
endif()
set(CPACK_TARGETS)
if(TARGET game-client)
list(APPEND CPACK_TARGETS game-client)
endif()
if(TARGET game-server)
list(APPEND CPACK_TARGETS game-server)
endif()
list(APPEND CPACK_TARGETS ${TARGET_TOOLS})
if(STEAMAPI_KIND STREQUAL SHARED)
list(APPEND CPACK_TARGETS ${TARGET_STEAMAPI})
endif()
set(CPACK_DIRS
data
${COPY_DIRS}
)
set(CPACK_FILES
license.txt
storage.cfg
${COPY_FILES}
)
2022-03-20 17:04:00 +00:00
set(CPACK_GEN_FILES
${VULKAN_SHADER_FILE_LIST}
)
if(TARGET_OS STREQUAL "windows")
list(APPEND CPACK_FILES other/config_directory.bat)
else()
list(APPEND CPACK_FILES other/config_directory.sh)
endif()
if(NOT DEV)
include(GNUInstallDirs)
install(DIRECTORY data DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ddnet COMPONENT data)
if(TARGET game-client)
install(TARGETS game-client DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
endif()
if(STEAMAPI_KIND STREQUAL SHARED)
install(TARGETS ${TARGET_STEAMAPI} DESTINATION ${CMAKE_INSTALL_LIBDIR}/ddnet COMPONENT client)
endif()
if(TARGET game-server)
install(TARGETS game-server DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server)
endif()
if(ANTIBOT)
2020-08-20 10:17:44 +00:00
install(TARGETS ${TARGET_ANTIBOT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/ddnet COMPONENT server)
endif()
install(TARGETS ${TARGETS_TOOLS} DESTINATION ${CMAKE_INSTALL_LIBDIR}/ddnet COMPONENT tools)
install(FILES other/ddnet.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications COMPONENT client)
foreach(SIZE 16 32 48 256)
install(FILES other/icons/DDNet_${SIZE}x${SIZE}x32.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}x${SIZE}/apps RENAME ddnet.png COMPONENT client)
2021-12-27 22:23:38 +00:00
install(FILES other/icons/DDNet-Server_${SIZE}x${SIZE}x32.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}x${SIZE}/apps RENAME ddnet-server.png COMPONENT server)
2019-05-23 14:28:25 +00:00
endforeach()
2022-03-20 17:04:00 +00:00
foreach(file ${VULKAN_SHADER_FILE_LIST})
install(FILES ${PROJECT_BINARY_DIR}/${file} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ddnet/data/shader/vulkan COMPONENT client)
endforeach()
endif()
if(DEV)
# Don't generate CPack targets.
else()
set(EXTRA_ARGS DESTINATION ${CPACK_PACKAGE_FILE_NAME} COMPONENT portable EXCLUDE_FROM_ALL)
install(TARGETS ${CPACK_TARGETS} ${EXTRA_ARGS})
install(DIRECTORY ${CPACK_DIRS} ${EXTRA_ARGS})
2022-03-20 17:04:00 +00:00
set(CPACK_FILES_TMP ${CPACK_FILES} ${CPACK_GEN_FILES})
install(FILES ${CPACK_FILES_TMP} ${EXTRA_ARGS})
endif()
set(PACKAGE_TARGETS)
if(CLIENT AND DMGBUILD)
file(MAKE_DIRECTORY bundle/client/)
file(MAKE_DIRECTORY bundle/server/)
2017-11-17 21:32:44 +00:00
configure_file(other/bundle/client/Info.plist.in bundle/client/Info.plist)
configure_file(other/bundle/server/Info.plist.in bundle/server/Info.plist)
set(DMG_TMPDIR pack_${CPACK_PACKAGE_FILE_NAME}_dmg)
set(DMG_MKDIRS
${CLIENT_EXECUTABLE}.app
${CLIENT_EXECUTABLE}.app/Contents
${CLIENT_EXECUTABLE}.app/Contents/Frameworks
${CLIENT_EXECUTABLE}.app/Contents/MacOS
${CLIENT_EXECUTABLE}.app/Contents/Resources
${SERVER_EXECUTABLE}.app
${SERVER_EXECUTABLE}.app/Contents
${SERVER_EXECUTABLE}.app/Contents/MacOS
${SERVER_EXECUTABLE}.app/Contents/Resources
${SERVER_EXECUTABLE}.app/Contents/Resources/data
${SERVER_EXECUTABLE}.app/Contents/Resources/data/mapres
)
set(DMG_MKDIR_COMMANDS)
foreach(dir ${DMG_MKDIRS})
list(APPEND DMG_MKDIR_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory ${DMG_TMPDIR}/${dir})
endforeach()
set(TARGET_TOOLS_FILES)
foreach(target ${TARGET_TOOLS})
list(APPEND TARGET_TOOLS_FILES $<TARGET_FILE:${target}>)
endforeach()
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.dmg
COMMAND ${CMAKE_COMMAND} -E remove_directory ${DMG_TMPDIR}
${DMG_MKDIR_COMMANDS}
2017-11-16 09:28:55 +00:00
# CLIENT
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/data ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Resources/data
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/other/icons/${CLIENT_EXECUTABLE}.icns ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Resources/
COMMAND ${CMAKE_COMMAND} -E copy bundle/client/Info.plist ${PROJECT_SOURCE_DIR}/other/bundle/client/PkgInfo ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:game-client> ${TARGET_TOOLS_FILES} ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/MacOS/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ddnet-libs/sdl/${LIB_DIR}/SDL2.framework ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/SDL2.framework
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/discord/${LIB_DIR}/discord_game_sdk.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/freetype/${LIB_DIR}/libfreetype.6.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/png/${LIB_DIR}/libpng16.16.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavcodec.60.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavformat.60.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libavutil.58.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswresample.4.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/ffmpeg/${LIB_DIR}/libswscale.7.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/libsteam_api.dylib ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/Frameworks/
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/darwin_strip_rpath.py ${CMAKE_OTOOL} ${CMAKE_INSTALL_NAME_TOOL} ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/MacOS/${CLIENT_EXECUTABLE}
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath @loader_path/../Frameworks ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/MacOS/${CLIENT_EXECUTABLE}
2017-11-16 09:28:55 +00:00
# SERVER
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/data/maps ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/Resources/data/maps
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/other/icons/${SERVER_EXECUTABLE}.icns ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/Resources/
COMMAND ${CMAKE_COMMAND} -E copy bundle/server/Info.plist ${PROJECT_SOURCE_DIR}/other/bundle/server/PkgInfo ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:game-server> $<TARGET_FILE:game-server-launcher> ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/MacOS/
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/darwin_strip_rpath.py ${CMAKE_OTOOL} ${CMAKE_INSTALL_NAME_TOOL} ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/MacOS/${SERVER_EXECUTABLE}
COMMAND ${CMAKE_COMMAND} -E copy ${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app/Contents/MacOS/${SERVER_EXECUTABLE} ${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app/Contents/MacOS/${SERVER_EXECUTABLE}
2017-11-16 09:28:55 +00:00
# DMG
COMMAND dmgbuild -s ${PROJECT_SOURCE_DIR}/other/dmgsettings.py -D client=${DMG_TMPDIR}/${CLIENT_EXECUTABLE}.app -D server=${DMG_TMPDIR}/${SERVER_EXECUTABLE}.app -D background=${PROJECT_SOURCE_DIR}/other/dmgbackground.png "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}" ${CPACK_PACKAGE_FILE_NAME}.dmg
2017-11-17 21:32:44 +00:00
DEPENDS
game-client
2020-08-25 20:41:13 +00:00
${TARGET_STEAMAPI}
game-server-launcher
game-server
${PROJECT_BINARY_DIR}/bundle/client/Info.plist
${PROJECT_BINARY_DIR}/bundle/server/Info.plist
2017-11-17 21:32:44 +00:00
data
other/bundle/client/PkgInfo
other/bundle/server/PkgInfo
2021-12-26 23:34:37 +00:00
other/dmgbackground.png
other/dmgsettings.py
other/icons/${CLIENT_EXECUTABLE}.icns
other/icons/${SERVER_EXECUTABLE}.icns
)
add_custom_target(package_dmg DEPENDS ${CPACK_PACKAGE_FILE_NAME}.dmg)
list(APPEND PACKAGE_TARGETS package_dmg)
endif()
foreach(ext zip tar.gz tar.xz)
set(TAR_MODE c)
set(TAR_EXTRA_ARGS)
string(REPLACE . _ EXT_SLUG ${ext})
set(TMPDIR pack_${CPACK_PACKAGE_FILE_NAME}_${EXT_SLUG}/${CPACK_PACKAGE_FILE_NAME})
set(COPY_FILE_COMMANDS)
set(COPY_DIR_COMMANDS)
set(COPY_TARGET_COMMANDS)
2018-01-14 14:57:02 +00:00
set(STRIP_TARGET_COMMANDS)
foreach(file ${CPACK_FILES})
list(APPEND COPY_FILE_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/${file} ${TMPDIR}/)
endforeach()
2022-03-20 17:04:00 +00:00
foreach(file ${CPACK_GEN_FILES})
list(APPEND COPY_FILE_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${file} ${TMPDIR}/${file})
endforeach()
foreach(dir ${CPACK_DIRS})
list(APPEND COPY_DIR_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/${dir} ${TMPDIR}/${dir})
endforeach()
foreach(target ${CPACK_TARGETS})
list(APPEND COPY_TARGET_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${TMPDIR}/)
if(NOT TARGET_OS STREQUAL "mac")
list(APPEND STRIP_TARGET_COMMANDS COMMAND strip -s ${TMPDIR}/$<TARGET_FILE_NAME:${target}>)
endif()
endforeach()
if(ext STREQUAL zip)
set(TAR_EXTRA_ARGS --format=zip)
elseif(ext STREQUAL tar.gz)
set(TAR_MODE cz)
elseif(ext STREQUAL tar.xz)
set(TAR_MODE cJ)
endif()
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.${ext}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TMPDIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${TMPDIR}
${COPY_FILE_COMMANDS}
${COPY_DIR_COMMANDS}
${COPY_TARGET_COMMANDS}
2018-01-14 14:57:02 +00:00
${STRIP_TARGET_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E chdir pack_${CPACK_PACKAGE_FILE_NAME}_${EXT_SLUG} ${CMAKE_COMMAND} -E tar ${TAR_MODE} ../${CPACK_PACKAGE_FILE_NAME}.${ext} ${TAR_EXTRA_ARGS} -- ${CPACK_PACKAGE_FILE_NAME}/
DEPENDS ${CPACK_TARGETS}
)
add_custom_target(package_${EXT_SLUG} DEPENDS ${CPACK_PACKAGE_FILE_NAME}.${ext})
list(APPEND PACKAGE_TARGETS package_${EXT_SLUG})
endforeach()
set(PACKAGE_DEFAULT tar_xz)
if(TARGET_OS STREQUAL "windows")
set(PACKAGE_DEFAULT zip)
elseif(TARGET_OS STREQUAL "mac")
set(PACKAGE_DEFAULT dmg)
endif()
add_custom_target(package_default DEPENDS package_${PACKAGE_DEFAULT})
add_custom_target(package_all DEPENDS ${PACKAGE_TARGETS})
# Unset these variables, they might do something in the future of CPack.
unset(CPACK_SOURCE_FILES)
unset(CPACK_SOURCE_FILES_INVERTED)
unset(CPACK_TARGETS)
unset(CPACK_DIRS)
unset(CPACK_FILES)
2022-03-20 17:04:00 +00:00
unset(CPACK_GEN_FILES)
include(CPack)
########################################################################
2017-03-03 14:23:18 +00:00
# COMPILER-SPECIFICS
########################################################################
# In the future (CMake 3.8.0+), use source_group(TREE ...)
macro(source_group_tree dir)
file(GLOB ents RELATIVE ${PROJECT_SOURCE_DIR}/${dir} ${PROJECT_SOURCE_DIR}/${dir}/*)
foreach(ent ${ents})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${dir}/${ent})
source_group_tree(${dir}/${ent})
else()
string(REPLACE "/" "\\" group ${dir})
source_group(${group} FILES ${PROJECT_SOURCE_DIR}/${dir}/${ent})
endif()
endforeach()
endmacro()
source_group_tree(src)
2020-08-20 10:17:44 +00:00
if(ANTIBOT)
# Allow the antibot library to use functions from the server binary.
add_cxx_compiler_flag_if_supported(OUR_FLAGS_LINK -rdynamic)
set_own_rpath(game-server)
2020-08-20 10:17:44 +00:00
endif()
set(TARGETS ${TARGETS_OWN} ${TARGETS_DEP})
foreach(target ${TARGETS})
if(MSVC)
set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded$<${DBG}:Debug>) # Use static CRT
2017-03-12 15:27:34 +00:00
target_compile_options(${target} PRIVATE /MP) # Use multiple cores
target_compile_options(${target} PRIVATE /EHsc) # Only catch C++ exceptions with catch.
target_compile_options(${target} PRIVATE /GS) # Protect the stack pointer.
target_compile_options(${target} PRIVATE /wd4996) # Use of non-_s functions.
2022-02-15 14:01:02 +00:00
target_compile_options(${target} PRIVATE /utf-8) # Use UTF-8 for source files.
endif()
if(OUR_FLAGS_LINK)
target_link_libraries(${target} ${OUR_FLAGS_LINK})
endif()
if(OUR_FLAGS)
target_compile_options(${target} PRIVATE ${OUR_FLAGS})
endif()
if(DEFINE_FORTIFY_SOURCE)
if(MINGW)
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=0>) # Currently broken in MinGW, see https://sourceforge.net/p/mingw-w64/discussion/723798/thread/b9d24f041f/
else()
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>) # Detect some buffer overflows.
endif()
2017-07-26 02:30:56 +00:00
endif()
2022-05-07 09:23:29 +00:00
if(ENABLE_IPO)
set_property(TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
2017-07-26 02:30:56 +00:00
endforeach()
foreach(target ${TARGETS_LINK})
if(MSVC)
set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS /SAFESEH:NO) # Disable SafeSEH because the shipped libraries don't support it (would cause error LNK2026 otherwise).
endif()
2017-07-26 02:30:56 +00:00
if(TARGET_OS STREQUAL "mac")
target_link_libraries(${target} -stdlib=libc++)
target_link_libraries(${target} "-framework SystemConfiguration") # Required by curl 7.79.0
2017-07-26 02:30:56 +00:00
endif()
if((MINGW OR TARGET_OS STREQUAL "linux") AND PREFER_BUNDLED_LIBS)
# Statically link the standard libraries with on MinGW/Linux so we don't
# have to ship them as DLLs.
target_link_libraries(${target} -static-libgcc)
target_link_libraries(${target} -static-libstdc++)
endif()
endforeach()
foreach(target ${TARGETS_OWN})
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${target} PROPERTY CXX_EXTENSIONS OFF)
if(MSVC)
target_compile_options(${target} PRIVATE /wd4244) # Possible loss of data (float -> int, int -> float, etc.).
2017-03-12 15:23:17 +00:00
target_compile_options(${target} PRIVATE /wd4267) # Possible loss of data (size_t - int on win64).
target_compile_options(${target} PRIVATE /wd4800) # Implicit conversion of int to bool.
endif()
if(TARGET_OS STREQUAL "windows")
target_compile_definitions(${target} PRIVATE NOMINMAX) # windows.h shouldn't define min/max macros
target_compile_definitions(${target} PRIVATE UNICODE) # Windows headers
target_compile_definitions(${target} PRIVATE _UNICODE) # C-runtime
endif()
if(OUR_FLAGS_OWN)
target_compile_options(${target} PRIVATE ${OUR_FLAGS_OWN})
endif()
target_include_directories(${target} PRIVATE ${PROJECT_BINARY_DIR}/src)
target_include_directories(${target} PRIVATE src)
target_include_directories(${target} PRIVATE src/rust-bridge)
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:CONF_DEBUG>)
target_include_directories(${target} SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} ${SQLite3_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
2017-10-20 09:52:18 +00:00
target_compile_definitions(${target} PRIVATE GLEW_STATIC)
if(CRYPTO_FOUND)
target_compile_definitions(${target} PRIVATE CONF_OPENSSL)
target_include_directories(${target} SYSTEM PRIVATE ${CRYPTO_INCLUDE_DIRS})
endif()
if(WEBSOCKETS)
target_compile_definitions(${target} PRIVATE CONF_WEBSOCKETS)
target_include_directories(${target} SYSTEM PRIVATE ${WEBSOCKETS_INCLUDE_DIRS})
endif()
2020-04-14 10:11:50 +00:00
if(UPNP)
target_compile_definitions(${target} PRIVATE CONF_UPNP)
target_include_directories(${target} SYSTEM PRIVATE ${MINIUPNPC_INCLUDE_DIRS})
2020-04-14 10:11:50 +00:00
endif()
if(VIDEORECORDER)
2017-10-26 22:42:33 +00:00
target_compile_definitions(${target} PRIVATE CONF_VIDEORECORDER)
endif()
if(ANTIBOT)
target_compile_definitions(${target} PRIVATE CONF_ANTIBOT)
endif()
if(HEADLESS_CLIENT)
target_compile_definitions(${target} PRIVATE CONF_HEADLESS_CLIENT)
endif()
if(MYSQL)
2021-11-28 00:31:22 +00:00
target_compile_definitions(${target} PRIVATE CONF_MYSQL)
target_include_directories(${target} SYSTEM PRIVATE ${MYSQL_INCLUDE_DIRS})
endif()
if(TEST_MYSQL)
target_compile_definitions(${target} PRIVATE CONF_TEST_MYSQL)
endif()
if(AUTOUPDATE AND NOT STEAM)
target_compile_definitions(${target} PRIVATE CONF_AUTOUPDATE)
endif()
if(INFORM_UPDATE AND NOT STEAM)
target_compile_definitions(${target} PRIVATE CONF_INFORM_UPDATE)
endif()
if(STEAM)
target_compile_definitions(${target} PRIVATE PLATFORM_SUFFIX="-steam")
endif()
2021-01-02 16:10:31 +00:00
if(DISCORD)
target_compile_definitions(${target} PRIVATE CONF_DISCORD)
if(DISCORD_DYNAMIC)
target_compile_definitions(${target} PRIVATE CONF_DISCORD_DYNAMIC)
endif()
2021-01-02 16:10:31 +00:00
endif()
2023-10-06 16:07:53 +00:00
if(VERSION)
target_compile_definitions(${target} PRIVATE GAME_RELEASE_VERSION="${VERSION}")
endif()
2022-03-25 08:26:37 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
target_compile_definitions(${target} PRIVATE CONF_WEBASM)
endif()
endforeach()
2017-03-12 14:56:44 +00:00
foreach(target ${TARGETS_DEP})
if(MSVC)
target_compile_options(${target} PRIVATE /W0)
endif()
if(OUR_FLAGS_DEP)
target_compile_options(${target} PRIVATE ${OUR_FLAGS_DEP})
endif()
endforeach()