[llvm] r289840 - [CMake] Minor change to symlink generation for LLDB

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 10:17:08 PST 2016

Author: cbieneman
Date: Thu Dec 15 12:17:07 2016
New Revision: 289840

URL: http://llvm.org/viewvc/llvm-project?rev=289840&view=rev
[CMake] Minor change to symlink generation for LLDB

If OUTPUT_DIR is not specified we can assume the symlink is linking to a file in the same directory, so we can use $<TARGET_FILE_NAME:${target}> to create a relative symlink.

In the case of LLDB, when we build a framework, we are creating symlinks in a different directory than the file we're pointing to, and we don't install those links. To make this work in the build directory we can use $<TARGET_FILE:${target}> instead, which uses the full path to the target.


Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=289840&r1=289839&r2=289840&view=diff
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Dec 15 12:17:07 2016
@@ -1290,6 +1290,8 @@ endfunction()
 function(add_llvm_tool_symlink link_name target)
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "OUTPUT_DIR" "" ${ARGN})
+  set(dest_binary "$<TARGET_FILE:${target}>")
   # This got a bit gross... For multi-configuration generators the target
   # properties return the resolved value of the string, not the build system
   # expression. To reconstruct the platform-agnostic path we have to do some
@@ -1298,6 +1300,11 @@ function(add_llvm_tool_symlink link_name
   # and replace it with CMAKE_CFG_INTDIR. This allows the build step to be type
   # agnostic again. 
+    # If you're not overriding the OUTPUT_DIR, we can make the link relative in
+    # the same directory.
+    if(UNIX)
+      set(dest_binary "$<TARGET_FILE_NAME:${target}>")
+    endif()
       list(GET CMAKE_CONFIGURATION_TYPES 0 first_type)
       string(TOUPPER ${first_type} first_type_upper)
@@ -1323,10 +1330,8 @@ function(add_llvm_tool_symlink link_name
     set(LLVM_LINK_OR_COPY create_symlink)
-    set(dest_binary "$<TARGET_FILE_NAME:${target}>")
     set(LLVM_LINK_OR_COPY copy)
-    set(dest_binary "$<TARGET_FILE:${target}>")
   set(output_path "${ARG_OUTPUT_DIR}/${link_name}${CMAKE_EXECUTABLE_SUFFIX}")

More information about the llvm-commits mailing list