소스 검색

Change the output path for cmake so all files go into the same root directory

Victor Luchits 8 년 전
부모
커밋
30cc2f6a01

+ 2 - 0
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)
 

+ 2 - 0
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()

+ 2 - 0
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)
 

+ 2 - 0
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)
 

+ 2 - 1
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)

+ 2 - 0
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)
 

+ 18 - 0
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()

+ 2 - 0
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)

+ 2 - 0
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)
 

+ 2 - 0
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)

+ 2 - 0
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)