add_llvm_executable(lld
  lld.cpp
  )

target_link_libraries(lld
  lldDriver
  lldCOFF
  LLVMSupport
  )

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}")
else()
  set(command copy)
  set(src "${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})

add_llvm_executable(lld
  lld.cpp
  )

target_link_libraries(lld
  lldDriver
  lldCOFF
  LLVMSupport
  )

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}")
else()
  set(command copy)
  set(src "${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})

# FIXME: Remove once the lld-link2 alias is gone.
set(dst2 "${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link2${CMAKE_EXECUTABLE_SUFFIX}")
add_custom_command(TARGET lld POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E ${command} ${src} ${dst2})

Create lld-link2 symlink/copy for new COFF linker.
Create lld-link2 symlink/copy for new COFF linker.

This situation will only be temporary; I imagine we will eventually want to
have the new linker take the lld-link alias after we remove the old one.
However, I would like to port the CFI test suite in the compiler-rt
repository to Windows using the new COFF linker's LTO support; these tests
currently use gcc-style command lines and invoke the linker via the
compiler driver.

We can select the linker using the -fuse-ld flag, which Clang supports on
Windows, but it takes an executable name, rather than a list of arguments
(so "-fuse-ld=lld -flavor link2" wouldn't work), and it doesn't seem worth
the effort to extend the Clang driver to support arguments.

Differential Revision: http://reviews.llvm.org/D11031

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@241696 91177308-0d34-0410-b5e6-96231b3b80d8
