mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
Server now consists from library and separate executable projects
This commit is contained in:
parent
dc8d48a3b6
commit
c2286e5126
@ -41,41 +41,50 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo)
|
||||
endif()
|
||||
|
||||
set(buildLobby OFF)
|
||||
set(singleProcess OFF)
|
||||
set(staticAI OFF)
|
||||
if(ANDROID)
|
||||
set(staticAI ON)
|
||||
set(singleProcess ON)
|
||||
endif()
|
||||
# Platform-independent options
|
||||
|
||||
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
|
||||
option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
|
||||
if(NOT ANDROID)
|
||||
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
||||
option(ENABLE_EDITOR "Enable compilation of map editor" ON)
|
||||
endif()
|
||||
option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
|
||||
option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
|
||||
option(ENABLE_SERVER "Enable compilation of dedicated server" ON)
|
||||
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
|
||||
|
||||
# Compilation options
|
||||
|
||||
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
||||
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
|
||||
option(ENABLE_STRICT_COMPILATION "Treat all compiler warnings as errors" OFF)
|
||||
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
|
||||
option(ENABLE_COLORIZED_COMPILER_OUTPUT "Colorize compilation output (Clang/GNU)." ON)
|
||||
option(ENABLE_CCACHE "Speed up recompilation by caching previous compilations" OFF)
|
||||
|
||||
# Platform-specific options
|
||||
|
||||
if(ANDROID)
|
||||
set(ENABLE_STATIC_AI_LIBS ON)
|
||||
else()
|
||||
option(ENABLE_STATIC_AI_LIBS "Add AI code into VCMI lib directly" ON)
|
||||
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
||||
endif()
|
||||
|
||||
if(APPLE_IOS)
|
||||
set(BUNDLE_IDENTIFIER_PREFIX "" CACHE STRING "Bundle identifier prefix")
|
||||
set(APP_DISPLAY_NAME "VCMI" CACHE STRING "App name on the home screen")
|
||||
set(ENABLE_SINGLE_APP_BUILD ON)
|
||||
else()
|
||||
option(ENABLE_TEST "Enable compilation of unit tests" OFF)
|
||||
option(ENABLE_SINGLE_APP_BUILD "Builds client and server as single executable" ${singleProcess})
|
||||
endif()
|
||||
|
||||
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
||||
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
|
||||
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
|
||||
option(ENABLE_STRICT_COMPILATION "Treat all compiler warnings as errors" OFF)
|
||||
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
|
||||
option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
|
||||
option(ENABLE_STATIC_AI_LIBS "Add AI code into VCMI lib directly" ${staticAI})
|
||||
|
||||
option(ENABLE_COLORIZED_COMPILER_OUTPUT "Colorize compilation output (Clang/GNU)." ON)
|
||||
if(APPLE_IOS OR ANDROID)
|
||||
option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) # Used for Snap packages and also useful for debugging
|
||||
option(ENABLE_LOBBY "Enable compilation of lobby server" OFF)
|
||||
set(ENABLE_SINGLE_APP_BUILD ON)
|
||||
set(ENABLE_EDITOR OFF)
|
||||
set(COPY_CONFIG_ON_BUILD OFF)
|
||||
else()
|
||||
option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
|
||||
option(ENABLE_EDITOR "Enable compilation of map editor" ON)
|
||||
option(ENABLE_SINGLE_APP_BUILD "Builds client and launcher as single executable" OFF)
|
||||
option(ENABLE_TEST "Enable compilation of unit tests" OFF)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COLORIZED_COMPILER_OUTPUT)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
@ -85,20 +94,6 @@ if(ENABLE_COLORIZED_COMPILER_OUTPUT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Used for Snap packages and also useful for debugging
|
||||
if(NOT APPLE_IOS AND NOT ANDROID)
|
||||
option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(buildLobby ON)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE_IOS AND NOT ANDROID)
|
||||
option(ENABLE_LOBBY "Enable compilation of lobby server" ${buildLobby})
|
||||
endif()
|
||||
|
||||
option(ENABLE_CCACHE "Speed up recompilation by caching previous compilations" OFF)
|
||||
if(ENABLE_CCACHE)
|
||||
find_program(CCACHE ccache REQUIRED)
|
||||
endif()
|
||||
@ -133,11 +128,6 @@ if(ENABLE_ERM AND NOT ENABLE_LUA)
|
||||
set(ENABLE_LUA ON)
|
||||
endif()
|
||||
|
||||
# We don't want to deploy assets into build directory for android/iOS build
|
||||
if((APPLE_IOS OR ANDROID) AND COPY_CONFIG_ON_BUILD)
|
||||
set(COPY_CONFIG_ON_BUILD OFF)
|
||||
endif()
|
||||
|
||||
############################################
|
||||
# Miscellaneous options #
|
||||
############################################
|
||||
@ -614,16 +604,16 @@ add_subdirectory_with_folder("AI" AI)
|
||||
|
||||
include(VCMI_lib)
|
||||
add_subdirectory(lib)
|
||||
if(ENABLE_SINGLE_APP_BUILD)
|
||||
add_subdirectory(lib_server)
|
||||
endif()
|
||||
add_subdirectory(server)
|
||||
|
||||
if(ENABLE_ERM)
|
||||
add_subdirectory(scripting/erm)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LUA)
|
||||
add_subdirectory(scripting/lua)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET minizip::minizip)
|
||||
add_subdirectory_with_folder("3rdparty" lib/minizip)
|
||||
add_library(minizip::minizip ALIAS minizip)
|
||||
@ -632,14 +622,21 @@ endif()
|
||||
if(ENABLE_LAUNCHER)
|
||||
add_subdirectory(launcher)
|
||||
endif()
|
||||
|
||||
if(ENABLE_EDITOR)
|
||||
add_subdirectory(mapeditor)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LOBBY)
|
||||
add_subdirectory(lobby)
|
||||
endif()
|
||||
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(server)
|
||||
|
||||
if(ENABLE_SERVER)
|
||||
add_subdirectory(serverapp)
|
||||
endif()
|
||||
|
||||
if(ENABLE_TEST)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
|
@ -13,6 +13,6 @@ if(ENABLE_STATIC_AI_LIBS)
|
||||
else()
|
||||
add_main_lib(${VCMI_LIB_TARGET} SHARED)
|
||||
endif()
|
||||
if(ENABLE_SINGLE_APP_BUILD)
|
||||
target_compile_definitions(${VCMI_LIB_TARGET} PUBLIC VCMI_LIB_NAMESPACE=LIB_CLIENT)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${VCMI_LIB_TARGET} PUBLIC VCMI_LIB_NAMESPACE=VCMI)
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
add_main_lib(vcmi_lib_server STATIC)
|
||||
target_compile_definitions(vcmi_lib_server PUBLIC VCMI_LIB_NAMESPACE=LIB_SERVER)
|
||||
target_compile_definitions(vcmi_lib_server PUBLIC VCMI_DLL_STATIC=1)
|
@ -1,4 +1,4 @@
|
||||
set(server_SRCS
|
||||
set(libserver_SRCS
|
||||
StdInc.cpp
|
||||
|
||||
battles/BattleActionProcessor.cpp
|
||||
@ -15,7 +15,6 @@ set(server_SRCS
|
||||
processors/PlayerMessageProcessor.cpp
|
||||
processors/TurnOrderProcessor.cpp
|
||||
|
||||
EntryPoint.cpp
|
||||
CGameHandler.cpp
|
||||
GlobalLobbyProcessor.cpp
|
||||
ServerSpellCastEnvironment.cpp
|
||||
@ -25,7 +24,7 @@ set(server_SRCS
|
||||
TurnTimerHandler.cpp
|
||||
)
|
||||
|
||||
set(server_HEADERS
|
||||
set(libserver_HEADERS
|
||||
StdInc.h
|
||||
|
||||
battles/BattleActionProcessor.h
|
||||
@ -51,45 +50,28 @@ set(server_HEADERS
|
||||
TurnTimerHandler.h
|
||||
)
|
||||
|
||||
assign_source_group(${server_SRCS} ${server_HEADERS})
|
||||
assign_source_group(${libserver_SRCS} ${libserver_HEADERS})
|
||||
|
||||
if(ENABLE_SINGLE_APP_BUILD)
|
||||
add_library(vcmiserver STATIC ${server_SRCS} ${server_HEADERS})
|
||||
target_compile_definitions(vcmiserver PUBLIC VCMI_DLL_STATIC=1)
|
||||
set(server_LIBS vcmi_lib_server)
|
||||
else()
|
||||
if(ANDROID)
|
||||
add_library(vcmiserver SHARED ${server_SRCS} ${server_HEADERS})
|
||||
else()
|
||||
add_executable(vcmiserver ${server_SRCS} ${server_HEADERS})
|
||||
endif()
|
||||
set(server_LIBS vcmi)
|
||||
endif()
|
||||
add_library(libserver STATIC ${libserver_SRCS} ${libserver_HEADERS})
|
||||
set(libserver_LIBS vcmi)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD OR HAIKU)
|
||||
set(server_LIBS execinfo ${server_LIBS})
|
||||
set(libserver_LIBS execinfo ${libserver_LIBS})
|
||||
endif()
|
||||
target_link_libraries(vcmiserver PRIVATE ${server_LIBS} minizip::minizip)
|
||||
|
||||
target_include_directories(vcmiserver
|
||||
target_link_libraries(libserver PRIVATE ${libserver_LIBS} minizip::minizip)
|
||||
|
||||
target_include_directories(libserver
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(vcmiserver
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "VCMI_server"
|
||||
PROJECT_LABEL "VCMI_server"
|
||||
OUTPUT_NAME "VCMI_libserver"
|
||||
PROJECT_LABEL "VCMI_libserver"
|
||||
)
|
||||
endif()
|
||||
|
||||
vcmi_set_output_dir(vcmiserver "")
|
||||
enable_pch(vcmiserver)
|
||||
|
||||
if(NOT ENABLE_SINGLE_APP_BUILD)
|
||||
if(ANDROID)
|
||||
install(TARGETS vcmiserver DESTINATION ${LIB_DIR})
|
||||
else()
|
||||
install(TARGETS vcmiserver DESTINATION ${BIN_DIR})
|
||||
endif()
|
||||
endif()
|
||||
vcmi_set_output_dir(libserver "")
|
||||
enable_pch(libserver)
|
||||
|
34
serverapp/CMakeLists.txt
Normal file
34
serverapp/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
set(appserver_SRCS
|
||||
StdInc.cpp
|
||||
EntryPoint.cpp
|
||||
)
|
||||
|
||||
set(appserver_HEADERS
|
||||
StdInc.h
|
||||
)
|
||||
|
||||
assign_source_group(${appserver_SRCS} ${appserver_HEADERS})
|
||||
add_executable(vcmiserver ${appserver_SRCS} ${appserver_HEADERS})
|
||||
set(appserver_LIBS vcmi)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD OR HAIKU)
|
||||
set(appserver_LIBS execinfo ${appserver_LIBS})
|
||||
endif()
|
||||
target_link_libraries(vcmiserver PRIVATE ${appserver_LIBS} minizip::minizip libserver)
|
||||
|
||||
target_include_directories(vcmiserver
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(vcmiserver
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "VCMI_server"
|
||||
PROJECT_LABEL "VCMI_server"
|
||||
)
|
||||
endif()
|
||||
|
||||
vcmi_set_output_dir(vcmiserver "")
|
||||
enable_pch(vcmiserver)
|
||||
|
||||
install(TARGETS vcmiserver DESTINATION ${BIN_DIR})
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "CVCMIServer.h"
|
||||
#include "../server/CVCMIServer.h"
|
||||
|
||||
#include "../lib/CConsoleHandler.h"
|
||||
#include "../lib/logging/CBasicLogConfigurator.h"
|
2
serverapp/StdInc.cpp
Normal file
2
serverapp/StdInc.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// Creates the precompiled header
|
||||
#include "StdInc.h"
|
14
serverapp/StdInc.h
Normal file
14
serverapp/StdInc.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* StdInc.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../Global.h"
|
||||
|
||||
VCMI_LIB_USING_NAMESPACE
|
Loading…
Reference in New Issue
Block a user