mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
feat: Move scripts to CMAKE_MODULE_PATH
This commit is contained in:
parent
17305831a1
commit
cb065a07af
@ -90,6 +90,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
|
find_package(MariaDB)
|
||||||
|
|
||||||
# Create a /resServer directory
|
# Create a /resServer directory
|
||||||
make_directory(${CMAKE_BINARY_DIR}/resServer)
|
make_directory(${CMAKE_BINARY_DIR}/resServer)
|
||||||
|
|
||||||
@ -281,7 +283,7 @@ add_subdirectory(dNavigation)
|
|||||||
add_subdirectory(dPhysics)
|
add_subdirectory(dPhysics)
|
||||||
|
|
||||||
# Create a list of common libraries shared between all binaries
|
# Create a list of common libraries shared between all binaries
|
||||||
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "magic_enum")
|
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum")
|
||||||
|
|
||||||
# Add platform specific common libraries
|
# Add platform specific common libraries
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
17
cmake/FindGoogleTest.cmake
Normal file
17
cmake/FindGoogleTest.cmake
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
message(STATUS "Fetching gtest...")
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
googletest
|
||||||
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
|
GIT_TAG release-1.12.1
|
||||||
|
)
|
||||||
|
|
||||||
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||||
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(GoogleTest)
|
||||||
|
|
||||||
|
message(STATUS "gtest fetched and is now ready.")
|
||||||
|
set(GoogleTest_FOUND TRUE)
|
@ -43,27 +43,28 @@ if(WIN32 AND NOT MARIADB_BUILD_SOURCE)
|
|||||||
file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_C_MSI}" MSI_DIR)
|
file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_C_MSI}" MSI_DIR)
|
||||||
execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR})
|
execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR})
|
||||||
endif()
|
endif()
|
||||||
|
set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll")
|
||||||
|
|
||||||
if(NOT EXISTS "${MARIADB_CPP_CONNECTOR_DIR}")
|
if(NOT EXISTS "${MARIADB_CPP_CONNECTOR_DIR}")
|
||||||
file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_CPP_MSI}" MSI_DIR)
|
file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_CPP_MSI}" MSI_DIR)
|
||||||
execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR})
|
execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MARIADB_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll")
|
set(MARIADBCPP_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll")
|
||||||
set(MARIADB_IMPLIB_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.lib")
|
set(MARIADB_IMPLIB_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.lib")
|
||||||
set(MARIADB_INCLUDE_DIR "${MARIADB_CPP_CONNECTOR_DIR}/include/mariadb")
|
set(MARIADB_INCLUDE_DIR "${MARIADB_CPP_CONNECTOR_DIR}/include/mariadb")
|
||||||
|
|
||||||
add_custom_target(mariadb_connector_cpp)
|
add_custom_target(mariadb_connector_cpp)
|
||||||
add_custom_command(TARGET mariadb_connector_cpp POST_BUILD
|
add_custom_command(TARGET mariadb_connector_cpp POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll"
|
"${MARIADBCPP_SHARED_LIBRARY_LOCATION}"
|
||||||
"${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll"
|
"${MARIADBC_SHARED_LIBRARY_LOCATION}"
|
||||||
"${PROJECT_BINARY_DIR}")
|
"${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
# MariaDB uses plugins that the database needs to load, the prebuilt binaries by default will try to find the libraries in system directories,
|
# MariaDB uses plugins that the database needs to load, the prebuilt binaries by default will try to find the libraries in system directories,
|
||||||
# so set this define and the servers will set the MARIADB_PLUGIN_DIR environment variable to the appropriate directory.
|
# so set this define and the servers will set the MARIADB_PLUGIN_DIR environment variable to the appropriate directory.
|
||||||
# Plugin directory is determined at dll load time (this will happen before main()) so we need to delay the dll load so that we can set the environment variable
|
# Plugin directory is determined at dll load time (this will happen before main()) so we need to delay the dll load so that we can set the environment variable
|
||||||
add_link_options(/DELAYLOAD:${MARIADB_SHARED_LIBRARY_LOCATION})
|
add_link_options(/DELAYLOAD:${MARIADBCPP_SHARED_LIBRARY_LOCATION})
|
||||||
add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADB_CPP_CONNECTOR_DIR}/plugin")
|
add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADB_CPP_CONNECTOR_DIR}/plugin")
|
||||||
else() # Build from source
|
else() # Build from source
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ else() # Build from source
|
|||||||
message("MariaDB C/C++ install prefix: " ${MARIADBCPP_INSTALL_DIR})
|
message("MariaDB C/C++ install prefix: " ${MARIADBCPP_INSTALL_DIR})
|
||||||
set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp)
|
set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp)
|
||||||
set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin)
|
set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin)
|
||||||
set(MARIADBCPP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-connector-cpp)
|
set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp)
|
||||||
set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include")
|
set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include")
|
||||||
ExternalProject_Add(mariadb_connector_cpp
|
ExternalProject_Add(mariadb_connector_cpp
|
||||||
PREFIX "${PROJECT_BINARY_DIR}/thirdparty/mariadb-connector-cpp"
|
PREFIX "${PROJECT_BINARY_DIR}/thirdparty/mariadb-connector-cpp"
|
||||||
@ -97,6 +98,7 @@ else() # Build from source
|
|||||||
INSTALL_DIR ${MARIADBCPP_INSTALL_DIR}
|
INSTALL_DIR ${MARIADBCPP_INSTALL_DIR}
|
||||||
CMAKE_ARGS -Wno-dev
|
CMAKE_ARGS -Wno-dev
|
||||||
-DWITH_UNIT_TESTS=OFF
|
-DWITH_UNIT_TESTS=OFF
|
||||||
|
-DMARIADB_LINK_DYNAMIC=OFF
|
||||||
-DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN}
|
-DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN}
|
||||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||||
-DINSTALL_LIBDIR=${MARIADBCPP_LIBRARY_DIR}
|
-DINSTALL_LIBDIR=${MARIADBCPP_LIBRARY_DIR}
|
||||||
@ -119,17 +121,26 @@ else() # Build from source
|
|||||||
set(MARIADB_PLUGIN_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
set(MARIADB_PLUGIN_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MARIADB_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}")
|
set(MARIADBCPP_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}")
|
||||||
|
if(WIN32)
|
||||||
|
set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/libmariadb.lib")
|
||||||
|
#elseif(UNIX)
|
||||||
|
# set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/libmariadb.so.3")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create mariadb connector library object
|
# Create mariadb connector library object
|
||||||
add_library(mariadbConnCpp SHARED IMPORTED GLOBAL)
|
message("libmariadb: ${MARIADBC_SHARED_LIBRARY_LOCATION}")
|
||||||
set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_LOCATION ${MARIADB_SHARED_LIBRARY_LOCATION})
|
message("libmariadbcpp: ${MARIADBCPP_SHARED_LIBRARY_LOCATION}")
|
||||||
|
add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL)
|
||||||
|
add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp)
|
||||||
|
set_property(TARGET MariaDB::ConnCpp PROPERTY IMPORTED_LOCATION ${MARIADBCPP_SHARED_LIBRARY_LOCATION})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION})
|
set_property(TARGET MariaDB::ConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add directories to include lists
|
# Add directories to include lists
|
||||||
target_include_directories(mariadbConnCpp INTERFACE ${MARIADB_INCLUDE_DIR})
|
target_include_directories(MariaDB::ConnCpp INTERFACE ${MARIADB_INCLUDE_DIR})
|
||||||
add_dependencies(mariadbConnCpp mariadb_connector_cpp)
|
|
||||||
|
set(MariaDB_FOUND TRUE)
|
@ -15,7 +15,7 @@ target_include_directories(dDatabaseGame PUBLIC "."
|
|||||||
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
|
"${PROJECT_SOURCE_DIR}/dCommon/dEnums"
|
||||||
)
|
)
|
||||||
target_link_libraries(dDatabaseGame
|
target_link_libraries(dDatabaseGame
|
||||||
PUBLIC mariadbConnCpp
|
PUBLIC MariaDB::ConnCpp
|
||||||
INTERFACE dCommon)
|
INTERFACE dCommon)
|
||||||
|
|
||||||
# Glob together all headers that need to be precompiled
|
# Glob together all headers that need to be precompiled
|
||||||
|
@ -1,20 +1,10 @@
|
|||||||
message (STATUS "Testing is enabled. Fetching gtest...")
|
message (STATUS "Testing is enabled.")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
include(FetchContent)
|
find_package(GoogleTest REQUIRED)
|
||||||
FetchContent_Declare(
|
|
||||||
googletest
|
|
||||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
||||||
GIT_TAG release-1.12.1
|
|
||||||
)
|
|
||||||
|
|
||||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(GoogleTest)
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|
||||||
message(STATUS "gtest fetched and is now ready.")
|
unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY) # for now
|
||||||
|
|
||||||
# Add the subdirectories
|
# Add the subdirectories
|
||||||
add_subdirectory(dCommonTests)
|
add_subdirectory(dCommonTests)
|
||||||
|
3
thirdparty/CMakeLists.txt
vendored
3
thirdparty/CMakeLists.txt
vendored
@ -32,9 +32,6 @@ add_subdirectory(SQLite)
|
|||||||
# Source code for magic_enum
|
# Source code for magic_enum
|
||||||
add_subdirectory(magic_enum)
|
add_subdirectory(magic_enum)
|
||||||
|
|
||||||
# MariaDB C++ Connector
|
|
||||||
include(CMakeMariaDBLists.txt)
|
|
||||||
|
|
||||||
# Create our third party library objects
|
# Create our third party library objects
|
||||||
add_subdirectory(raknet)
|
add_subdirectory(raknet)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user