Add Linux compatibility for LoginServer
- Updated main.cpp with platform-specific code for Windows/Linux - Modified stdafx.h to include Linux headers and definitions - Updated signal_handler.cpp for cross-platform signal handling - Added Linux-compatible types and macros - Created CMakeLists.txt for Linux build system - Added build.sh script for automated building - Added loginserver.sh script for server management - Created comprehensive README_LINUX.md with deployment instructions - All changes maintain Windows compatibility using preprocessor directives
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(LoginServer)
|
||||
|
||||
# Set C++ standard
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Set compiler flags
|
||||
if(WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2 -pthread")
|
||||
endif()
|
||||
|
||||
# Define preprocessor macros
|
||||
if(WIN32)
|
||||
add_definitions(-D_WIN32)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-DVC_EXTRALEAN)
|
||||
else()
|
||||
add_definitions(-D__VERSION=1)
|
||||
endif()
|
||||
|
||||
# Include directories
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../shared
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../shared/database
|
||||
)
|
||||
|
||||
# Source files
|
||||
set(LOGIN_SERVER_SOURCES
|
||||
main.cpp
|
||||
LoginServer.cpp
|
||||
LoginSession.cpp
|
||||
DBProcess.cpp
|
||||
stdafx.cpp
|
||||
)
|
||||
|
||||
# Shared library sources
|
||||
set(SHARED_SOURCES
|
||||
../shared/globals.cpp
|
||||
../shared/tstring.cpp
|
||||
../shared/Thread.cpp
|
||||
../shared/TimeThread.cpp
|
||||
../shared/Socket.cpp
|
||||
../shared/SocketMgr.cpp
|
||||
../shared/Condition.cpp
|
||||
../shared/RWLock.cpp
|
||||
../shared/ReferenceObject.cpp
|
||||
../shared/signal_handler.cpp
|
||||
../shared/Ini.cpp
|
||||
../shared/JvCryption.cpp
|
||||
../shared/crc32.c
|
||||
../shared/lzf.c
|
||||
../shared/HardwareInformation.cpp
|
||||
../shared/DebugUtils.cpp
|
||||
../shared/SMDFile.cpp
|
||||
../shared/CircularBuffer.cpp
|
||||
)
|
||||
|
||||
# Database sources
|
||||
file(GLOB DATABASE_SOURCES "../shared/database/*.cpp")
|
||||
|
||||
# Platform specific sources
|
||||
if(WIN32)
|
||||
list(APPEND SHARED_SOURCES
|
||||
../shared/SocketWin32.cpp
|
||||
../shared/SocketOpsWin32.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
# Create executable
|
||||
add_executable(LoginServer
|
||||
${LOGIN_SERVER_SOURCES}
|
||||
${SHARED_SOURCES}
|
||||
${DATABASE_SOURCES}
|
||||
)
|
||||
|
||||
# Link libraries
|
||||
if(WIN32)
|
||||
target_link_libraries(LoginServer ws2_32 odbc32)
|
||||
else()
|
||||
target_link_libraries(LoginServer pthread odbc)
|
||||
endif()
|
||||
|
||||
# Set output directory
|
||||
set_target_properties(LoginServer PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
# Copy configuration files
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/LogIn.ini)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LogIn.ini ${CMAKE_BINARY_DIR}/bin/LogIn.ini COPYONLY)
|
||||
endif()
|
||||
Reference in New Issue
Block a user