diff --git a/.gitignore b/.gitignore index 0b0d2ecf7..f87f7c19d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,10 @@ docker/configs # Third party libraries thirdparty/mysql/ thirdparty/mysql_linux/ +thirdparty/backtrace/ +thirdparty/magic_enum/ +thirdparty/recastnavigation/ +thirdparty/tinyxml2/ CMakeVariables.txt # Build folders diff --git a/.gitmodules b/.gitmodules index 4ba6a43b5..4c50f8b3c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,19 +1,7 @@ [submodule "thirdparty/cpp-httplib"] path = thirdparty/cpp-httplib url = https://github.com/yhirose/cpp-httplib -[submodule "thirdparty/tinyxml2"] - path = thirdparty/tinyxml2 - url = https://github.com/leethomason/tinyxml2 -[submodule "thirdparty/recastnavigation"] - path = thirdparty/recastnavigation - url = https://github.com/recastnavigation/recastnavigation -[submodule "thirdparty/libbcrypt"] - path = thirdparty/libbcrypt - url = https://github.com/trusch/libbcrypt.git [submodule "thirdparty/mariadb-connector-cpp"] path = thirdparty/mariadb-connector-cpp url = https://github.com/mariadb-corporation/mariadb-connector-cpp.git ignore = dirty -[submodule "thirdparty/magic_enum"] - path = thirdparty/magic_enum - url = https://github.com/Neargye/magic_enum.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a6c4b235..91cd757a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,53 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) find_package(MariaDB) +# Fetch third party dependencies +set(DLU_THIRDPARTY_SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty) + +include(FetchContent) +FetchContent_Declare( + backtrace + SYSTEM + SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/backtrace + GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git +) +FetchContent_Declare( + bcrypt + SYSTEM + SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/libbcrypt + GIT_REPOSITORY https://github.com/trusch/libbcrypt.git + GIT_TAG d6523c370de6e724ce4ec703e2449b5b028ea3b1 +) +FetchContent_Declare( + magic_enum + SYSTEM + SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/magic_enum + GIT_REPOSITORY https://github.com/Neargye/magic_enum.git + GIT_TAG v0.9.7 +) +FetchContent_Declare( + Recast + SYSTEM + SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/recastnavigation + GIT_REPOSITORY https://github.com/recastnavigation/recastnavigation.git + GIT_TAG v1.6.0 +) +FetchContent_Declare( + tinyxml2 + SYSTEM + SOURCE_DIR ${DLU_THIRDPARTY_SOURCE_DIR}/tinyxml2 + GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git + GIT_TAG 9.0.0 +) +FetchContent_MakeAvailable(magic_enum Recast tinyxml2) + +# Turn off tinyxml2 testing +set(tinyxml2_BUILD_TESTING OFF) + +include(CMakePrintHelpers) +cmake_print_properties(TARGETS magic_enum Recast tinyxml2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES) + # Create a /resServer directory make_directory(${CMAKE_BINARY_DIR}/resServer) @@ -251,10 +298,7 @@ include_directories( "tests/dGameTests/dComponentsTests" SYSTEM - "thirdparty/magic_enum/include/magic_enum" "thirdparty/raknet/Source" - "thirdparty/tinyxml2" - "thirdparty/recastnavigation" "thirdparty/SQLite" "thirdparty/cpplinq" "thirdparty/cpp-httplib" @@ -272,7 +316,7 @@ 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") + add_compile_options("-Wuninitialized" "-Wold-style-cast" "-Wstrict-aliasing") else() message(WARNING "Unknown compiler: '${CMAKE_CXX_COMPILER_ID}' - No warning flags enabled.") endif() @@ -341,7 +385,7 @@ target_precompile_headers( target_precompile_headers( tinyxml2 PRIVATE - "$<$:${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/tinyxml2.h>" + "$<$:${tinyxml2_SOURCE_DIR}/tinyxml2.h>" ) if(${ENABLE_TESTING}) diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index d020ff72f..fd3430a6e 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -70,5 +70,6 @@ else () endif () target_link_libraries(dCommon + PUBLIC magic_enum PRIVATE ZLIB::ZLIB bcrypt tinyxml2 INTERFACE dDatabase) diff --git a/dCommon/dEnums/MessageType/Game.h b/dCommon/dEnums/MessageType/Game.h index 8c5bddae7..60359da4c 100644 --- a/dCommon/dEnums/MessageType/Game.h +++ b/dCommon/dEnums/MessageType/Game.h @@ -1,7 +1,7 @@ #pragma once #include -#include "magic_enum.hpp" +#include namespace MessageType { enum class Game : uint16_t { diff --git a/dCommon/dEnums/MessageType/World.h b/dCommon/dEnums/MessageType/World.h index acca62466..6e56fd590 100644 --- a/dCommon/dEnums/MessageType/World.h +++ b/dCommon/dEnums/MessageType/World.h @@ -1,7 +1,7 @@ #pragma once #include -#include "magic_enum.hpp" +#include namespace MessageType { enum class World : uint32_t { diff --git a/dCommon/dEnums/StringifiedEnum.h b/dCommon/dEnums/StringifiedEnum.h index 1816d705c..deab81d8d 100644 --- a/dCommon/dEnums/StringifiedEnum.h +++ b/dCommon/dEnums/StringifiedEnum.h @@ -2,7 +2,7 @@ #define __STRINGIFIEDENUM_H__ #include -#include "magic_enum.hpp" +#include namespace StringifiedEnum { template diff --git a/dCommon/dEnums/eInventoryType.h b/dCommon/dEnums/eInventoryType.h index 1c6688b22..e671f4b94 100644 --- a/dCommon/dEnums/eInventoryType.h +++ b/dCommon/dEnums/eInventoryType.h @@ -4,8 +4,7 @@ #define __EINVENTORYTYPE__H__ #include - -#include "magic_enum.hpp" +#include static const uint8_t NUMBER_OF_INVENTORIES = 17; /** diff --git a/dDatabase/CMakeLists.txt b/dDatabase/CMakeLists.txt index 004bdc147..3384ad66b 100644 --- a/dDatabase/CMakeLists.txt +++ b/dDatabase/CMakeLists.txt @@ -4,4 +4,4 @@ add_subdirectory(GameDatabase) add_library(dDatabase STATIC "MigrationRunner.cpp") target_include_directories(dDatabase PUBLIC ".") target_link_libraries(dDatabase - PUBLIC dDatabaseCDClient dDatabaseGame) + PUBLIC magic_enum dDatabaseCDClient dDatabaseGame) diff --git a/dGame/dBehaviors/CMakeLists.txt b/dGame/dBehaviors/CMakeLists.txt index 35d8cae66..0c884be95 100644 --- a/dGame/dBehaviors/CMakeLists.txt +++ b/dGame/dBehaviors/CMakeLists.txt @@ -55,7 +55,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp" "VerifyBehavior.cpp") add_library(dBehaviors OBJECT ${DGAME_DBEHAVIORS_SOURCES}) -target_link_libraries(dBehaviors PUBLIC dDatabaseCDClient dPhysics) +target_link_libraries(dBehaviors PUBLIC dDatabaseCDClient dPhysics magic_enum tinyxml2) target_include_directories(dBehaviors PUBLIC "." "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # via BehaviorContext.h PRIVATE diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index c60e135fe..545bb1497 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -79,4 +79,4 @@ target_include_directories(dComponents PUBLIC "." ) target_precompile_headers(dComponents REUSE_FROM dGameBase) -target_link_libraries(dComponents INTERFACE dBehaviors) +target_link_libraries(dComponents PUBLIC magic_enum tinyxml2 INTERFACE dBehaviors) diff --git a/dGame/dGameMessages/CMakeLists.txt b/dGame/dGameMessages/CMakeLists.txt index 0f28dea4f..1d168213b 100644 --- a/dGame/dGameMessages/CMakeLists.txt +++ b/dGame/dGameMessages/CMakeLists.txt @@ -6,7 +6,7 @@ set(DGAME_DGAMEMESSAGES_SOURCES add_library(dGameMessages OBJECT ${DGAME_DGAMEMESSAGES_SOURCES}) target_link_libraries(dGameMessages - PUBLIC dDatabase + PUBLIC magic_enum tinyxml2 dDatabase INTERFACE dGameBase # TradingManager ) target_include_directories(dGameMessages PUBLIC "." diff --git a/dGame/dInventory/CMakeLists.txt b/dGame/dInventory/CMakeLists.txt index b45b27bf1..dc461620b 100644 --- a/dGame/dInventory/CMakeLists.txt +++ b/dGame/dInventory/CMakeLists.txt @@ -24,6 +24,7 @@ target_include_directories(dInventory PUBLIC "." "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h "${PROJECT_SOURCE_DIR}/dZoneManager" # via Item.cpp ) +target_link_libraries(dInventory PUBLIC magic_enum tinyxml2) target_precompile_headers(dInventory REUSE_FROM dGameBase) # Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185 diff --git a/dGame/dMission/CMakeLists.txt b/dGame/dMission/CMakeLists.txt index 51f74c37d..c8f6a26fa 100644 --- a/dGame/dMission/CMakeLists.txt +++ b/dGame/dMission/CMakeLists.txt @@ -4,7 +4,7 @@ set(DGAME_DMISSION_SOURCES "MissionTask.cpp") add_library(dMission OBJECT ${DGAME_DMISSION_SOURCES}) -target_link_libraries(dMission PUBLIC dDatabase) +target_link_libraries(dMission PUBLIC tinyxml2 dDatabase) target_include_directories(dMission PUBLIC "." PRIVATE "${PROJECT_SOURCE_DIR}/dGame/dComponents" diff --git a/dGame/dPropertyBehaviors/CMakeLists.txt b/dGame/dPropertyBehaviors/CMakeLists.txt index 3e03ba1d1..91681916c 100644 --- a/dGame/dPropertyBehaviors/CMakeLists.txt +++ b/dGame/dPropertyBehaviors/CMakeLists.txt @@ -13,7 +13,7 @@ foreach(file ${DGAME_DPROPERTYBEHAVIORS_CONTROLBEHAVIORMESSAGES}) endforeach() add_library(dPropertyBehaviors OBJECT ${DGAME_DPROPERTYBEHAVIORS_SOURCES}) -target_link_libraries(dPropertyBehaviors PRIVATE dDatabaseCDClient) +target_link_libraries(dPropertyBehaviors PUBLIC tinyxml2 PRIVATE dDatabaseCDClient) target_include_directories(dPropertyBehaviors PUBLIC "." "ControlBehaviorMessages" PRIVATE "${PROJECT_SOURCE_DIR}/dCommon/dClient" # ControlBehaviors.cpp uses AssetManager diff --git a/dNavigation/CMakeLists.txt b/dNavigation/CMakeLists.txt index e2a1c6ef3..53e558457 100644 --- a/dNavigation/CMakeLists.txt +++ b/dNavigation/CMakeLists.txt @@ -14,4 +14,4 @@ target_include_directories(dNavigation PUBLIC "." "${PROJECT_SOURCE_DIR}/dGame/dEntity" "${PROJECT_SOURCE_DIR}/dNavigation/dTerrain" # via dNavMesh.cpp ) -target_link_libraries(dNavigation PRIVATE Detour Recast dCommon) +target_link_libraries(dNavigation PUBLIC tinyxml2 PRIVATE Detour Recast dCommon) diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index ee1e4586e..9c7e2bf27 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -4,7 +4,7 @@ #define _VARIADIC_MAX 10 #include "dCommonVars.h" #include "dNetCommon.h" -#include "magic_enum.hpp" +#include enum class ServerType : uint32_t; enum class eLoginResponse : uint8_t; diff --git a/dNet/CMakeLists.txt b/dNet/CMakeLists.txt index 15cdda42b..602e57006 100644 --- a/dNet/CMakeLists.txt +++ b/dNet/CMakeLists.txt @@ -8,7 +8,7 @@ set(DNET_SOURCES "AuthPackets.cpp" "ZoneInstanceManager.cpp") add_library(dNet STATIC ${DNET_SOURCES}) -target_link_libraries(dNet PRIVATE bcrypt MD5) +target_link_libraries(dNet PUBLIC magic_enum PRIVATE bcrypt MD5) target_include_directories(dNet PRIVATE "${PROJECT_SOURCE_DIR}/dCommon" "${PROJECT_SOURCE_DIR}/dCommon/dEnums" diff --git a/dWorldServer/CMakeLists.txt b/dWorldServer/CMakeLists.txt index 62a3767aa..815a2c08b 100644 --- a/dWorldServer/CMakeLists.txt +++ b/dWorldServer/CMakeLists.txt @@ -13,7 +13,7 @@ target_include_directories(WorldServer PRIVATE "${PROJECT_SOURCE_DIR}/dServer" # BinaryPathFinder.h ) -target_link_libraries(WorldServer ${COMMON_LIBRARIES} +target_link_libraries(WorldServer PUBLIC ${COMMON_LIBRARIES} dScripts dGameBase dComponents diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index ef7c4cba9..7af4f3477 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -32,7 +32,7 @@ add_custom_command(TARGET dCommonTests POST_BUILD endif() # Link needed libraries -target_link_libraries(dCommonTests ${COMMON_LIBRARIES} GTest::gtest_main) +target_link_libraries(dCommonTests ${COMMON_LIBRARIES} GTest::gtest_main magic_enum) # Copy test files to testing directory add_subdirectory(TestBitStreams) diff --git a/tests/dCommonTests/dEnumsTests/MagicEnumTests.cpp b/tests/dCommonTests/dEnumsTests/MagicEnumTests.cpp index fcd517f1f..a1e1fb3e1 100644 --- a/tests/dCommonTests/dEnumsTests/MagicEnumTests.cpp +++ b/tests/dCommonTests/dEnumsTests/MagicEnumTests.cpp @@ -8,7 +8,7 @@ #include "Game.h" #include "MessageType/Game.h" #include "MessageType/World.h" -#include "magic_enum.hpp" +#include #define ENUM_EQ(e, y, z)\ LOG("%s %s", StringifiedEnum::ToString(static_cast(y)).data(), #z);\ diff --git a/tests/dGameTests/CMakeLists.txt b/tests/dGameTests/CMakeLists.txt index e1c294331..7e7a6dbd7 100644 --- a/tests/dGameTests/CMakeLists.txt +++ b/tests/dGameTests/CMakeLists.txt @@ -23,7 +23,7 @@ add_custom_command(TARGET dGameTests POST_BUILD WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() -target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main +target_link_libraries(dGameTests ${COMMON_LIBRARIES} magic_enum GTest::gtest_main dGame dScripts dPhysics Detour Recast tinyxml2 dWorldServer dZoneManager dChatFilter dNavigation) # Discover the tests diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 79863a53b..f94c99bac 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,17 +1,12 @@ # Source Code for recast -add_subdirectory(recastnavigation) - -# Turn off tinyxml2 testing -set(tinyxml2_BUILD_TESTING OFF) -# Source Code for tinyxml2 -add_subdirectory(tinyxml2) +# add_subdirectory(recastnavigation) # Source Code for libbcrypt. Uses a file glob instead to get around Windows build issues. -file( - GLOB SOURCES_LIBBCRYPT - LIST_DIRECTORIES false - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${CMAKE_CURRENT_SOURCE_DIR}/libbcrypt/src/*.c + file( + GLOB SOURCES_LIBBCRYPT + LIST_DIRECTORIES false + RELATIVE "${DLU_THIRDPARTY_SOURCE_DIR}" + ${DLU_THIRDPARTY_SOURCE_DIR}/libbcrypt/src/*.c ) add_library(bcrypt ${SOURCES_LIBBCRYPT}) @@ -20,12 +15,12 @@ add_library(bcrypt ${SOURCES_LIBBCRYPT}) # fortunately they are only needed for building the libbcrypt directory and nothing else, so these are marked private. if(NOT WIN32) - target_include_directories(bcrypt PRIVATE "libbcrypt/include/bcrypt") + target_include_directories(bcrypt PRIVATE "libbcrypt/include/bcrypt") 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") @@ -34,21 +29,12 @@ target_include_directories(bcrypt PRIVATE "libbcrypt/src") # Source code for sqlite add_subdirectory(SQLite) -# Source code for magic_enum -add_subdirectory(magic_enum) - # Create our third party library objects add_subdirectory(raknet) # Download Backtrace if configured if(UNIX AND NOT APPLE) - include(FetchContent) if (${INCLUDE_BACKTRACE} AND ${COMPILE_BACKTRACE}) - FetchContent_Declare( - backtrace - GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git - ) - FetchContent_MakeAvailable(backtrace) if (NOT EXISTS ${backtrace_SOURCE_DIR}/.libs) diff --git a/thirdparty/libbcrypt b/thirdparty/libbcrypt deleted file mode 160000 index d6523c370..000000000 --- a/thirdparty/libbcrypt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d6523c370de6e724ce4ec703e2449b5b028ea3b1 diff --git a/thirdparty/magic_enum b/thirdparty/magic_enum deleted file mode 160000 index e55b9b54d..000000000 --- a/thirdparty/magic_enum +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e55b9b54d5cf61f8e117cafb17846d7d742dd3b4 diff --git a/thirdparty/recastnavigation b/thirdparty/recastnavigation deleted file mode 160000 index c5cbd5302..000000000 --- a/thirdparty/recastnavigation +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c5cbd53024c8a9d8d097a4371215e3342d2fdc87 diff --git a/thirdparty/tinyxml2 b/thirdparty/tinyxml2 deleted file mode 160000 index a97739768..000000000 --- a/thirdparty/tinyxml2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9773976845b19e89020c1215781e71116477ef1