diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index b827b3329..52c5526ce 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -34,6 +34,8 @@ endif() add_library(BattleAI SHARED ${battleAI_SRCS} ${battleAI_HEADERS}) target_link_libraries(BattleAI vcmi) +vcmi_set_output_dir(BattleAI "AI") + set_target_properties(BattleAI PROPERTIES ${PCH_PROPERTIES}) cotire(BattleAI) diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 415a01808..2aeab301d 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -19,6 +19,8 @@ set(emptyAI_HEADERS add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS}) target_link_libraries(EmptyAI vcmi) +vcmi_set_output_dir(EmptyAI "AI") + if (NOT APPLE) # Already inside vcmiclient bundle install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) endif() diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index 2aacbb89c..a83fc5e35 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -19,6 +19,8 @@ set(stupidAI_HEADERS add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS}) target_link_libraries(StupidAI vcmi) +vcmi_set_output_dir(StupidAI "AI") + set_target_properties(StupidAI PROPERTIES ${PCH_PROPERTIES}) cotire(StupidAI) diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index 4b33645b4..07a635ba6 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -38,6 +38,8 @@ else() target_link_libraries(VCAI fl-static vcmi) endif() +vcmi_set_output_dir(VCAI "AI") + set_target_properties(VCAI PROPERTIES ${PCH_PROPERTIES}) cotire(VCAI) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ad5390d8..204cf9e40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 2.8.12) # where to look for cmake modules set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) +include(VCMIUtils) + # enable Release mode but only if it was not set if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) @@ -363,7 +365,6 @@ else() set(CPACK_GENERATOR TGZ) endif() - include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in" "${CMAKE_BINARY_DIR}/Version.cpp" @ONLY) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 09703ab3d..fcec55119 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -200,6 +200,8 @@ endif() target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${SYSTEM_LIBS}) +vcmi_set_output_dir(vcmiclient "") + set_target_properties(vcmiclient PROPERTIES ${PCH_PROPERTIES}) cotire(vcmiclient) diff --git a/cmake_modules/VCMIUtils.cmake b/cmake_modules/VCMIUtils.cmake new file mode 100644 index 000000000..62685e62a --- /dev/null +++ b/cmake_modules/VCMIUtils.cmake @@ -0,0 +1,18 @@ +####################################### +# Output directories # +####################################### + +macro(vcmi_set_output_dir name dir) + # multi-config builds (e.g. msvc) + foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGUPPERCASE) + set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) + set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) + set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIGUPPERCASE} ${CMAKE_BINARY_DIR}/${OUTPUTCONFIG}/${dir}) + endforeach() + + # generic no-config case (e.g. with mingw) + set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) + set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) + set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/${dir}) +endmacro() diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 21e78f639..cf6de45f7 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -68,6 +68,8 @@ else() target_link_libraries(vcmilauncher vcmi ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${SDL_LIBRARY}) endif() +vcmi_set_output_dir(vcmilauncher "") + # temporary(?) disabled - generation of PCH takes too much time since cotire is trying to collect all Qt headers #set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES}) #cotire(vcmilauncher) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index cb7a0dfbb..8a481a6d0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -301,6 +301,8 @@ if (ANDROID) return() endif() +vcmi_set_output_dir(vcmi "") + set_target_properties(vcmi PROPERTIES ${PCH_PROPERTIES}) cotire(vcmi) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index e2fb800a1..18a6d63af 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -32,6 +32,8 @@ if(WIN32) set_target_properties(vcmiserver PROPERTIES OUTPUT_NAME VCMI_server) endif() +vcmi_set_output_dir(vcmiserver "") + set_target_properties(vcmiserver PROPERTIES ${PCH_PROPERTIES}) set_target_properties(vcmiserver PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @executable_path/") cotire(vcmiserver) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7fb5454c7..ee6f4ed7d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,6 +26,8 @@ add_executable(vcmitest ${test_SRCS} ${test_HEADERS}) target_link_libraries(vcmitest vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB}) add_test(vcmitest vcmitest) +vcmi_set_output_dir(vcmitest "") + set_target_properties(vcmitest PROPERTIES ${PCH_PROPERTIES}) cotire(vcmitest)