1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Added option to build minimal vcmi library as needed by lobby

This commit is contained in:
Ivan Savenko
2024-03-27 19:30:07 +02:00
parent 9cf161bc66
commit 39da7b3e32
3 changed files with 107 additions and 83 deletions

View File

@@ -44,6 +44,7 @@ option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON) 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_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON) option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
option(ENABLE_MINIMAL_LIB "Build only core parts of vcmi library that are required for game lobby" OFF)
# Compilation options # Compilation options
@@ -248,6 +249,10 @@ if(ENABLE_SINGLE_APP_BUILD)
add_definitions(-DENABLE_SINGLE_APP_BUILD) add_definitions(-DENABLE_SINGLE_APP_BUILD)
endif() endif()
if(ENABLE_MINIMAL_LIB)
add_definitions(-DENABLE_MINIMAL_LIB)
endif()
if(APPLE_IOS) if(APPLE_IOS)
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0) set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)

View File

@@ -1,6 +1,48 @@
set(lib_SRCS set(lib_SRCS
StdInc.cpp StdInc.cpp
filesystem/AdapterLoaders.cpp
filesystem/CArchiveLoader.cpp
filesystem/CBinaryReader.cpp
filesystem/CCompressedStream.cpp
filesystem/CFileInputStream.cpp
filesystem/CFilesystemLoader.cpp
filesystem/CMemoryBuffer.cpp
filesystem/CMemoryStream.cpp
filesystem/CZipLoader.cpp
filesystem/CZipSaver.cpp
filesystem/FileInfo.cpp
filesystem/Filesystem.cpp
filesystem/MinizipExtensions.cpp
filesystem/ResourcePath.cpp
json/JsonNode.cpp
json/JsonParser.cpp
json/JsonRandom.cpp
json/JsonUtils.cpp
json/JsonValidator.cpp
json/JsonWriter.cpp
logging/CBasicLogConfigurator.cpp
logging/CLogger.cpp
logging/VisualLogger.cpp
network/NetworkConnection.cpp
network/NetworkHandler.cpp
network/NetworkServer.cpp
vstd/DateUtils.cpp
vstd/StringUtils.cpp
CConfigHandler.cpp
CConsoleHandler.cpp
CThreadHelper.cpp
TextOperations.cpp
VCMIDirs.cpp
)
set(lib_MAIN_SRCS
battle/AccessibilityInfo.cpp battle/AccessibilityInfo.cpp
battle/BattleAction.cpp battle/BattleAction.cpp
battle/BattleAttackInfo.cpp battle/BattleAttackInfo.cpp
@@ -46,38 +88,13 @@ set(lib_SRCS
events/PlayerGotTurn.cpp events/PlayerGotTurn.cpp
events/TurnStarted.cpp events/TurnStarted.cpp
filesystem/AdapterLoaders.cpp
filesystem/CArchiveLoader.cpp
filesystem/CBinaryReader.cpp
filesystem/CCompressedStream.cpp
filesystem/CFileInputStream.cpp
filesystem/CFilesystemLoader.cpp
filesystem/CMemoryBuffer.cpp
filesystem/CMemoryStream.cpp
filesystem/CZipLoader.cpp
filesystem/CZipSaver.cpp
filesystem/FileInfo.cpp
filesystem/Filesystem.cpp
filesystem/MinizipExtensions.cpp
filesystem/ResourcePath.cpp
json/JsonBonus.cpp json/JsonBonus.cpp
json/JsonNode.cpp
json/JsonParser.cpp
json/JsonRandom.cpp
json/JsonUtils.cpp
json/JsonValidator.cpp
json/JsonWriter.cpp
gameState/CGameState.cpp gameState/CGameState.cpp
gameState/CGameStateCampaign.cpp gameState/CGameStateCampaign.cpp
gameState/InfoAboutArmy.cpp gameState/InfoAboutArmy.cpp
gameState/TavernHeroesPool.cpp gameState/TavernHeroesPool.cpp
logging/CBasicLogConfigurator.cpp
logging/CLogger.cpp
logging/VisualLogger.cpp
mapObjectConstructors/AObjectTypeHandler.cpp mapObjectConstructors/AObjectTypeHandler.cpp
mapObjectConstructors/CBankInstanceConstructor.cpp mapObjectConstructors/CBankInstanceConstructor.cpp
mapObjectConstructors/CObjectClassesHandler.cpp mapObjectConstructors/CObjectClassesHandler.cpp
@@ -128,10 +145,6 @@ set(lib_SRCS
modding/IdentifierStorage.cpp modding/IdentifierStorage.cpp
modding/ModUtility.cpp modding/ModUtility.cpp
network/NetworkConnection.cpp
network/NetworkHandler.cpp
network/NetworkServer.cpp
networkPacks/NetPacksLib.cpp networkPacks/NetPacksLib.cpp
pathfinder/CGPathNode.cpp pathfinder/CGPathNode.cpp
@@ -225,9 +238,6 @@ set(lib_SRCS
spells/effects/RemoveObstacle.cpp spells/effects/RemoveObstacle.cpp
spells/effects/Sacrifice.cpp spells/effects/Sacrifice.cpp
vstd/DateUtils.cpp
vstd/StringUtils.cpp
ArtifactUtils.cpp ArtifactUtils.cpp
BasicTypes.cpp BasicTypes.cpp
BattleFieldHandler.cpp BattleFieldHandler.cpp
@@ -236,8 +246,6 @@ set(lib_SRCS
CArtifactInstance.cpp CArtifactInstance.cpp
CBonusTypeHandler.cpp CBonusTypeHandler.cpp
CBuildingHandler.cpp CBuildingHandler.cpp
CConfigHandler.cpp
CConsoleHandler.cpp
CCreatureHandler.cpp CCreatureHandler.cpp
CCreatureSet.cpp CCreatureSet.cpp
CGameInfoCallback.cpp CGameInfoCallback.cpp
@@ -249,7 +257,6 @@ set(lib_SRCS
CScriptingModule.cpp CScriptingModule.cpp
CSkillHandler.cpp CSkillHandler.cpp
CStack.cpp CStack.cpp
CThreadHelper.cpp
CTownHandler.cpp CTownHandler.cpp
GameSettings.cpp GameSettings.cpp
IGameCallback.cpp IGameCallback.cpp
@@ -264,12 +271,14 @@ set(lib_SRCS
RoadHandler.cpp RoadHandler.cpp
ScriptHandler.cpp ScriptHandler.cpp
TerrainHandler.cpp TerrainHandler.cpp
TextOperations.cpp
TurnTimerInfo.cpp TurnTimerInfo.cpp
VCMIDirs.cpp
VCMI_Lib.cpp VCMI_Lib.cpp
) )
if (NOT ENABLE_MINIMAL_LIB)
list(APPEND lib_SRCS ${lib_MAIN_SRCS})
endif()
# Version.cpp is a generated file # Version.cpp is a generated file
if(ENABLE_GITVERSION) if(ENABLE_GITVERSION)
list(APPEND lib_SRCS ${CMAKE_BINARY_DIR}/Version.cpp) list(APPEND lib_SRCS ${CMAKE_BINARY_DIR}/Version.cpp)
@@ -280,14 +289,61 @@ endif()
set(lib_HEADERS set(lib_HEADERS
../include/vstd/CLoggerBase.h ../include/vstd/CLoggerBase.h
../include/vstd/DateUtils.h
../include/vstd/StringUtils.h
../Global.h ../Global.h
../AUTHORS.h ../AUTHORS.h
StdInc.h StdInc.h
filesystem/AdapterLoaders.h
filesystem/CArchiveLoader.h
filesystem/CBinaryReader.h
filesystem/CCompressedStream.h
filesystem/CFileInputStream.h
filesystem/CFilesystemLoader.h
filesystem/CInputOutputStream.h
filesystem/CInputStream.h
filesystem/CMemoryBuffer.h
filesystem/CMemoryStream.h
filesystem/COutputStream.h
filesystem/CStream.h
filesystem/CZipLoader.h
filesystem/CZipSaver.h
filesystem/FileInfo.h
filesystem/Filesystem.h
filesystem/ISimpleResourceLoader.h
filesystem/MinizipExtensions.h
filesystem/ResourcePath.h
json/JsonBonus.h
json/JsonFormatException.h
json/JsonNode.h
json/JsonParser.h
json/JsonRandom.h
json/JsonUtils.h
json/JsonValidator.h
json/JsonWriter.h
logging/CBasicLogConfigurator.h
logging/CLogger.h
logging/VisualLogger.h
network/NetworkConnection.h
network/NetworkDefines.h
network/NetworkHandler.h
network/NetworkInterface.h
network/NetworkServer.h
CConfigHandler.h
CConsoleHandler.h
CThreadHelper.h
TextOperations.h
VCMIDirs.h
)
set(lib_MAIN_HEADERS
../include/vstd/ContainerUtils.h ../include/vstd/ContainerUtils.h
../include/vstd/RNG.h ../include/vstd/RNG.h
../include/vstd/DateUtils.h
../include/vstd/StringUtils.h
../include/vcmi/events/AdventureEvents.h ../include/vcmi/events/AdventureEvents.h
../include/vcmi/events/ApplyDamage.h ../include/vcmi/events/ApplyDamage.h
@@ -385,35 +441,6 @@ set(lib_HEADERS
events/PlayerGotTurn.h events/PlayerGotTurn.h
events/TurnStarted.h events/TurnStarted.h
filesystem/AdapterLoaders.h
filesystem/CArchiveLoader.h
filesystem/CBinaryReader.h
filesystem/CCompressedStream.h
filesystem/CFileInputStream.h
filesystem/CFilesystemLoader.h
filesystem/CInputOutputStream.h
filesystem/CInputStream.h
filesystem/CMemoryBuffer.h
filesystem/CMemoryStream.h
filesystem/COutputStream.h
filesystem/CStream.h
filesystem/CZipLoader.h
filesystem/CZipSaver.h
filesystem/FileInfo.h
filesystem/Filesystem.h
filesystem/ISimpleResourceLoader.h
filesystem/MinizipExtensions.h
filesystem/ResourcePath.h
json/JsonBonus.h
json/JsonFormatException.h
json/JsonNode.h
json/JsonParser.h
json/JsonRandom.h
json/JsonUtils.h
json/JsonValidator.h
json/JsonWriter.h
gameState/CGameState.h gameState/CGameState.h
gameState/CGameStateCampaign.h gameState/CGameStateCampaign.h
gameState/EVictoryLossCheckResult.h gameState/EVictoryLossCheckResult.h
@@ -423,10 +450,6 @@ set(lib_HEADERS
gameState/TavernSlot.h gameState/TavernSlot.h
gameState/QuestInfo.h gameState/QuestInfo.h
logging/CBasicLogConfigurator.h
logging/CLogger.h
logging/VisualLogger.h
mapObjectConstructors/AObjectTypeHandler.h mapObjectConstructors/AObjectTypeHandler.h
mapObjectConstructors/CBankInstanceConstructor.h mapObjectConstructors/CBankInstanceConstructor.h
mapObjectConstructors/CDefaultObjectTypeHandler.h mapObjectConstructors/CDefaultObjectTypeHandler.h
@@ -487,12 +510,6 @@ set(lib_HEADERS
modding/ModUtility.h modding/ModUtility.h
modding/ModVerificationInfo.h modding/ModVerificationInfo.h
network/NetworkConnection.h
network/NetworkDefines.h
network/NetworkHandler.h
network/NetworkInterface.h
network/NetworkServer.h
networkPacks/ArtifactLocation.h networkPacks/ArtifactLocation.h
networkPacks/BattleChanges.h networkPacks/BattleChanges.h
networkPacks/Component.h networkPacks/Component.h
@@ -622,8 +639,6 @@ set(lib_HEADERS
CArtifactInstance.h CArtifactInstance.h
CBonusTypeHandler.h CBonusTypeHandler.h
CBuildingHandler.h CBuildingHandler.h
CConfigHandler.h
CConsoleHandler.h
CCreatureHandler.h CCreatureHandler.h
CCreatureSet.h CCreatureSet.h
CGameInfoCallback.h CGameInfoCallback.h
@@ -640,7 +655,6 @@ set(lib_HEADERS
CSoundBase.h CSoundBase.h
CStack.h CStack.h
CStopWatch.h CStopWatch.h
CThreadHelper.h
CTownHandler.h CTownHandler.h
ExtraOptionsInfo.h ExtraOptionsInfo.h
FunctionList.h FunctionList.h
@@ -667,14 +681,16 @@ set(lib_HEADERS
ScopeGuard.h ScopeGuard.h
StartInfo.h StartInfo.h
TerrainHandler.h TerrainHandler.h
TextOperations.h
TurnTimerInfo.h TurnTimerInfo.h
UnlockGuard.h UnlockGuard.h
VCMIDirs.h
vcmi_endian.h vcmi_endian.h
VCMI_Lib.h VCMI_Lib.h
) )
if (NOT ENABLE_MINIMAL_LIB)
list(APPEND lib_HEADERS ${lib_MAIN_HEADERS})
endif()
assign_source_group(${lib_SRCS} ${lib_HEADERS}) assign_source_group(${lib_SRCS} ${lib_HEADERS})
if(ENABLE_STATIC_LIBS) if(ENABLE_STATIC_LIBS)
@@ -682,6 +698,7 @@ if(ENABLE_STATIC_LIBS)
else() else()
add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS}) add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
endif() endif()
set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1") set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1")
target_link_libraries(vcmi PUBLIC target_link_libraries(vcmi PUBLIC
minizip::minizip ZLIB::ZLIB minizip::minizip ZLIB::ZLIB

View File

@@ -422,6 +422,7 @@ static std::string additionalPropertiesCheck(JsonValidator & validator, const Js
static bool testFilePresence(const std::string & scope, const ResourcePath & resource) static bool testFilePresence(const std::string & scope, const ResourcePath & resource)
{ {
#ifndef ENABLE_MINIMAL_LIB
std::set<std::string> allowedScopes; std::set<std::string> allowedScopes;
if(scope != ModScope::scopeBuiltin() && !scope.empty()) // all real mods may have dependencies if(scope != ModScope::scopeBuiltin() && !scope.empty()) // all real mods may have dependencies
{ {
@@ -441,6 +442,7 @@ static bool testFilePresence(const std::string & scope, const ResourcePath & res
if (CResourceHandler::get(entry)->existsResource(resource)) if (CResourceHandler::get(entry)->existsResource(resource))
return true; return true;
} }
#endif
return false; return false;
} }