diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index 2c6b77f6c..eab378a65 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -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 StdInc.cpp @@ -34,7 +32,8 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l endif() 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") diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index dc3d8c08d..deac9bfa7 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -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 StdInc.cpp @@ -16,7 +14,8 @@ set(emptyAI_HEADERS assign_source_group(${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") diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index cb083c425..5575df428 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -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 StdInc.cpp @@ -16,7 +14,8 @@ set(stupidAI_HEADERS assign_source_group(${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") diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index d8d6f6798..9ff6c785c 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -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 StdInc.cpp @@ -115,10 +108,18 @@ if(ANDROID) # android compiles ai libs into main lib directly, so we skip this l endif() add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS}) + if(FL_FOUND) - target_link_libraries(VCAI ${FL_LIBRARIES} vcmi) + target_include_directories(VCAI PUBLIC ${FL_INCLUDE_DIRS}) 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() vcmi_set_output_dir(VCAI "AI") diff --git a/CMakeLists.txt b/CMakeLists.txt index 174512e43..c1c5a963f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ set(VCMI_VERSION_PATCH 0) option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF) 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_GITVERSION "Enable Version.cpp with Git commit hash" ON) option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 82d31d54a..2ba5d8f36 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -173,9 +173,9 @@ if(WIN32) endif() endif() -target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} - ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY} - ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS} ${SYSTEM_LIBS} +target_link_libraries(vcmiclient PRIVATE + vcmi ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_MIXER_LIBRARY} ${SDL2_TTF_LIBRARY} + ${FFMPEG_LIBRARIES} ${FFMPEG_EXTRA_LINKING_OPTIONS} ) target_include_directories(vcmi diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4c3457746..fdfba6656 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -353,7 +353,10 @@ assign_source_group(${lib_SRCS} ${lib_HEADERS}) add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS}) 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 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 6fc33d33e..de4f179c0 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -24,7 +24,7 @@ endif() 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 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7fb62b2be..6ad71bd12 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -108,10 +108,10 @@ set(mock_HEADERS 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) -target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB}) +add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS}) +target_link_libraries(vcmitest PRIVATE gtest gmock vcmi ${SYSTEM_LIBS} VCAI) -target_include_directories( +target_include_directories(vcmitest PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${GTestSrc} PRIVATE ${GTestSrc}/include