1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

enable StupidAI and EmptyAI for static AI

This commit is contained in:
Andrey Filipenkov
2023-02-28 13:08:58 +03:00
parent c31a9f7f5d
commit 0294a8b063
7 changed files with 33 additions and 18 deletions

View File

@@ -49,10 +49,8 @@ endif()
add_subdirectory(BattleAI)
add_subdirectory(VCAI)
if(NOT ENABLE_STATIC_AI_LIBS)
add_subdirectory(StupidAI)
add_subdirectory(EmptyAI)
endif()
add_subdirectory(StupidAI)
add_subdirectory(EmptyAI)
if(ENABLE_NULLKILLER_AI)
add_subdirectory(Nullkiller)
endif()

View File

@@ -1,8 +1,5 @@
set(emptyAI_SRCS
StdInc.cpp
CEmptyAI.cpp
exp_funcs.cpp
)
set(emptyAI_HEADERS
@@ -11,13 +8,20 @@ set(emptyAI_HEADERS
CEmptyAI.h
)
if(NOT ENABLE_STATIC_AI_LIBS)
list(APPEND emptyAI_SRCS main.cpp StdInc.cpp)
endif()
assign_source_group(${emptyAI_SRCS} ${emptyAI_HEADERS})
add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS})
if(ENABLE_STATIC_AI_LIBS)
add_library(EmptyAI STATIC ${emptyAI_SRCS} ${emptyAI_HEADERS})
else()
add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS})
install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})
endif()
target_include_directories(EmptyAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(EmptyAI PRIVATE ${VCMI_LIB_TARGET})
vcmi_set_output_dir(EmptyAI "AI")
enable_pch(EmptyAI)
install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR} OPTIONAL)

View File

@@ -1,5 +1,5 @@
/*
* exp_funcs.cpp, part of VCMI engine
* main.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*

View File

@@ -1,7 +1,4 @@
set(stupidAI_SRCS
StdInc.cpp
main.cpp
StupidAI.cpp
)
@@ -11,13 +8,20 @@ set(stupidAI_HEADERS
StupidAI.h
)
if(NOT ENABLE_STATIC_AI_LIBS)
list(APPEND stupidAI_SRCS main.cpp StdInc.cpp)
endif()
assign_source_group(${stupidAI_SRCS} ${stupidAI_HEADERS})
add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS})
if(ENABLE_STATIC_AI_LIBS)
add_library(StupidAI STATIC ${stupidAI_SRCS} ${stupidAI_HEADERS})
else()
add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS})
install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})
endif()
target_link_libraries(StupidAI PRIVATE ${VCMI_LIB_TARGET})
target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
vcmi_set_output_dir(StupidAI "AI")
enable_pch(StupidAI)
install(TARGETS StupidAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})

View File

@@ -255,6 +255,7 @@ add_dependencies(vcmiclient vcmiserver)
if(NOT ENABLE_STATIC_AI_LIBS)
add_dependencies(vcmiclient
BattleAI
EmptyAI
StupidAI
VCAI
)

View File

@@ -20,6 +20,8 @@
# include "AI/VCAI/VCAI.h"
# include "AI/Nullkiller/AIGateway.h"
# include "AI/BattleAI/BattleAI.h"
# include "AI/StupidAI/StupidAI.h"
# include "AI/EmptyAI/CEmptyAI.h"
#else
# ifdef VCMI_WINDOWS
# include <windows.h> //for .dll libs
@@ -113,7 +115,11 @@ std::shared_ptr<CGlobalAI> createAny(const boost::filesystem::path & libpath, co
template<>
std::shared_ptr<CBattleGameInterface> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{
return std::make_shared<CBattleAI>();
if(libpath.stem() == "libBattleAI")
return std::make_shared<CBattleAI>();
else if(libpath.stem() == "libStupidAI")
return std::make_shared<CStupidAI>();
return std::make_shared<CEmptyAI>();
}
#endif // STATIC_AI

View File

@@ -3,6 +3,8 @@ if(ENABLE_STATIC_AI_LIBS)
target_compile_definitions(${VCMI_LIB_TARGET} PRIVATE STATIC_AI)
target_link_libraries(${VCMI_LIB_TARGET} PRIVATE
BattleAI
EmptyAI
StupidAI
VCAI
)
if(ENABLE_NULLKILLER_AI)