test using FetchContent for dependencies

This commit is contained in:
jadebenn 2024-11-20 21:12:11 -06:00
parent 53877a0bc3
commit b49e316296
24 changed files with 49 additions and 40 deletions

6
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[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
@ -14,6 +11,3 @@
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

View File

@ -109,6 +109,31 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
find_package(MariaDB)
# Fetch third party dependencies
include(FetchContent)
FetchContent_Declare(
backtrace
SYSTEM
GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
)
FetchContent_Declare(
magic_enum
SYSTEM
GIT_REPOSITORY https://github.com/Neargye/magic_enum.git
GIT_TAG v0.9.7
)
FetchContent_Declare(
tinyxml2
SYSTEM
GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
GIT_TAG 9.0.0
)
FetchContent_MakeAvailable(magic_enum tinyxml2)
include(CMakePrintHelpers)
cmake_print_properties(TARGETS magic_enum tinyxml2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES)
# Create a /resServer directory
make_directory(${CMAKE_BINARY_DIR}/resServer)
@ -251,9 +276,9 @@ include_directories(
"tests/dGameTests/dComponentsTests"
SYSTEM
"thirdparty/magic_enum/include/magic_enum"
# "thirdparty/magic_enum/include/magic_enum"
"thirdparty/raknet/Source"
"thirdparty/tinyxml2"
# "thirdparty/tinyxml2"
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
@ -341,7 +366,9 @@ target_precompile_headers(
target_precompile_headers(
tinyxml2 PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/tinyxml2.h>"
"$<$<COMPILE_LANGUAGE:CXX>:${tinyxml2_SOURCE_DIR}/tinyxml2.h>"
#/home/jonah/DarkflameServer/build/gnu-debug/_deps/tinyxml2-src/tinyxml2.h
#/home/jonah/DarkflameServer/build/gnu-debug/_deps/tinyxml2-src
)
if(${ENABLE_TESTING})

View File

@ -70,5 +70,6 @@ else ()
endif ()
target_link_libraries(dCommon
PUBLIC magic_enum
PRIVATE ZLIB::ZLIB bcrypt tinyxml2
INTERFACE dDatabase)

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstdint>
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
namespace MessageType {
enum class Game : uint16_t {

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstdint>
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
namespace MessageType {
enum class World : uint32_t {

View File

@ -2,7 +2,7 @@
#define __STRINGIFIEDENUM_H__
#include <string>
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
namespace StringifiedEnum {
template<typename T>

View File

@ -4,8 +4,7 @@
#define __EINVENTORYTYPE__H__
#include <cstdint>
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
static const uint8_t NUMBER_OF_INVENTORIES = 17;
/**

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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 "."

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -4,7 +4,7 @@
#define _VARIADIC_MAX 10
#include "dCommonVars.h"
#include "dNetCommon.h"
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
enum class ServerType : uint32_t;
enum class eLoginResponse : uint8_t;

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -8,7 +8,7 @@
#include "Game.h"
#include "MessageType/Game.h"
#include "MessageType/World.h"
#include "magic_enum.hpp"
#include <magic_enum/magic_enum.hpp>
#define ENUM_EQ(e, y, z)\
LOG("%s %s", StringifiedEnum::ToString(static_cast<e>(y)).data(), #z);\

View File

@ -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

View File

@ -3,8 +3,6 @@ add_subdirectory(recastnavigation)
# Turn off tinyxml2 testing
set(tinyxml2_BUILD_TESTING OFF)
# Source Code for tinyxml2
add_subdirectory(tinyxml2)
# Source Code for libbcrypt. Uses a file glob instead to get around Windows build issues.
file(
@ -34,21 +32,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)

@ -1 +0,0 @@
Subproject commit e55b9b54d5cf61f8e117cafb17846d7d742dd3b4

1
thirdparty/tinyxml2 vendored

@ -1 +0,0 @@
Subproject commit a9773976845b19e89020c1215781e71116477ef1