DarkflameServer/CMakeLists.txt
jadebenn 7b819d508b Squashed commit of the following:
commit f4311e593f
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Nov 16 22:16:50 2024 -0600

    temp fix for MSVC debug builds

commit 0e81c69de8
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Nov 16 21:11:04 2024 -0600

    CMakePresets indentation

commit d7aa52a0fc
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Nov 16 21:03:37 2024 -0600

    use DLU_CONFIG_DIR envvar

commit d1bfe9f15d
Merge: 6e781da2 de3fe931
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Nov 16 20:24:05 2024 -0600

    Merge branch 'main' into MSVCCompilerFlags

commit 6e781da2e7
Merge: 6ccd72c6 3a6123fe
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Apr 13 18:15:16 2024 -0500

    Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags

commit 6ccd72c6a9
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Apr 13 17:48:58 2024 -0500

    add RelWithDebInfo presets and move -Werror flag into presets.json

commit b96cfd71a4
Merge: c4adcee8 1ee45639
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Apr 9 01:47:17 2024 -0500

    Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags

commit c4adcee8e8
Merge: 7f9fcb5b 28ce8ac5
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 22:30:35 2024 -0500

    Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags

commit 7f9fcb5b75
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 22:10:01 2024 -0500

    change gnu and clang build directories to enable consistent artifact generation

commit 553740e8a0
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 21:38:34 2024 -0500

    update build presets

commit 39a8029fda
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 20:30:06 2024 -0500

    update github actions

commit 7eae64f8a6
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 20:18:46 2024 -0500

    disable /WX on MSVC

commit 24d3bc0ce6
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Mon Apr 8 20:11:59 2024 -0500

    altered cmake configuration scripts

commit 368f4ccabf
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Apr 6 23:00:04 2024 -0500

    change defaults

commit 7d7ea68bf9
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 22:23:32 2024 -0500

    fix preset

commit 57d0b12f9b
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Apr 6 21:50:32 2024 -0500

    expand cmake presets

commit aa62d357bb
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 20:50:26 2024 -0500

    rename gcc to gnu

commit d6e4edd886
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 20:27:20 2024 -0500

    change runtime output dir

commit abe413f239
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 20:22:47 2024 -0500

    debug try 2

commit c6c771b892
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 20:16:00 2024 -0500

    add debug messages (again)

commit 6c6966afd2
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 19:46:58 2024 -0500

    was not actually fixed

commit fab74c90b6
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 19:37:02 2024 -0500

    are these messages actually somehow fixing the issue?

commit a4b6b7c0d9
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 19:27:34 2024 -0500

    see if this re-breaks mac

commit 07626f8ebb
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 19:04:59 2024 -0500

    back to debug messages

commit bdf9adc0e8
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:55 2024 -0500

    Revert "try disabling an apple-specific build rule"

    This reverts commit 45ec66e976.

commit 8154207848
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:53 2024 -0500

    Revert "more fiddling with mac test builds"

    This reverts commit 0f843c02c9.

commit 8f5c10d158
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:52 2024 -0500

    Revert "try and narrow down the macos build failure cause"

    This reverts commit 5fd86833fa.

commit 54876bf886
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:50 2024 -0500

    Revert "try stripping out all the custom macos test logic again"

    This reverts commit cc15a26ce8.

commit 8af35727a6
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:48 2024 -0500

    Revert "I'm really just throwing everything to the wall and seeing what sticks"

    This reverts commit 1a05b027fe.

commit e143f22ada
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:46 2024 -0500

    Revert "more macos tinkering"

    This reverts commit 829ec35b57.

commit 495e70c376
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:44 2024 -0500

    Revert "implib"

    This reverts commit d41349d6ed.

commit 37dbb52104
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:42 2024 -0500

    Revert "try manual link directory specification"

    This reverts commit 0c2d40632e.

commit ce568189fc
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:40 2024 -0500

    Revert "save me"

    This reverts commit bd73aa21a9.

commit c420a72016
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:36 2024 -0500

    Revert "aaaaaaaaa"

    This reverts commit 338279c396.

commit dccac945bb
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:47:08 2024 -0500

    Revert "paths paths paths"

    This reverts commit 9a7d86aa6c.

commit 9a7d86aa6c
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:39:08 2024 -0500

    paths paths paths

commit 338279c396
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:29:01 2024 -0500

    aaaaaaaaa

commit bd73aa21a9
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:21:16 2024 -0500

    save me

commit 0c2d40632e
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 18:09:03 2024 -0500

    try manual link directory specification

commit d41349d6ed
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 17:52:20 2024 -0500

    implib

commit 829ec35b57
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 17:43:47 2024 -0500

    more macos tinkering

commit 1a05b027fe
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 17:18:41 2024 -0500

    I'm really just throwing everything to the wall and seeing what sticks

commit cc15a26ce8
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 17:09:45 2024 -0500

    try stripping out all the custom macos test logic again

commit 5fd86833fa
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 16:54:53 2024 -0500

    try and narrow down the macos build failure cause

commit 0f843c02c9
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 16:47:19 2024 -0500

    more fiddling with mac test builds

commit 45ec66e976
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 16:29:29 2024 -0500

    try disabling an apple-specific build rule

commit 6e41423dc3
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 04:01:07 2024 -0500

    one last MacOS try for the night

commit bc79a17ddb
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 03:50:41 2024 -0500

    try fixing macos build

commit d6031ce9f5
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 03:04:52 2024 -0500

    try zero-initializinng this struct to solve docker issue

commit 24cbd94a80
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Apr 6 02:34:36 2024 -0500

    attempted docker fix

commit 7812f27330
Merge: ef8029d4 18c27b14
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Fri Apr 5 23:32:29 2024 -0500

    Merge branch 'main' into MSVCCompilerFlags

commit ef8029d46f
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Fri Apr 5 23:30:26 2024 -0500

    update cmake configs

commit 04a7bc2b8d
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 21:00:23 2024 -0500

    edit build script

commit 9fc6b4e973
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 18:10:09 2024 -0500

    fix build directory issue

commit a19afaaab0
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 18:06:37 2024 -0500

    update .gitignore

commit 426d34a0aa
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 17:58:19 2024 -0500

    unexclude toolchain dir

commit 9ce7d9043c
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 17:55:02 2024 -0500

    updated cmake workflows

commit db5c10c331
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 16:58:00 2024 -0500

    temporarily remove macos build for testing purposes

commit f7da00ff89
Merge: 145f97cf 661e0939
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 16:51:39 2024 -0500

    Merge branch 'MSVCCompilerFlags' of https://github.com/jadebenn/DarkflameServer into MSVCCompilerFlags

commit 145f97cfdc
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Fri Apr 5 16:50:39 2024 -0500

    build reorganization and experimental clang support

commit 661e0939b7
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Wed Apr 3 22:13:11 2024 -0500

    fix typo in windows preset

commit 018e5707d7
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 20:30:33 2024 -0500

    try using compiler flags for mac instead

commit 81e5f059d5
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 20:20:31 2024 -0500

    macos refuses to work :(

commit a3d70197f2
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 20:13:37 2024 -0500

    try adding build types back to mac

commit 005d439a4a
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 19:58:44 2024 -0500

    edit macos presets

commit bba825f0c8
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 19:48:20 2024 -0500

    update CMake presets

commit 199c8224a5
Merge: 1116ba83 c1c5db65
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Wed Apr 3 19:00:39 2024 -0500

    Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags

commit 1116ba8306
Merge: 9316bd6e c7b3d9e8
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sun Feb 11 21:03:02 2024 -0600

    Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags

commit 9316bd6eeb
Merge: 62fb8ad0 29666a1f
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Feb 10 21:02:52 2024 -0600

    Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags

commit 62fb8ad071
Merge: d5089b72 24f94edf
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Thu Feb 8 21:41:50 2024 -0600

    Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags

commit d5089b72cc
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sun Feb 4 16:26:38 2024 -0600

    add Linux debug preset

commit 7c9f56ff76
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Sat Feb 3 16:02:53 2024 -0600

    move out g++ O2 flag

commit 6cc99fae42
Merge: 96276391 050184c5
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Sat Feb 3 02:41:43 2024 -0600

    Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags

commit 962763916d
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 22:00:49 2024 -0600

    export the compile commands so I can see if they're having any effect

commit 4b7d1d6593
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 21:49:24 2024 -0600

    trying 'init' flags instead

commit 3fa80063e9
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 21:13:47 2024 -0600

    ONE MORE TIME

commit ae2115c68d
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 20:52:33 2024 -0600

    final(?) try for now

commit 119937f5d9
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 20:34:44 2024 -0600

    ditto

commit ab39754597
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 20:34:41 2024 -0600

    testing if these even have any effect

commit e7058be3dc
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 20:28:05 2024 -0600

    third test

commit 10d7776fb2
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 19:33:59 2024 -0600

    trying more variations on the flags

commit 70f3756098
Author: jadebenn <jonahbenn@yahoo.com>
Date:   Tue Jan 30 18:49:46 2024 -0600

    testing

commit 9b7c593ae9
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Tue Jan 30 08:49:53 2024 -0600

    Update CMakePresets.json

commit 8a34544d0e
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Tue Jan 30 08:44:29 2024 -0600

    test moving flags to json

commit b682f13fa9
Merge: 2239507d d78b5087
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Mon Jan 29 22:49:29 2024 -0600

    Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags

commit 2239507d3c
Author: jadebenn <jadebenn@users.noreply.github.com>
Date:   Mon Jan 29 06:14:47 2024 -0600

    Add MSVC optimization flags
2024-11-17 12:33:15 -06:00

350 lines
11 KiB
CMake

cmake_minimum_required(VERSION 3.25)
project(Darkflame
HOMEPAGE_URL "https://github.com/DarkflameUniverse/DarkflameServer"
LANGUAGES C CXX
)
# check if the path to the source directory contains a space
if("${CMAKE_SOURCE_DIR}" MATCHES " ")
message(FATAL_ERROR "The server cannot build in the path (" ${CMAKE_SOURCE_DIR} ") because it contains a space. Please move the server to a path without spaces.")
endif()
include(CTest)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Export the compile commands for debugging
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # Set CMAKE visibility policy to NEW on project and subprojects
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) # Set C and C++ symbol visibility to hide inlined functions
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Read variables from file
FILE(READ "${CMAKE_SOURCE_DIR}/CMakeVariables.txt" variables)
string(REPLACE "\\\n" "" variables ${variables})
string(REPLACE "\n" ";" variables ${variables})
# Set the cmake variables, formatted as "VARIABLE #" in variables
foreach(variable ${variables})
# If the string contains a #, skip it
if(NOT "${variable}" MATCHES "#")
# Split the variable into name and value
string(REPLACE "=" ";" variable ${variable})
# Check that the length of the variable is 2 (name and value)
list(LENGTH variable length)
if(${length} EQUAL 2)
list(GET variable 0 variable_name)
list(GET variable 1 variable_value)
# Set the variable
set(${variable_name} ${variable_value})
message(STATUS "Variable: ${variable_name} = ${variable_value}")
endif()
endif()
endforeach()
# Set the version
set(PROJECT_VERSION "\"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}\"")
# Echo the version
message(STATUS "Version: ${PROJECT_VERSION}")
# Disable demo, tests and examples for recastNavigation. Turn these to ON if you want to use them
# This has to be done here to prevent a rare build error due to missing dependencies on the initial generations.
set(RECASTNAVIGATION_DEMO OFF CACHE BOOL "" FORCE)
set(RECASTNAVIGATION_TESTS OFF CACHE BOOL "" FORCE)
set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE)
# Compiler flags:
# Disabled deprecated warnings as the MySQL includes have deprecated code in them.
# Disabled misleading indentation as DL_LinkedList from RakNet has a weird indent.
# Disabled no-register
# Disabled unknown pragmas because Linux doesn't understand Windows pragmas.
if(UNIX)
add_compile_options("-fPIC")
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0 _GLIBCXX_USE_CXX17_ABI=0)
# For all except Clang and Apple Clang
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-static-libgcc" "-lstdc++fs")
endif()
if(${DYNAMIC} AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("-rdynamic")
endif()
if(${GGDB})
add_compile_options("-ggdb")
endif()
elseif(MSVC)
# Skip warning for invalid conversion from size_t to uint32_t for all targets below for now
# Also disable non-portable MSVC volatile behavior
add_compile_options("/wd4267" "/utf-8" "/volatile:iso" "/Zc:inline")
elseif(WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
# Our output dir
#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) # unfortunately, forces all libraries to be built in series, which will slow down the build process
# TODO make this not have to override the build type directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
find_package(MariaDB)
# Create a /resServer directory
make_directory(${CMAKE_BINARY_DIR}/resServer)
# Create a /logs directory
make_directory(${CMAKE_BINARY_DIR}/logs)
# Get DLU config directory
if(DEFINED ENV{DLU_CONFIG_DIR})
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
else()
set(DLU_CONFIG_DIR ${PROJECT_BINARY_DIR})
endif()
message(STATUS "Variable: DLU_CONFIG_DIR = ${DLU_CONFIG_DIR}")
# Copy resource files on first build
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf")
message(STATUS "Checking resource file integrity")
include(Utils)
UpdateConfigOption(${DLU_CONFIG_DIR}/authconfig.ini "port" "auth_server_port")
UpdateConfigOption(${DLU_CONFIG_DIR}/chatconfig.ini "port" "chat_server_port")
UpdateConfigOption(${DLU_CONFIG_DIR}/masterconfig.ini "port" "master_server_port")
foreach(resource_file ${RESOURCE_FILES})
set(file_size 0)
if(EXISTS ${DLU_CONFIG_DIR}/${resource_file})
file(SIZE ${DLU_CONFIG_DIR}/${resource_file} file_size)
endif()
if(${file_size} EQUAL 0)
configure_file(
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${DLU_CONFIG_DIR}/${resource_file}
COPYONLY
)
message(STATUS "Moved " ${resource_file} " to DLU config directory")
elseif(resource_file MATCHES ".ini")
message(STATUS "Checking " ${resource_file} " for missing config options")
file(READ ${DLU_CONFIG_DIR}/${resource_file} current_file_contents)
string(REPLACE "\\\n" "" current_file_contents ${current_file_contents})
string(REPLACE "\n" ";" current_file_contents ${current_file_contents})
set(parsed_current_file_contents "")
# Remove comment lines so they do not interfere with the variable parsing
foreach(line ${current_file_contents})
string(FIND ${line} "#" is_comment)
if(NOT ${is_comment} EQUAL 0)
string(APPEND parsed_current_file_contents ${line})
endif()
endforeach()
file(READ ${CMAKE_SOURCE_DIR}/resources/${resource_file} depot_file_contents)
string(REPLACE "\\\n" "" depot_file_contents ${depot_file_contents})
string(REPLACE "\n" ";" depot_file_contents ${depot_file_contents})
set(line_to_add "")
foreach(line ${depot_file_contents})
string(FIND ${line} "#" is_comment)
if(NOT ${is_comment} EQUAL 0)
string(REPLACE "=" ";" line_split ${line})
list(GET line_split 0 variable_name)
if(NOT ${parsed_current_file_contents} MATCHES ${variable_name})
message(STATUS "Adding missing config option " ${variable_name} " to " ${resource_file})
set(line_to_add ${line_to_add} ${line})
foreach(line_to_append ${line_to_add})
file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n" ${line_to_append})
endforeach()
file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n")
endif()
set(line_to_add "")
else()
set(line_to_add ${line_to_add} ${line})
endif()
endforeach()
endif()
endforeach()
message(STATUS "Resource file integrity check complete")
# if navmeshes directory does not exist, create it
if(NOT EXISTS ${PROJECT_BINARY_DIR}/navmeshes)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/navmeshes)
endif()
# Copy navmesh data on first build and extract it
configure_file(${CMAKE_SOURCE_DIR}/resources/navmeshes.zip ${PROJECT_BINARY_DIR}/navmeshes.zip COPYONLY)
file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PROJECT_BINARY_DIR}/navmeshes)
file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip)
# Copy vanity files on first build
set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml")
foreach(file ${VANITY_FILES})
configure_file("${CMAKE_SOURCE_DIR}/vanity/${file}" "${CMAKE_BINARY_DIR}/vanity/${file}" COPYONLY)
endforeach()
# Move our migrations for MasterServer to run
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/dlu/)
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql)
foreach(file ${SQL_FILES})
get_filename_component(file ${file} NAME)
configure_file(${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/dlu/${file})
endforeach()
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/cdserver/)
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/cdserver/*.sql)
foreach(file ${SQL_FILES})
get_filename_component(file ${file} NAME)
configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file})
endforeach()
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
if (APPLE)
include_directories("/usr/local/include/")
endif()
# Load all of our third party directories
add_subdirectory(thirdparty SYSTEM)
# Create our list of include directories
include_directories(
"dPhysics"
"dNavigation"
"dNet"
"tests"
"tests/dCommonTests"
"tests/dGameTests"
"tests/dGameTests/dComponentsTests"
SYSTEM
"thirdparty/magic_enum/include/magic_enum"
"thirdparty/raknet/Source"
"thirdparty/tinyxml2"
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
"thirdparty/cpp-httplib"
"thirdparty/MD5"
)
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
# TODO: Should probably not do this.
if(APPLE)
include_directories("/usr/local/include/")
endif()
# Set warning flags
if(MSVC)
# add_compile_options("/W4")
# Want to enable warnings eventually, but WAY too much noise right now
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
add_compile_options("-Wuninitialized" "-Wold-style-cast")
else()
message(WARNING "Unknown compiler: '${CMAKE_CXX_COMPILER_ID}' - No warning flags enabled.")
endif()
# Add linking directories:
file(
GLOB HEADERS_DZONEMANAGER
LIST_DIRECTORIES false
${PROJECT_SOURCE_DIR}/dZoneManager/*.h
)
file(
GLOB HEADERS_DCOMMON
LIST_DIRECTORIES false
${PROJECT_SOURCE_DIR}/dCommon/*.h
)
file(
GLOB HEADERS_DGAME
LIST_DIRECTORIES false
${PROJECT_SOURCE_DIR}/dGame/Entity.h
${PROJECT_SOURCE_DIR}/dGame/dGameMessages/GameMessages.h
${PROJECT_SOURCE_DIR}/dGame/EntityManager.h
${PROJECT_SOURCE_DIR}/dScripts/CppScripts.h
)
# Add our library subdirectories for creation of the library object
add_subdirectory(dCommon)
add_subdirectory(dDatabase)
add_subdirectory(dChatFilter)
add_subdirectory(dNet)
add_subdirectory(dScripts) # Add for dGame to use
add_subdirectory(dGame)
add_subdirectory(dZoneManager)
add_subdirectory(dNavigation)
add_subdirectory(dPhysics)
add_subdirectory(dServer)
# Create a list of common libraries shared between all binaries
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum")
# Add platform specific common libraries
if(UNIX)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "dl" "pthread")
if(NOT APPLE AND ${INCLUDE_BACKTRACE})
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "backtrace")
endif()
endif()
# Include all of our binary directories
add_subdirectory(dWorldServer)
add_subdirectory(dAuthServer)
add_subdirectory(dChatServer)
add_subdirectory(dMasterServer) # Add MasterServer last so it can rely on the other binaries
target_precompile_headers(
dZoneManager PRIVATE
${HEADERS_DZONEMANAGER}
)
target_precompile_headers(
dCommon PRIVATE
${HEADERS_DCOMMON}
)
target_precompile_headers(
tinyxml2 PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/tinyxml2.h>"
)
if(${ENABLE_TESTING})
add_subdirectory(tests)
endif()