[CMake] Introduce moddir for MODULE -- corresponding to LIBRARY_OUTPUT_DIRECTORY.

On Win32.DLL, it points not lib but bin.

LIBRARY_OUTPUT_DIRECTORY affects add_library(MODULE), especially Win32.DLL.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212903 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
NAKAMURA Takumi 2014-07-13 13:33:26 +00:00
parent eddc485a8f
commit adad0d53dc

View File

@ -155,19 +155,28 @@ function(set_output_directory target bindir libdir)
return() return()
endif() endif()
# moddir -- corresponding to LIBRARY_OUTPUT_DIRECTORY.
# It affects output of add_library(MODULE).
if(WIN32 OR CYGWIN)
# DLL platform
set(moddir ${bindir})
else()
set(moddir ${libdir})
endif()
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES}) foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX) string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${bindir}) string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${bindir})
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${libdir}) string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${libdir})
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} mi ${moddir})
set_target_properties(${target} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${bi}) 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 "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li})
set_target_properties(${target} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li}) set_target_properties(${target} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${mi})
endforeach() endforeach()
else() else()
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bindir}) set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bindir})
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libdir}) set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libdir})
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libdir}) set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${moddir})
endif() endif()
endfunction() endfunction()
@ -383,9 +392,15 @@ macro(add_llvm_loadable_module name)
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else() else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if(WIN32 OR CYGWIN)
# DLL platform
set(dlldir "bin")
else()
set(dlldir "lib${LLVM_LIBDIR_SUFFIX}")
endif()
install(TARGETS ${name} install(TARGETS ${name}
EXPORT LLVMExports EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} LIBRARY DESTINATION ${dlldir}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif() endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})