lld-link: Unify symlink code with llvm-lib

llvm-svn: 246139
This commit is contained in:
Martell Malone 2015-08-27 05:18:36 +00:00
parent f71e8370d1
commit 895f9a7422
2 changed files with 14 additions and 10 deletions

View File

@ -11,18 +11,19 @@ target_link_libraries(lld
install(TARGETS lld
RUNTIME DESTINATION bin)
# Create the lld-link[.exe] symlink in the build directory. If symlink is not
# supported by the operating system, create a copy instead.
if(UNIX)
set(command create_symlink)
# Make relative symlink
set(src "lld${CMAKE_EXECUTABLE_SUFFIX}")
set(LLD_LINK_OR_COPY create_symlink)
set(lld_binary "lld${CMAKE_EXECUTABLE_SUFFIX}")
else()
set(command copy)
set(src "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld${CMAKE_EXECUTABLE_SUFFIX}")
set(LLD_LINK_OR_COPY copy)
set(lld_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld${CMAKE_EXECUTABLE_SUFFIX}")
endif()
set(dst "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX}")
add_custom_command(TARGET lld POST_BUILD
COMMAND ${CMAKE_COMMAND} -E ${command} ${src} ${dst})
set(lld_link "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX}")
add_custom_command(OUTPUT ${lld_link}
COMMAND ${CMAKE_COMMAND} -E ${LLD_LINK_OR_COPY} "${lld_binary}" "${lld_link}"
DEPENDS lld)
install(SCRIPT install_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")

View File

@ -1,3 +1,6 @@
# We need to execute this script at installation time because the
# DESTDIR environment variable may be unset at configuration time.
# See PR8397.
if(UNIX)
set(LINK_OR_COPY create_symlink)
set(DESTDIR $ENV{DESTDIR})