diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fc44885d..9c734166 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -16,12 +16,12 @@ jobs: os: [ windows-2022, ubuntu-22.04, macos-13 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Add msbuild to PATH (Windows only) if: ${{ matrix.os == 'windows-2022' }} - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 with: vs-version: '[17,18)' msbuild-architecture: x64 @@ -33,21 +33,19 @@ jobs: - name: cmake uses: lukka/run-cmake@v10 with: - configurePreset: "ci-${{matrix.os}}" - buildPreset: "ci-${{matrix.os}}" - testPreset: "ci-${{matrix.os}}" + workflowPreset: "ci-${{matrix.os}}" - name: artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-${{matrix.os}} path: | - build/*Server* - build/*.ini - build/*.so - build/*.dll - build/vanity/ - build/navmeshes/ - build/migrations/ - build/*.dcf - !build/*.pdb - !build/d*/ + build/*/*Server* + build/*/*.ini + build/*/*.so + build/*/*.dll + build/*/vanity/ + build/*/navmeshes/ + build/*/migrations/ + build/*/*.dcf + !build/*/*.pdb + !build/*/d*/ diff --git a/.gitignore b/.gitignore index 12a3b284..0b0d2ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -122,4 +122,7 @@ docker/__pycache__ docker-compose.override.yml !*Test.bin + +# CMake scripts !cmake/* +!cmake/toolchains/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f8dbaf5..0d9d394b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.25) -project(Darkflame) +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 " ") @@ -8,8 +11,10 @@ endif() include(CTest) +set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 20) -set(CXX_STANDARD_REQUIRED ON) +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 @@ -61,35 +66,36 @@ set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE) # Disabled no-register # Disabled unknown pragmas because Linux doesn't understand Windows pragmas. if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wuninitialized -fPIC") + add_compile_options("-fPIC") add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0 _GLIBCXX_USE_CXX17_ABI=0) - if(NOT APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -lstdc++fs") + # 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") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") + add_compile_options("-rdynamic") endif() if(${GGDB}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb") + add_compile_options("-ggdb") endif() - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O2 -fPIC") 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") + 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_BINARY_DIR ${PROJECT_BINARY_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}) @@ -109,31 +115,39 @@ 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(${PROJECT_BINARY_DIR}/authconfig.ini "port" "auth_server_port") -UpdateConfigOption(${PROJECT_BINARY_DIR}/chatconfig.ini "port" "chat_server_port") -UpdateConfigOption(${PROJECT_BINARY_DIR}/masterconfig.ini "port" "master_server_port") +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 ${PROJECT_BINARY_DIR}/${resource_file}) - file(SIZE ${PROJECT_BINARY_DIR}/${resource_file} file_size) + 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} ${PROJECT_BINARY_DIR}/${resource_file} + ${CMAKE_SOURCE_DIR}/resources/${resource_file} ${DLU_CONFIG_DIR}/${resource_file} COPYONLY ) - message(STATUS "Moved " ${resource_file} " to project binary directory") + 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 ${PROJECT_BINARY_DIR}/${resource_file} current_file_contents) + 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 "") @@ -164,10 +178,10 @@ foreach(resource_file ${RESOURCE_FILES}) set(line_to_add ${line_to_add} ${line}) foreach(line_to_append ${line_to_add}) - file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n" ${line_to_append}) + file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n" ${line_to_append}) endforeach() - file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n") + file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n") endif() set(line_to_add "") @@ -236,14 +250,15 @@ include_directories( "tests/dGameTests" "tests/dGameTests/dComponentsTests" - SYSTEM "thirdparty/magic_enum/include/magic_enum" - SYSTEM "thirdparty/raknet/Source" - SYSTEM "thirdparty/tinyxml2" - SYSTEM "thirdparty/recastnavigation" - SYSTEM "thirdparty/SQLite" - SYSTEM "thirdparty/cpplinq" - SYSTEM "thirdparty/cpp-httplib" - SYSTEM "thirdparty/MD5" + 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) @@ -252,10 +267,17 @@ if(APPLE) include_directories("/usr/local/include/") endif() -# Add linking directories: -if (UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Werror") # Warning flags +# 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 diff --git a/CMakePresets.json b/CMakePresets.json index 2feabc53..c4595ed5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,128 +1,641 @@ { - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 14, - "patch": 0 - }, - "configurePresets": [ - { - "name": "default", - "displayName": "Default configure step", - "description": "Use 'build' dir and Unix makefiles", - "binaryDir": "${sourceDir}/build", - "generator": "Unix Makefiles" - }, - { - "name": "ci-ubuntu-22.04", - "displayName": "CI configure step for Ubuntu", - "description": "Same as default, Used in GitHub actions workflow", - "inherits": "default" - }, - { - "name": "ci-macos-13", - "displayName": "CI configure step for MacOS", - "description": "Same as default, Used in GitHub actions workflow", - "inherits": "default" - }, - { - "name": "ci-windows-2022", - "displayName": "CI configure step for Windows", - "description": "Set architecture to 64-bit (b/c RakNet)", - "inherits": "default", - "generator": "Visual Studio 17 2022", - "architecture": { - "value": "x64" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "windows-default", - "inherits": "ci-windows-2022", - "displayName": "Windows only Configure Settings", - "description": "Sets build and install directories", - "generator": "Ninja", - "architecture": { - "value": "x64", - "strategy": "external" - } - } - ], - "buildPresets": [ - { - "name": "default", - "configurePreset": "default", - "displayName": "Default Build", - "description": "Default Build", - "jobs": 2 - }, - { - "name": "ci-windows-2022", - "configurePreset": "ci-windows-2022", - "displayName": "Windows CI Build", - "description": "This preset is used by the CI build on windows", - "configuration": "RelWithDebInfo", - "jobs": 2 - }, - { - "name": "ci-ubuntu-22.04", - "configurePreset": "ci-ubuntu-22.04", - "displayName": "Linux CI Build", - "description": "This preset is used by the CI build on linux", - "jobs": 2 - }, - { - "name": "ci-macos-13", - "configurePreset": "ci-macos-13", - "displayName": "MacOS CI Build", - "description": "This preset is used by the CI build on MacOS", - "jobs": 2 - } - ], - "testPresets": [ - { - "name": "ci-ubuntu-22.04", - "configurePreset": "ci-ubuntu-22.04", - "displayName": "CI Tests on Linux", - "description": "Runs all tests on a linux configuration", - "execution": { - "jobs": 2 + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "displayName": "Default configure step", + "description": "Use 'build' dir and Unix makefiles", + "binaryDir": "${sourceDir}/build", + "environment": { + "DLU_CONFIG_DIR": "${sourceDir}/build" + }, + "generator": "Unix Makefiles" }, - "output": { - "outputOnFailure": true - } - }, - { - "name": "ci-macos-13", - "configurePreset": "ci-macos-13", - "displayName": "CI Tests on MacOS", - "description": "Runs all tests on a Mac configuration", - "execution": { - "jobs": 2 - }, - "output": { - "outputOnFailure": true - } - }, - { - "name": "ci-windows-2022", - "configurePreset": "ci-windows-2022", - "displayName": "CI Tests on windows", - "description": "Runs all tests on a windows configuration", - "configuration": "RelWithDebInfo", - "execution": { - "jobs": 2 - }, - "output": { - "outputOnFailure": true - }, - "filter": { - "exclude": { - "name": "((example)|(minigzip))+" + { + "name": "debug-config", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "relwithdebinfo-config", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "release-config", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "clang-config", + "hidden": true, + "toolchainFile": "${sourceDir}/cmake/toolchains/linux-clang.cmake" + }, + { + "name": "gnu-config", + "hidden": true, + "toolchainFile": "${sourceDir}/cmake/toolchains/linux-gnu.cmake" + }, + { + "name": "windows-msvc", + "inherits": "default", + "displayName": "[Multi] Windows (MSVC)", + "description": "Set architecture to 64-bit (b/c RakNet)", + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/build/msvc", + "architecture": { + "value": "x64" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "windows-default", + "inherits": "windows-msvc", + "displayName": "Windows only Configure Settings", + "description": "Sets build and install directories", + "generator": "Ninja", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "architecture": { + "value": "x64" + } + }, + { + "name": "linux-config", + "inherits": "default", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + } + }, + { + "name": "linux-clang-debug", + "inherits": [ + "linux-config", + "clang-config", + "debug-config" + ], + "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)", + "description": "Create a debug build using the Clang toolchain for Linux", + "binaryDir": "${sourceDir}/build/clang-debug" + }, + { + "name": "linux-clang-relwithdebinfo", + "inherits": [ + "linux-config", + "clang-config", + "relwithdebinfo-config" + ], + "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)", + "description": "Create a release build with debug info using the Clang toolchain for Linux", + "binaryDir": "${sourceDir}/build/clang-relwithdebinfo" + }, + { + "name": "linux-clang-release", + "inherits": [ + "linux-config", + "clang-config", + "release-config" + ], + "displayName": "EXPERIMENTAL - [Release] Linux (Clang)", + "description": "Create a release build using the Clang toolchain for Linux", + "binaryDir": "${sourceDir}/build/clang-release" + }, + { + "name": "linux-gnu-debug", + "inherits": [ + "linux-config", + "gnu-config", + "debug-config" + ], + "displayName": "[Debug] Linux (GNU)", + "description": "Create a debug build using the GNU toolchain for Linux", + "binaryDir": "${sourceDir}/build/gnu-debug" + }, + { + "name": "linux-gnu-relwithdebinfo", + "inherits": [ + "linux-config", + "gnu-config", + "relwithdebinfo-config" + ], + "displayName": "[RelWithDebInfo] Linux (GNU)", + "description": "Create a release build with debug info using the GNU toolchain for Linux", + "binaryDir": "${sourceDir}/build/gnu-relwithdebinfo" + }, + { + "name": "linux-gnu-release", + "inherits": [ + "linux-config", + "gnu-config", + "release-config" + ], + "displayName": "[Release] Linux (GNU)", + "description": "Create a release build using the GNU toolchain for Linux", + "binaryDir": "${sourceDir}/build/gnu-release" + }, + { + "name": "macos", + "inherits": "default", + "displayName": "[Multi] MacOS", + "description": "Create a build for MacOS", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, + "binaryDir": "${sourceDir}/build/macos" } - } - ] - } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default", + "displayName": "Default Build", + "description": "Default Build", + "jobs": 2 + }, + { + "name": "windows-msvc-debug", + "inherits": "default", + "configurePreset": "windows-msvc", + "displayName": "[Debug] Windows (MSVC)", + "description": "This preset is used to build in debug mode using the MSVC toolchain on Windows", + "configuration": "Debug" + }, + { + "name": "windows-msvc-relwithdebinfo", + "inherits": "default", + "configurePreset": "windows-msvc", + "displayName": "[RelWithDebInfo] Windows (MSVC)", + "description": "This preset is used to build in debug mode using the MSVC toolchain on Windows", + "configuration": "RelWithDebInfo" + }, + { + "name": "windows-msvc-release", + "inherits": "default", + "configurePreset": "windows-msvc", + "displayName": "[Release] Windows (MSVC)", + "description": "This preset is used to build in release mode using the MSVC toolchain on Windows", + "configuration": "Release" + }, + { + "name": "linux-clang-debug", + "inherits": "default", + "configurePreset": "linux-clang-debug", + "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)", + "description": "This preset is used to build in debug mode using the Clang toolchain on Linux", + "configuration": "Debug" + }, + { + "name": "linux-clang-relwithdebinfo", + "inherits": "default", + "configurePreset": "linux-clang-relwithdebinfo", + "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)", + "description": "This preset is used to build in release mode with debug info using the Clang toolchain on Linux", + "configuration": "RelWithDebInfo" + }, + { + "name": "linux-clang-release", + "inherits": "default", + "configurePreset": "linux-clang-release", + "displayName": "EXPERIMENTAL - [Release] Linux (Clang)", + "description": "This preset is used to build in release mode using the Clang toolchain on Linux", + "configuration": "Release" + }, + { + "name": "linux-gnu-debug", + "inherits": "default", + "configurePreset": "linux-gnu-debug", + "displayName": "[Debug] Linux (GNU)", + "description": "This preset is used to build in debug mode using the GNU toolchain on Linux", + "configuration": "Debug" + }, + { + "name": "linux-gnu-relwithdebinfo", + "inherits": "default", + "configurePreset": "linux-gnu-relwithdebinfo", + "displayName": "[RelWithDebInfo] Linux (GNU)", + "description": "This preset is used to build in release mode with debug info using the GNU toolchain on Linux", + "configuration": "RelWithDebInfo" + }, + { + "name": "linux-gnu-release", + "inherits": "default", + "configurePreset": "linux-gnu-release", + "displayName": "[Release] Linux (GNU)", + "description": "This preset is used to build in release mode using the GNU toolchain on Linux", + "configuration": "Release" + }, + { + "name": "macos-debug", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[Debug] MacOS", + "description": "This preset is used to build in debug mode on MacOS", + "configuration": "Debug" + }, + { + "name": "macos-relwithdebinfo", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[RelWithDebInfo] MacOS", + "description": "This preset is used to build in release mode with debug info on MacOS", + "configuration": "RelWithDebInfo" + }, + { + "name": "macos-release", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[Release] MacOS", + "description": "This preset is used to build in release mode on MacOS", + "configuration": "Release" + } + ], + "testPresets": [ + { + "name": "default", + "configurePreset": "default", + "execution": { + "jobs": 2 + }, + "output": { + "outputOnFailure": true + } + }, + { + "name": "windows-msvc-test", + "inherits": "default", + "configurePreset": "windows-msvc", + "hidden": true, + "filter": { + "exclude": { + "name": "((example)|(minigzip))+" + } + } + }, + { + "name": "windows-msvc-debug", + "inherits": "windows-msvc-test", + "configurePreset": "windows-msvc", + "displayName": "[Debug] Windows (MSVC)", + "description": "Runs all tests on a Windows configuration", + "configuration": "Debug" + }, + { + "name": "windows-msvc-relwithdebinfo", + "inherits": "windows-msvc-test", + "configurePreset": "windows-msvc", + "displayName": "[RelWithDebInfo] Windows (MSVC)", + "description": "Runs all tests on a Windows configuration", + "configuration": "RelWithDebInfo" + }, + { + "name": "windows-msvc-release", + "inherits": "windows-msvc-test", + "configurePreset": "windows-msvc", + "displayName": "[Release] Windows (MSVC)", + "description": "Runs all tests on a Windows configuration", + "configuration": "Release" + }, + { + "name": "linux-clang-debug", + "inherits": "default", + "configurePreset": "linux-clang-debug", + "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)", + "description": "Runs all tests on a Linux Clang configuration", + "configuration": "Release" + }, + { + "name": "linux-clang-relwithdebinfo", + "inherits": "default", + "configurePreset": "linux-clang-relwithdebinfo", + "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)", + "description": "Runs all tests on a Linux Clang configuration", + "configuration": "RelWithDebInfo" + }, + { + "name": "linux-clang-release", + "inherits": "default", + "configurePreset": "linux-clang-release", + "displayName": "EXPERIMENTAL - [Release] Linux (Clang)", + "description": "Runs all tests on a Linux Clang configuration", + "configuration": "Release" + }, + { + "name": "linux-gnu-debug", + "inherits": "default", + "configurePreset": "linux-gnu-debug", + "displayName": "[Debug] Linux (GNU)", + "description": "Runs all tests on a Linux GNU configuration", + "configuration": "Release" + }, + { + "name": "linux-gnu-relwithdebinfo", + "inherits": "default", + "configurePreset": "linux-gnu-relwithdebinfo", + "displayName": "[RelWithDebInfo] Linux (GNU)", + "description": "Runs all tests on a Linux GNU configuration", + "configuration": "RelWithDebInfo" + }, + { + "name": "linux-gnu-release", + "inherits": "default", + "configurePreset": "linux-gnu-release", + "displayName": "[Release] Linux (GNU)", + "description": "Runs all tests on a Linux GNU configuration", + "configuration": "Release" + }, + { + "name": "macos-debug", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[Debug] MacOS", + "description": "Runs all tests on a MacOS configuration", + "configuration": "Debug" + }, + { + "name": "macos-relwithdebinfo", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[RelWithDebInfo] MacOS", + "description": "Runs all tests on a MacOS configuration", + "configuration": "RelWithDebInfo" + }, + { + "name": "macos-release", + "inherits": "default", + "configurePreset": "macos", + "displayName": "[Release] MacOS", + "description": "Runs all tests on a MacOS configuration", + "configuration": "Release" + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + } + ] + }, + { + "name": "windows-msvc-debug", + "displayName": "[Debug] Windows (MSVC)", + "description": "MSVC debug workflow preset for Windows", + "steps": [ + { + "type": "configure", + "name": "windows-msvc" + }, + { + "type": "build", + "name": "windows-msvc-debug" + }, + { + "type": "test", + "name": "windows-msvc-debug" + } + ] + }, + { + "name": "windows-msvc-relwithdebinfo", + "displayName": "[RelWithDebInfo] Windows (MSVC)", + "description": "MSVC release with debug info workflow preset for Windows", + "steps": [ + { + "type": "configure", + "name": "windows-msvc" + }, + { + "type": "build", + "name": "windows-msvc-relwithdebinfo" + }, + { + "type": "test", + "name": "windows-msvc-relwithdebinfo" + } + ] + }, + { + "name": "ci-windows-2022", + "displayName": "[Release] Windows (MSVC)", + "description": "CI workflow preset for Windows", + "steps": [ + { + "type": "configure", + "name": "windows-msvc" + }, + { + "type": "build", + "name": "windows-msvc-release" + }, + { + "type": "test", + "name": "windows-msvc-release" + } + ] + }, + { + "name": "linux-gnu-debug", + "displayName": "[Debug] Linux (GNU)", + "description": "GNU debug workflow preset for Linux", + "steps": [ + { + "type": "configure", + "name": "linux-gnu-debug" + }, + { + "type": "build", + "name": "linux-gnu-debug" + }, + { + "type": "test", + "name": "linux-gnu-debug" + } + ] + }, + { + "name": "linux-gnu-relwithdebinfo", + "displayName": "[RelWithDebInfo] Linux (GNU)", + "description": "GNU release with debug info workflow preset for Linux", + "steps": [ + { + "type": "configure", + "name": "linux-gnu-relwithdebinfo" + }, + { + "type": "build", + "name": "linux-gnu-relwithdebinfo" + }, + { + "type": "test", + "name": "linux-gnu-relwithdebinfo" + } + ] + }, + { + "name": "ci-ubuntu-22.04", + "displayName": "[Release] Linux (GNU)", + "description": "CI workflow preset for Ubuntu", + "steps": [ + { + "type": "configure", + "name": "linux-gnu-release" + }, + { + "type": "build", + "name": "linux-gnu-release" + }, + { + "type": "test", + "name": "linux-gnu-release" + } + ] + }, + { + "name": "linux-clang-debug", + "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)", + "description": "Clang debug workflow preset for Linux", + "steps": [ + { + "type": "configure", + "name": "linux-clang-debug" + }, + { + "type": "build", + "name": "linux-clang-debug" + }, + { + "type": "test", + "name": "linux-clang-debug" + } + ] + }, + { + "name": "linux-clang-relwithdebinfo", + "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)", + "description": "Clang release with debug info workflow preset for Linux", + "steps": [ + { + "type": "configure", + "name": "linux-clang-relwithdebinfo" + }, + { + "type": "build", + "name": "linux-clang-relwithdebinfo" + }, + { + "type": "test", + "name": "linux-clang-relwithdebinfo" + } + ] + }, + { + "name": "linux-clang-release", + "displayName": "EXPERIMENTAL - [Release] Linux (Clang)", + "description": "Clang release workflow preset for Linux", + "steps": [ + { + "type": "configure", + "name": "linux-clang-release" + }, + { + "type": "build", + "name": "linux-clang-release" + }, + { + "type": "test", + "name": "linux-clang-release" + } + ] + }, + { + "name": "macos-debug", + "displayName": "[Debug] MacOS", + "description": "Release workflow preset for MacOS", + "steps": [ + { + "type": "configure", + "name": "macos" + }, + { + "type": "build", + "name": "macos-debug" + }, + { + "type": "test", + "name": "macos-debug" + } + ] + }, + { + "name": "macos-relwithdebinfo", + "displayName": "[RelWithDebInfo] MacOS", + "description": "Release with debug info workflow preset for MacOS", + "steps": [ + { + "type": "configure", + "name": "macos" + }, + { + "type": "build", + "name": "macos-relwithdebinfo" + }, + { + "type": "test", + "name": "macos-relwithdebinfo" + } + ] + }, + { + "name": "ci-macos-13", + "displayName": "[Release] MacOS", + "description": "CI workflow preset for MacOS", + "steps": [ + { + "type": "configure", + "name": "macos" + }, + { + "type": "build", + "name": "macos-release" + }, + { + "type": "test", + "name": "macos-release" + } + ] + } + ] +} diff --git a/build.sh b/build.sh index b8d33492..3f36e8a3 100755 --- a/build.sh +++ b/build.sh @@ -6,8 +6,7 @@ mkdir -p build cd build # Run cmake to generate make files -cmake .. +cmake -DCMAKE_BUILD_TYPE="Release" .. # To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `cmake --build . --config Release -j8' cmake --build . --config Release $1 - diff --git a/cmake/toolchains/linux-clang.cmake b/cmake/toolchains/linux-clang.cmake new file mode 100644 index 00000000..63bf92fc --- /dev/null +++ b/cmake/toolchains/linux-clang.cmake @@ -0,0 +1,14 @@ +# Try and find a clang-16 install, falling back to a generic clang install otherwise +find_program(CLANG_C_COMPILER clang-16 | clang REQUIRED) +find_program(CLANG_CXX_COMPILER clang++-16 | clang++ REQUIRED) + +# Debug messages +message(DEBUG "CLANG_C_COMPILER = ${CLANG_C_COMPILER}") +message(DEBUG "CLANG_CXX_COMPILER = ${CLANG_CXX_COMPILER}") + +# Set compilers to clang +set(CMAKE_C_COMPILER ${CLANG_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER}) + +# Set linker to lld +add_link_options("-fuse-ld=lld") diff --git a/cmake/toolchains/linux-gnu.cmake b/cmake/toolchains/linux-gnu.cmake new file mode 100644 index 00000000..7a60c81f --- /dev/null +++ b/cmake/toolchains/linux-gnu.cmake @@ -0,0 +1,11 @@ +# Try and find a gcc/g++ install +find_program(GNU_C_COMPILER cc | gcc REQUIRED) +find_program(GNU_CXX_COMPILER c++ | g++ REQUIRED) + +# Debug messages +message(DEBUG "GNU_C_COMPILER = ${GNU_C_COMPILER}") +message(DEBUG "GNU_CXX_COMPILER = ${GNU_C_COMPILER}") + +# Set compilers to clang +set(CMAKE_C_COMPILER ${GNU_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${GNU_CXX_COMPILER}) diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 6043fe63..8ae9246d 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -102,7 +102,7 @@ void VanityUtilities::SpawnVanity() { } LWOOBJID SpawnSpawner(const VanityObject& object, const VanityObjectLocation& location) { - SceneObject obj; + SceneObject obj{}; obj.lot = object.m_LOT; // guratantee we have no collisions do { @@ -268,7 +268,7 @@ void ParseXml(const std::string& file) { for (auto* location = locations->FirstChildElement("location"); location != nullptr; location = location->NextSiblingElement("location")) { - + // Get the location data auto zoneID = GeneralUtils::TryParse(location->Attribute("zone")); auto x = GeneralUtils::TryParse(location->Attribute("x")); diff --git a/dMasterServer/CMakeLists.txt b/dMasterServer/CMakeLists.txt index 260e4f16..2e2b4dd9 100644 --- a/dMasterServer/CMakeLists.txt +++ b/dMasterServer/CMakeLists.txt @@ -6,7 +6,7 @@ set(DMASTERSERVER_SOURCES add_library(dMasterServer ${DMASTERSERVER_SOURCES}) add_executable(MasterServer "MasterServer.cpp") -add_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") +target_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") target_include_directories(dMasterServer PUBLIC "." "${PROJECT_SOURCE_DIR}/dZoneManager" # InstanceManager.h uses dZMCommon.h ${PROJECT_SOURCE_DIR}/dServer/ # BinaryPathFinder.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e8765191..24adec61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,8 +4,6 @@ enable_testing() find_package(GoogleTest REQUIRED) include(GoogleTest) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) - if(APPLE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True) set(CMAKE_BUILD_WITH_INSTALL_RPATH True) diff --git a/tests/dCommonTests/AMFDeserializeTests.cpp b/tests/dCommonTests/AMFDeserializeTests.cpp index c949ae50..fb9e5a4f 100644 --- a/tests/dCommonTests/AMFDeserializeTests.cpp +++ b/tests/dCommonTests/AMFDeserializeTests.cpp @@ -176,7 +176,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) { /** * @brief This test checks that if we recieve an unimplemented eAmf * we correctly throw an error and can actch it. - * Yes this leaks memory. + * Yes this leaks memory. */ TEST(dCommonTests, AMFDeserializeUnimplementedValuesTest) { std::vector unimplementedValues = { @@ -363,7 +363,7 @@ TEST(dCommonTests, AMFBadConversionTest) { ASSERT_EQ(result->Get("BehaviorID"), nullptr); // Does not exist in the associative portion - ASSERT_EQ(result->Get("DOES_NOT_EXIST"), nullptr); + ASSERT_EQ(result->Get("DOES_NOT_EXIST"), nullptr); result->Push(true); diff --git a/tests/dCommonTests/Amf3Tests.cpp b/tests/dCommonTests/Amf3Tests.cpp index 5b52cf27..79d0d496 100644 --- a/tests/dCommonTests/Amf3Tests.cpp +++ b/tests/dCommonTests/Amf3Tests.cpp @@ -78,7 +78,7 @@ TEST(dCommonTests, AMF3InsertionAssociativeTest) { ASSERT_EQ(array.Get("Integer")->GetValueType(), eAmf::Integer); ASSERT_EQ(array.Get("Double")->GetValueType(), eAmf::Double); ASSERT_EQ(array.GetArray("Array")->GetValueType(), eAmf::Array); - ASSERT_EQ(array.Get("Null")->GetValueType(), eAmf::Null); + ASSERT_EQ(array.Get("Null")->GetValueType(), eAmf::Null); ASSERT_EQ(array.Get>("Undefined")->GetValueType(), eAmf::Undefined); } @@ -101,6 +101,6 @@ TEST(dCommonTests, AMF3InsertionDenseTest) { ASSERT_EQ(array.Get(4)->GetValueType(), eAmf::Integer); ASSERT_EQ(array.Get(5)->GetValueType(), eAmf::Double); ASSERT_EQ(array.GetArray(6)->GetValueType(), eAmf::Array); - ASSERT_EQ(array.Get(7)->GetValueType(), eAmf::Null); + ASSERT_EQ(array.Get(7)->GetValueType(), eAmf::Null); ASSERT_EQ(array.Get>(8)->GetValueType(), eAmf::Undefined); } diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index f6056476..79863a53 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -25,7 +25,7 @@ endif() # Need to define this on Clang and GNU for 'strdup' support if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - target_compile_definitions(bcrypt PRIVATE "_POSIX_C_SOURCE=200809L") + target_compile_definitions(bcrypt PRIVATE "_POSIX_C_SOURCE=200809L") endif() target_include_directories(bcrypt INTERFACE "libbcrypt/include") diff --git a/thirdparty/SQLite/CMakeLists.txt b/thirdparty/SQLite/CMakeLists.txt index 3aa066a4..e745c46a 100644 --- a/thirdparty/SQLite/CMakeLists.txt +++ b/thirdparty/SQLite/CMakeLists.txt @@ -11,7 +11,7 @@ if(UNIX) # -Wno-unused-result -Wno-unknown-pragmas -fpermissive target_compile_options(sqlite3 PRIVATE) - if(NOT APPLE) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(sqlite3 PRIVATE "-Wno-return-local-addr" "-Wno-maybe-uninitialized") else() target_compile_options(sqlite3 PRIVATE "-Wno-return-stack-address" "-Wno-uninitialized" "-Wno-deprecated-declarations")