1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CMake more transitive

-Moving AIs cmake to target focusing code
-Beign explicit when link libraries
This commit is contained in:
Michał Kalinowski 2019-03-20 20:58:15 +01:00 committed by ArseniyShestakov
parent c310a05ee0
commit ec536e613c
9 changed files with 28 additions and 27 deletions

View File

@ -1,5 +1,3 @@
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(battleAI_SRCS set(battleAI_SRCS
StdInc.cpp StdInc.cpp
@ -34,7 +32,8 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l
endif() endif()
add_library(BattleAI SHARED ${battleAI_SRCS} ${battleAI_HEADERS}) add_library(BattleAI SHARED ${battleAI_SRCS} ${battleAI_HEADERS})
target_link_libraries(BattleAI vcmi) target_include_directories(BattleAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(BattleAI PRIVATE vcmi)
vcmi_set_output_dir(BattleAI "AI") vcmi_set_output_dir(BattleAI "AI")

View File

@ -1,5 +1,3 @@
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(emptyAI_SRCS set(emptyAI_SRCS
StdInc.cpp StdInc.cpp
@ -16,7 +14,8 @@ set(emptyAI_HEADERS
assign_source_group(${emptyAI_SRCS} ${emptyAI_HEADERS}) assign_source_group(${emptyAI_SRCS} ${emptyAI_HEADERS})
add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS}) add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS})
target_link_libraries(EmptyAI vcmi) target_include_directories(EmptyAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(EmptyAI PRIVATE vcmi)
vcmi_set_output_dir(EmptyAI "AI") vcmi_set_output_dir(EmptyAI "AI")

View File

@ -1,5 +1,3 @@
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(stupidAI_SRCS set(stupidAI_SRCS
StdInc.cpp StdInc.cpp
@ -16,7 +14,8 @@ set(stupidAI_HEADERS
assign_source_group(${stupidAI_SRCS} ${stupidAI_HEADERS}) assign_source_group(${stupidAI_SRCS} ${stupidAI_HEADERS})
add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS}) add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS})
target_link_libraries(StupidAI vcmi) target_link_libraries(StupidAI PRIVATE vcmi)
target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
vcmi_set_output_dir(StupidAI "AI") vcmi_set_output_dir(StupidAI "AI")

View File

@ -1,10 +1,3 @@
if(FL_FOUND)
include_directories(${FL_INCLUDE_DIRS})
else()
include_directories(${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
endif()
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(VCAI_SRCS set(VCAI_SRCS
StdInc.cpp StdInc.cpp
@ -115,10 +108,18 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l
endif() endif()
add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS}) add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS})
if(FL_FOUND) if(FL_FOUND)
target_link_libraries(VCAI ${FL_LIBRARIES} vcmi) target_include_directories(VCAI PUBLIC ${FL_INCLUDE_DIRS})
else() else()
target_link_libraries(VCAI fl-static vcmi) target_include_directories(VCAI PUBLIC ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
endif()
target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(FL_FOUND)
target_link_libraries(VCAI PRIVATE ${FL_LIBRARIES} vcmi)
else()
target_link_libraries(VCAI PRIVATE fl-static vcmi)
endif() endif()
vcmi_set_output_dir(VCAI "AI") vcmi_set_output_dir(VCAI "AI")

View File

@ -46,7 +46,7 @@ set(VCMI_VERSION_PATCH 0)
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF) option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON) option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
option(ENABLE_TEST "Enable compilation of unit tests" OFF) option(ENABLE_TEST "Enable compilation of unit tests" ON)
option(ENABLE_PCH "Enable compilation using precompiled headers" ON) option(ENABLE_PCH "Enable compilation using precompiled headers" 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_DEBUG_CONSOLE "Enable debug console for Windows builds" ON) option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)

View File

@ -173,9 +173,9 @@ if(WIN32)
endif() endif()
endif() endif()
target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} target_link_libraries(vcmiclient PRIVATE
${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY} vcmi ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY}
${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS} ${SYSTEM_LIBS} ${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS}
) )
target_include_directories(vcmi target_include_directories(vcmi

View File

@ -353,7 +353,10 @@ assign_source_group(${lib_SRCS} ${lib_HEADERS})
add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS}) add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1") set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1")
target_link_libraries(vcmi ${MINIZIP_LIBRARIES} ${Boost_LIBRARIES} ${SDL2_LIBRARY} ${ZLIB_LIBRARIES} ${SYSTEM_LIBS}) target_link_libraries(vcmi PUBLIC
${MINIZIP_LIBRARIES} ${SDL2_LIBRARY} ${ZLIB_LIBRARIES}
${SYSTEM_LIBS} ${Boost_LIBRARIES}
)
target_include_directories(vcmi target_include_directories(vcmi
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -24,7 +24,7 @@ endif()
add_executable(vcmiserver ${server_SRCS} ${server_HEADERS}) add_executable(vcmiserver ${server_SRCS} ${server_HEADERS})
target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${SYSTEM_LIBS}) target_link_libraries(vcmiserver PRIVATE vcmi)
target_include_directories(vcmiserver target_include_directories(vcmiserver
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -108,10 +108,10 @@ set(mock_HEADERS
add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL) add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL)
add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc) add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS})
target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB}) target_link_libraries(vcmitest PRIVATE gtest gmock vcmi ${SYSTEM_LIBS} VCAI)
target_include_directories( target_include_directories(vcmitest
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${GTestSrc} PRIVATE ${GTestSrc}
PRIVATE ${GTestSrc}/include PRIVATE ${GTestSrc}/include