From 74ae52847d3d58f9122003386c8e7a27b7b6d71b Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Mon, 30 Dec 2013 06:48:30 +0000 Subject: [CMake][VS][XCode] Restruct the output directory layout more comfortable, ${BINARY_DIR}/${BUILD_MODE}/(bin|lib) We have been seeing nasty directory layout with CMake multiconfig, such as, bin/Release/clang.exe lib/clang/3.x/... lib/Release/clang/3.x/.. (duplicated) Move the layout similar to autoconf's; Release/bin/clang.exe Release/lib/clang/3.x/... Checked on Visual Studio 10. Could you guys please confirm my change on XCode(and other multiconfig builders)? Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more, or a certain builder, for eaxample, msbuild.exe, would be confused. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198205 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/AddLLVM.cmake | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'cmake/modules/AddLLVM.cmake') diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index b31aeeeae1..bbfb9b17ff 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -95,9 +95,30 @@ function(add_dead_strip target_name) endif() endfunction(add_dead_strip) +# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}. +# Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more, +# or a certain builder, for eaxample, msbuild.exe, would be confused. +function(set_output_directory target bindir libdir) + if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + foreach(build_mode ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${build_mode}" CONFIG_SUFFIX) + string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${bindir}) + string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${libdir}) + set_target_properties(${target} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${bi}) + set_target_properties(${target} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li}) + set_target_properties(${target} PROPERTIES "LIBDIR__OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li}) + endforeach() + else() + set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bindir}) + set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libdir}) + set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libdir}) + endif() +endfunction() + macro(add_llvm_library name) llvm_process_sources( ALL_FILES ${ARGN} ) add_library( ${name} ${ALL_FILES} ) + set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} ) add_dead_strip( ${name} ) if( LLVM_COMMON_DEPENDS ) @@ -201,6 +222,7 @@ macro(add_llvm_executable name) endif(LLVM_EXPORTED_SYMBOL_FILE) set(EXCLUDE_FROM_ALL OFF) + set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) @@ -313,12 +335,13 @@ endfunction(add_llvm_implicit_external_projects) # Generic support for adding a unittest. function(add_unittest test_suite test_name) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if( NOT LLVM_BUILD_TESTS ) set(EXCLUDE_FROM_ALL ON) endif() add_llvm_executable(${test_name} ${ARGN}) + set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) + set_output_directory(${test_name} ${outdir} ${outdir}) target_link_libraries(${test_name} gtest gtest_main -- cgit v1.2.3