From 7b819d508bdb55833a24e7633b1675955e344d32 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sun, 17 Nov 2024 12:33:15 -0600 Subject: [PATCH] Squashed commit of the following: commit f4311e593faa00381a50e4ca363e0b6753cadb1d Author: jadebenn Date: Sat Nov 16 22:16:50 2024 -0600 temp fix for MSVC debug builds commit 0e81c69de858809de72c97ef1aa285711b303938 Author: jadebenn Date: Sat Nov 16 21:11:04 2024 -0600 CMakePresets indentation commit d7aa52a0fcd0db5225b5f807a59c2b63d16b7486 Author: jadebenn Date: Sat Nov 16 21:03:37 2024 -0600 use DLU_CONFIG_DIR envvar commit d1bfe9f15d933eaaebd86a912a76776a647d5911 Merge: 6e781da2 de3fe931 Author: jadebenn Date: Sat Nov 16 20:24:05 2024 -0600 Merge branch 'main' into MSVCCompilerFlags commit 6e781da2e7cdea4d5b449ee362a8ab719fd1c3cd Merge: 6ccd72c6 3a6123fe Author: jadebenn Date: Sat Apr 13 18:15:16 2024 -0500 Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags commit 6ccd72c6a901b39612b524a7bb7cebf3b38c085c Author: jadebenn Date: Sat Apr 13 17:48:58 2024 -0500 add RelWithDebInfo presets and move -Werror flag into presets.json commit b96cfd71a43f3d28736170816814a010c918f9f9 Merge: c4adcee8 1ee45639 Author: jadebenn Date: Tue Apr 9 01:47:17 2024 -0500 Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags commit c4adcee8e812efdfa3d840b96c6de9e6af4265e7 Merge: 7f9fcb5b 28ce8ac5 Author: jadebenn Date: Mon Apr 8 22:30:35 2024 -0500 Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags commit 7f9fcb5b758c697d9ea75bb5cfb1720e000670d5 Author: jadebenn Date: Mon Apr 8 22:10:01 2024 -0500 change gnu and clang build directories to enable consistent artifact generation commit 553740e8a0a899e8c261501e6c24f3f27b951ccc Author: jadebenn Date: Mon Apr 8 21:38:34 2024 -0500 update build presets commit 39a8029fdabd4787394ae185b84340cda6561af2 Author: jadebenn Date: Mon Apr 8 20:30:06 2024 -0500 update github actions commit 7eae64f8a6caa1462ce285ef1f55109a1aa5d5db Author: jadebenn Date: Mon Apr 8 20:18:46 2024 -0500 disable /WX on MSVC commit 24d3bc0ce65776671ce850e4535d1c4110089372 Author: jadebenn Date: Mon Apr 8 20:11:59 2024 -0500 altered cmake configuration scripts commit 368f4ccabf576f4dc00f16e0c25646f46c2182b7 Author: jadebenn Date: Sat Apr 6 23:00:04 2024 -0500 change defaults commit 7d7ea68bf9af88cc0f8565f334912638e18edc65 Author: jadebenn Date: Sat Apr 6 22:23:32 2024 -0500 fix preset commit 57d0b12f9b07caf3173be04587125fe4eca33fb1 Author: jadebenn Date: Sat Apr 6 21:50:32 2024 -0500 expand cmake presets commit aa62d357bb133c6a770572bc3bcad8442941fc9a Author: jadebenn Date: Sat Apr 6 20:50:26 2024 -0500 rename gcc to gnu commit d6e4edd886c0d38d465728584a76dc2569a2b5e4 Author: jadebenn Date: Sat Apr 6 20:27:20 2024 -0500 change runtime output dir commit abe413f239c2d4ac82b98621b3948fc0822e01f3 Author: jadebenn Date: Sat Apr 6 20:22:47 2024 -0500 debug try 2 commit c6c771b892d713d789a3fb4fb008693522af845b Author: jadebenn Date: Sat Apr 6 20:16:00 2024 -0500 add debug messages (again) commit 6c6966afd25494897dd9c3c20b5d44160c557268 Author: jadebenn Date: Sat Apr 6 19:46:58 2024 -0500 was not actually fixed commit fab74c90b645d77765004521fa8109af02118843 Author: jadebenn Date: Sat Apr 6 19:37:02 2024 -0500 are these messages actually somehow fixing the issue? commit a4b6b7c0d9b905dc53d5c34668d312c0a39a4e6c Author: jadebenn Date: Sat Apr 6 19:27:34 2024 -0500 see if this re-breaks mac commit 07626f8ebba098d7ed04b0269666774c291683df Author: jadebenn Date: Sat Apr 6 19:04:59 2024 -0500 back to debug messages commit bdf9adc0e84bfad8bdec408af7f55c7dd0c8f1d4 Author: jadebenn Date: Sat Apr 6 18:47:55 2024 -0500 Revert "try disabling an apple-specific build rule" This reverts commit 45ec66e97605e3ea5b0a76f6eed0ec6f955c1675. commit 8154207848918ae5d2d13edc90522c104479f242 Author: jadebenn Date: Sat Apr 6 18:47:53 2024 -0500 Revert "more fiddling with mac test builds" This reverts commit 0f843c02c90b2aa5f0c211e19c47b00798c295c8. commit 8f5c10d15806b0b9f5e425e146f67bc3da4b34ca Author: jadebenn Date: Sat Apr 6 18:47:52 2024 -0500 Revert "try and narrow down the macos build failure cause" This reverts commit 5fd86833fa6e421860496c3626415ab70c93a795. commit 54876bf886b16f7c217af82aa805cf85321f369e Author: jadebenn Date: Sat Apr 6 18:47:50 2024 -0500 Revert "try stripping out all the custom macos test logic again" This reverts commit cc15a26ce80ff9cfec5f1a94b0c00c42e1832c55. commit 8af35727a6038eb29d60d0fcebdebb536e6417f0 Author: jadebenn 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 1a05b027fe822a94e5a6b70e6c744623d6a98e61. commit e143f22adafa82cfa3462869f0842f2acbdbdebb Author: jadebenn Date: Sat Apr 6 18:47:46 2024 -0500 Revert "more macos tinkering" This reverts commit 829ec35b57983ad4444d90ab780fff95a8b47608. commit 495e70c37641673f420bd6589e3706247eb741fd Author: jadebenn Date: Sat Apr 6 18:47:44 2024 -0500 Revert "implib" This reverts commit d41349d6edada6a041c64971730eed1c51af14c5. commit 37dbb52104917116a344b86dab90160f5b43411d Author: jadebenn Date: Sat Apr 6 18:47:42 2024 -0500 Revert "try manual link directory specification" This reverts commit 0c2d40632ee5df9c241532d8bf62de9969e47f51. commit ce568189fca00cccae412ee81593ec74b760781b Author: jadebenn Date: Sat Apr 6 18:47:40 2024 -0500 Revert "save me" This reverts commit bd73aa21a9cd1625f7cf567ab5b56bde46c0af0e. commit c420a72016df072a7bd190ca3d4106ef0af9a202 Author: jadebenn Date: Sat Apr 6 18:47:36 2024 -0500 Revert "aaaaaaaaa" This reverts commit 338279c396e7c4a78174929a0aaf5205f2c026e6. commit dccac945bb100289cd0bff67e071563cc51bf7e8 Author: jadebenn Date: Sat Apr 6 18:47:08 2024 -0500 Revert "paths paths paths" This reverts commit 9a7d86aa6c59e73de27fbcda2111f7a1472008f4. commit 9a7d86aa6c59e73de27fbcda2111f7a1472008f4 Author: jadebenn Date: Sat Apr 6 18:39:08 2024 -0500 paths paths paths commit 338279c396e7c4a78174929a0aaf5205f2c026e6 Author: jadebenn Date: Sat Apr 6 18:29:01 2024 -0500 aaaaaaaaa commit bd73aa21a9cd1625f7cf567ab5b56bde46c0af0e Author: jadebenn Date: Sat Apr 6 18:21:16 2024 -0500 save me commit 0c2d40632ee5df9c241532d8bf62de9969e47f51 Author: jadebenn Date: Sat Apr 6 18:09:03 2024 -0500 try manual link directory specification commit d41349d6edada6a041c64971730eed1c51af14c5 Author: jadebenn Date: Sat Apr 6 17:52:20 2024 -0500 implib commit 829ec35b57983ad4444d90ab780fff95a8b47608 Author: jadebenn Date: Sat Apr 6 17:43:47 2024 -0500 more macos tinkering commit 1a05b027fe822a94e5a6b70e6c744623d6a98e61 Author: jadebenn Date: Sat Apr 6 17:18:41 2024 -0500 I'm really just throwing everything to the wall and seeing what sticks commit cc15a26ce80ff9cfec5f1a94b0c00c42e1832c55 Author: jadebenn Date: Sat Apr 6 17:09:45 2024 -0500 try stripping out all the custom macos test logic again commit 5fd86833fa6e421860496c3626415ab70c93a795 Author: jadebenn Date: Sat Apr 6 16:54:53 2024 -0500 try and narrow down the macos build failure cause commit 0f843c02c90b2aa5f0c211e19c47b00798c295c8 Author: jadebenn Date: Sat Apr 6 16:47:19 2024 -0500 more fiddling with mac test builds commit 45ec66e97605e3ea5b0a76f6eed0ec6f955c1675 Author: jadebenn Date: Sat Apr 6 16:29:29 2024 -0500 try disabling an apple-specific build rule commit 6e41423dc3b3bd9366ca769cb13d69ab274877dc Author: jadebenn Date: Sat Apr 6 04:01:07 2024 -0500 one last MacOS try for the night commit bc79a17ddb50df28148ca128eabe41c04ec40572 Author: jadebenn Date: Sat Apr 6 03:50:41 2024 -0500 try fixing macos build commit d6031ce9f5d9686673ef1cf4b5629dfffc311d6d Author: jadebenn Date: Sat Apr 6 03:04:52 2024 -0500 try zero-initializinng this struct to solve docker issue commit 24cbd94a80ac8aac6a72c18b04c9b5bef374a505 Author: jadebenn Date: Sat Apr 6 02:34:36 2024 -0500 attempted docker fix commit 7812f27330c3bd88519b984ceb6b4e0710279ef2 Merge: ef8029d4 18c27b14 Author: jadebenn Date: Fri Apr 5 23:32:29 2024 -0500 Merge branch 'main' into MSVCCompilerFlags commit ef8029d46fa01a41470cad2135bd9543eea0530a Author: jadebenn Date: Fri Apr 5 23:30:26 2024 -0500 update cmake configs commit 04a7bc2b8da3e59d8dc19855b654a6833a571614 Author: jadebenn Date: Fri Apr 5 21:00:23 2024 -0500 edit build script commit 9fc6b4e97330c054409d3211fba92de2e0ea7f2a Author: jadebenn Date: Fri Apr 5 18:10:09 2024 -0500 fix build directory issue commit a19afaaab0fc0fb3efae7d1e6d9caf167ef278da Author: jadebenn Date: Fri Apr 5 18:06:37 2024 -0500 update .gitignore commit 426d34a0aa2ef9ef9c520facfe0e0ef816d58a77 Author: jadebenn Date: Fri Apr 5 17:58:19 2024 -0500 unexclude toolchain dir commit 9ce7d9043c5159998620b9f9d731ca6f61aae0d7 Author: jadebenn Date: Fri Apr 5 17:55:02 2024 -0500 updated cmake workflows commit db5c10c331491c1e4866652603107b21701b3d0c Author: jadebenn Date: Fri Apr 5 16:58:00 2024 -0500 temporarily remove macos build for testing purposes commit f7da00ff89a6decdd7fc2848e6539cfcc5b64caa Merge: 145f97cf 661e0939 Author: jadebenn Date: Fri Apr 5 16:51:39 2024 -0500 Merge branch 'MSVCCompilerFlags' of https://github.com/jadebenn/DarkflameServer into MSVCCompilerFlags commit 145f97cfdcfc7f5229342e926a29960bdefe6d51 Author: jadebenn Date: Fri Apr 5 16:50:39 2024 -0500 build reorganization and experimental clang support commit 661e0939b7e5f80c44a2ed08293e3c558738dbfc Author: jadebenn Date: Wed Apr 3 22:13:11 2024 -0500 fix typo in windows preset commit 018e5707d78a866ab78a2f087cc7c22c6c0d00ca Author: jadebenn Date: Wed Apr 3 20:30:33 2024 -0500 try using compiler flags for mac instead commit 81e5f059d53575593a06291a580eec6da0de55fc Author: jadebenn Date: Wed Apr 3 20:20:31 2024 -0500 macos refuses to work :( commit a3d70197f2c7d79cee190aca382c915a1dd04ff9 Author: jadebenn Date: Wed Apr 3 20:13:37 2024 -0500 try adding build types back to mac commit 005d439a4a13728b52712aadfd3a41a4ce365877 Author: jadebenn Date: Wed Apr 3 19:58:44 2024 -0500 edit macos presets commit bba825f0c8622e8023f5e0e531c30b0c38d15da1 Author: jadebenn Date: Wed Apr 3 19:48:20 2024 -0500 update CMake presets commit 199c8224a59cacd70ebb238c6b9bcbb7cb5f05ee Merge: 1116ba83 c1c5db65 Author: jadebenn Date: Wed Apr 3 19:00:39 2024 -0500 Merge remote-tracking branch 'upstream/main' into MSVCCompilerFlags commit 1116ba8306bb56db0765b6a7e2cbdca5b3d20594 Merge: 9316bd6e c7b3d9e8 Author: jadebenn Date: Sun Feb 11 21:03:02 2024 -0600 Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags commit 9316bd6eeb56947355b4f0bf975a4236fb8c6855 Merge: 62fb8ad0 29666a1f Author: jadebenn Date: Sat Feb 10 21:02:52 2024 -0600 Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags commit 62fb8ad071a15fd5236c93648f17f4553b8e0fd8 Merge: d5089b72 24f94edf Author: jadebenn Date: Thu Feb 8 21:41:50 2024 -0600 Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags commit d5089b72cc667bb8ba47b370ef5b33589ae856fa Author: jadebenn Date: Sun Feb 4 16:26:38 2024 -0600 add Linux debug preset commit 7c9f56ff76bed9d33d577d78b9dc8060b3ac373a Author: jadebenn Date: Sat Feb 3 16:02:53 2024 -0600 move out g++ O2 flag commit 6cc99fae42193560dd2c99fd54820b604bf0b242 Merge: 96276391 050184c5 Author: jadebenn Date: Sat Feb 3 02:41:43 2024 -0600 Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags commit 962763916d301cee21fa675d6743ced871c53fa1 Author: jadebenn Date: Tue Jan 30 22:00:49 2024 -0600 export the compile commands so I can see if they're having any effect commit 4b7d1d65937d6261fe505950b055a8e03577a087 Author: jadebenn Date: Tue Jan 30 21:49:24 2024 -0600 trying 'init' flags instead commit 3fa80063e926fa70222f23f9b00860ff7a31026b Author: jadebenn Date: Tue Jan 30 21:13:47 2024 -0600 ONE MORE TIME commit ae2115c68d18b2b12bf4435764248a2bba2f7d68 Author: jadebenn Date: Tue Jan 30 20:52:33 2024 -0600 final(?) try for now commit 119937f5d980a702d1fc47531de330332830688d Author: jadebenn Date: Tue Jan 30 20:34:44 2024 -0600 ditto commit ab39754597b4576c174d5093685d3f361fb6028a Author: jadebenn Date: Tue Jan 30 20:34:41 2024 -0600 testing if these even have any effect commit e7058be3dcee8dd5eb533122a663819e76855df7 Author: jadebenn Date: Tue Jan 30 20:28:05 2024 -0600 third test commit 10d7776fb2ab1e3f646035a4deb6b79b211193f0 Author: jadebenn Date: Tue Jan 30 19:33:59 2024 -0600 trying more variations on the flags commit 70f37560986b956e21cf5473edf0f8f3f35e62ef Author: jadebenn Date: Tue Jan 30 18:49:46 2024 -0600 testing commit 9b7c593ae9bb6fe2da8b3e4401384e97b8339b1d Author: jadebenn Date: Tue Jan 30 08:49:53 2024 -0600 Update CMakePresets.json commit 8a34544d0ea4d20b1092e71a84b7d93f3329f9a9 Author: jadebenn Date: Tue Jan 30 08:44:29 2024 -0600 test moving flags to json commit b682f13fa930dde4276b9a935c4649eec31db5a3 Merge: 2239507d d78b5087 Author: jadebenn Date: Mon Jan 29 22:49:29 2024 -0600 Merge branch 'DarkflameUniverse:main' into MSVCCompilerFlags commit 2239507d3c05cdf07d5d57156de2865021e18e3f Author: jadebenn Date: Mon Jan 29 06:14:47 2024 -0600 Add MSVC optimization flags --- .github/workflows/build-and-test.yml | 30 +- .gitignore | 3 + CMakeLists.txt | 86 ++- CMakePresets.json | 761 +++++++++++++++++---- build.sh | 3 +- cmake/toolchains/linux-clang.cmake | 14 + cmake/toolchains/linux-gnu.cmake | 11 + dGame/dUtilities/VanityUtilities.cpp | 4 +- dMasterServer/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 - tests/dCommonTests/AMFDeserializeTests.cpp | 4 +- tests/dCommonTests/Amf3Tests.cpp | 4 +- thirdparty/CMakeLists.txt | 2 +- thirdparty/SQLite/CMakeLists.txt | 2 +- 14 files changed, 743 insertions(+), 185 deletions(-) create mode 100644 cmake/toolchains/linux-clang.cmake create mode 100644 cmake/toolchains/linux-gnu.cmake 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")