From 09e479e8d64f215b3abd7ac1ad886318694beef5 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Wed, 29 Nov 2023 14:09:23 +0000 Subject: [PATCH] Adding server2 back to cmake --- source/CMakeLists.txt | 2 +- source/server2/CMakeLists.txt | 21 +++++++-------------- source/server2/server.hpp | 7 ++++--- source/server2/server_main.cpp | 2 +- source/server2/xdr_protocol.cpp | 7 ++++++- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index ce0b3204..3feda9de 100755 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -54,7 +54,7 @@ endif() if( NOT CLIENT_ONLY ) add_subdirectory( server ) -# add_subdirectory( server2 ) + add_subdirectory( server2 ) add_subdirectory( plugins ) endif() diff --git a/source/server2/CMakeLists.txt b/source/server2/CMakeLists.txt index d896d5f0..630d45c2 100755 --- a/source/server2/CMakeLists.txt +++ b/source/server2/CMakeLists.txt @@ -8,9 +8,7 @@ find_package( fmt REQUIRED ) if( WIN32 OR MINGW ) find_package( XDR REQUIRED ) - if( NOT MINGW ) - find_package( dlfcn-win32 CONFIG REQUIRED ) - endif() + find_package( dlfcn-win32 CONFIG REQUIRED ) else() find_package( TIRPC QUIET ) if( TIRPC_FOUND ) @@ -53,7 +51,7 @@ add_definitions( -DSERVERBUILD ) add_library( server2-objects OBJECT ${SRC_FILES} ) -target_link_libraries( server2-objects PRIVATE fmt::fmt ) +target_link_libraries( server2-objects PRIVATE spdlog::spdlog fmt::fmt ) set( SERVER2_OBJ $ @@ -61,6 +59,7 @@ set( SERVER2_OBJ $ $ $ + $ ) add_library( server2-static STATIC ${SERVER2_OBJ} ) @@ -70,22 +69,18 @@ endif() set( LINK_XDR ) set( EXE_FLAG ) -set( EXE_EXT ) if( WIN32 OR MINGW ) set( EXE_FLAG WIN32 ) - if( MINGW ) - set( EXE_EXT ".exe" ) - endif() include_directories( ${XDR_INCLUDE_DIR} ) set( LINK_XDR ${XDR_LIBRARIES} ws2_32 ) -elseif( TIRPC_FOUND ) +elseif(TIRPC_FOUND ) include_directories( ${TIRPC_INCLUDE_DIR} ) set( LINK_XDR ${LINK_XDR} ${TIRPC_LIBRARIES} ) endif() -target_link_libraries( server2-static PRIVATE ${LINK_XDR} ) +target_link_libraries( server2-static PRIVATE ${LINK_XDR} fmt::fmt ) if( BUILD_SHARED_LIBS ) - target_link_libraries( server2-shared PRIVATE ${LINK_XDR} ) + target_link_libraries( server2-shared PRIVATE ${LINK_XDR} fmt::fmt ) endif() add_executable( server2-exe ${EXE_FLAG} server_main.cpp) @@ -108,10 +103,8 @@ if( WIN32 OR MINGW ) endif() set( LINK_DL ) -if( WIN32 AND NOT MINGW ) +if( WIN32 OR MINGW ) set( LINK_DL dlfcn-win32::dl ) -else() - set( LINK_DL dl ) endif() set( LINK_M ) diff --git a/source/server2/server.hpp b/source/server2/server.hpp index f01662de..23c70ef7 100644 --- a/source/server2/server.hpp +++ b/source/server2/server.hpp @@ -13,6 +13,7 @@ #include "clientserver/parseXML.h" #include "clientserver/socketStructs.h" #include "cache/memcache.hpp" +#include "clientserver/export.h" namespace uda { @@ -29,9 +30,9 @@ class Server { constexpr static int ServerVersion = 8; constexpr static int LegacyServerVersion = 6; - Server(); - void run(); - void close(); + LIBRARY_API Server(); + LIBRARY_API void run(); + LIBRARY_API void close(); private: void startup(); diff --git a/source/server2/server_main.cpp b/source/server2/server_main.cpp index 814db0ee..52e5b171 100755 --- a/source/server2/server_main.cpp +++ b/source/server2/server_main.cpp @@ -22,7 +22,7 @@ int main() try { uda::Server server; - server.run(); +// server.run(); } catch (uda::server::Exception& ex) { return ex.code(); } diff --git a/source/server2/xdr_protocol.cpp b/source/server2/xdr_protocol.cpp index 69bb8a71..e3823f50 100644 --- a/source/server2/xdr_protocol.cpp +++ b/source/server2/xdr_protocol.cpp @@ -15,7 +15,6 @@ #include #include -#include #include "server.hpp" @@ -25,6 +24,12 @@ # define write _write #endif +#ifndef _WIN32 +# include +#else +# include +#endif + constexpr int MinBlockTime = 1000; constexpr int MaxBlockTime = 10000;