summaryrefslogtreecommitdiffstats
path: root/llvm/cmake/modules
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-12-05 03:28:03 +0000
committerChris Bieneman <beanz@apple.com>2016-12-05 03:28:03 +0000
commit89e08ed0c161131ec5f11dd21863b941ddc9e76b (patch)
treeb878030177adb3198fffb7e750ffbbef12d08d41 /llvm/cmake/modules
parentca17841fc4adee75968b3b5096c470bade697bf0 (diff)
downloadbcm5719-llvm-89e08ed0c161131ec5f11dd21863b941ddc9e76b.tar.gz
bcm5719-llvm-89e08ed0c161131ec5f11dd21863b941ddc9e76b.zip
[CMake] Refactor add_llvm_tool_symlink for reuse
The old implementation of add_llvm_tool_symlink could fail in odd ways when building out of tree. This version solves that problem by not using the LLVM_* variables, and instead reaeding the target's properties. llvm-svn: 288632
Diffstat (limited to 'llvm/cmake/modules')
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake37
1 files changed, 24 insertions, 13 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 7941ceda56a..0d2fe37aeba 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1288,43 +1288,54 @@ function(llvm_install_symlink name dest)
endif()
endfunction()
-function(add_llvm_tool_symlink name dest)
- cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
+function(add_llvm_tool_symlink link_name target)
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "OUTPUT_DIR" "" ${ARGN})
+ if(NOT ARG_OUTPUT_DIR)
+ get_target_property(target_type ${target} TYPE)
+ if(${target_type} STREQUAL "STATIC_LIBRARY")
+ get_target_property(ARG_OUTPUT_DIR ${target} ARCHIVE_OUTPUT_DIRECTORY)
+ elseif(UNIX AND ${target_type} STREQUAL "SHARED_LIBRARY")
+ get_target_property(ARG_OUTPUT_DIR ${target} LIBRARY_OUTPUT_DIRECTORY)
+ else()
+ get_target_property(ARG_OUTPUT_DIR ${target} RUNTIME_OUTPUT_DIRECTORY)
+ endif()
+ endif()
+
if(UNIX)
set(LLVM_LINK_OR_COPY create_symlink)
- set(dest_binary "${dest}${CMAKE_EXECUTABLE_SUFFIX}")
+ set(dest_binary "$<TARGET_FILE_NAME:${target}>")
else()
set(LLVM_LINK_OR_COPY copy)
- set(dest_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/${dest}${CMAKE_EXECUTABLE_SUFFIX}")
+ set(dest_binary "$<TARGET_FILE:${target}>")
endif()
- set(output_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
+ set(output_path "${ARG_OUTPUT_DIR}/${link_name}${CMAKE_EXECUTABLE_SUFFIX}")
- set(target_name ${name})
- if(TARGET ${name})
- set(target_name ${name}-link)
+ set(target_name ${link_name})
+ if(TARGET ${link_name})
+ set(target_name ${link_name}-link)
endif()
if(ARG_ALWAYS_GENERATE)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${dest_binary})
- add_custom_command(TARGET ${dest} POST_BUILD
+ add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}")
else()
add_custom_command(OUTPUT ${output_path}
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}"
- DEPENDS ${dest})
- add_custom_target(${target_name} ALL DEPENDS ${output_path})
+ DEPENDS ${target})
+ add_custom_target(${target_name} ALL DEPENDS ${target} ${output_path})
set_target_properties(${target_name} PROPERTIES FOLDER Tools)
# Make sure both the link and target are toolchain tools
- if (${name} IN_LIST LLVM_TOOLCHAIN_TOOLS AND ${dest} IN_LIST LLVM_TOOLCHAIN_TOOLS)
+ if (${link_name} IN_LIST LLVM_TOOLCHAIN_TOOLS AND ${target} IN_LIST LLVM_TOOLCHAIN_TOOLS)
set(TOOL_IS_TOOLCHAIN ON)
endif()
if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
- llvm_install_symlink(${name} ${dest})
+ llvm_install_symlink(${link_name} ${target})
endif()
endif()
endfunction()
OpenPOWER on IntegriCloud