Skip to content

Commit

Permalink
Adding server2 back to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Nov 29, 2023
1 parent 89194b7 commit 09e479e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ endif()

if( NOT CLIENT_ONLY )
add_subdirectory( server )
# add_subdirectory( server2 )
add_subdirectory( server2 )
add_subdirectory( plugins )
endif()

Expand Down
21 changes: 7 additions & 14 deletions source/server2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -53,14 +51,15 @@ 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
$<TARGET_OBJECTS:server2-objects>
$<TARGET_OBJECTS:clientserver-server-objects>
$<TARGET_OBJECTS:logging-server-objects>
$<TARGET_OBJECTS:structures-server-objects>
$<TARGET_OBJECTS:authentication-server-objects>
$<TARGET_OBJECTS:cache-objects>
)

add_library( server2-static STATIC ${SERVER2_OBJ} )
Expand All @@ -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)
Expand All @@ -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 )
Expand Down
7 changes: 4 additions & 3 deletions source/server2/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "clientserver/parseXML.h"
#include "clientserver/socketStructs.h"
#include "cache/memcache.hpp"
#include "clientserver/export.h"

namespace uda {

Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion source/server2/server_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main()

try {
uda::Server server;
server.run();
// server.run();
} catch (uda::server::Exception& ex) {
return ex.code();
}
Expand Down
7 changes: 6 additions & 1 deletion source/server2/xdr_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <logging/logging.h>
#include <clientserver/udaDefines.h>
#include <err.h>

#include "server.hpp"

Expand All @@ -25,6 +24,12 @@
# define write _write
#endif

#ifndef _WIN32
# include <sys/select.h>
#else
# include <winsock.h>
#endif

constexpr int MinBlockTime = 1000;
constexpr int MaxBlockTime = 10000;

Expand Down

0 comments on commit 09e479e

Please sign in to comment.