[PATCH] D73442: [CMake] Support symlinking runtimes under a different name
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 26 17:44:20 PST 2020
phosek created this revision.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
When using the per-target runtimes directory layout with the runtimes
build, this change allows symlinking runtimes under a different target
(triple) name. The example use case is as follow:
set(LLVM_RUNTIME_TARGET_x86_64-linux-gnu_SYMLINK "x86_64-unknown-linux-gnu" CACHE STRING "")
This would create a symlink x86_64-linux-gnu pointing to the
x86_64-unknown-linux-gnu runtime directory.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73442
Files:
llvm/runtimes/CMakeLists.txt
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -555,6 +555,41 @@
add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
endforeach()
endforeach()
+
+ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
+ ${PACKAGE_VERSION})
+
+ foreach(name ${LLVM_RUNTIME_TARGETS})
+ foreach(symlink ${LLVM_RUNTIME_TARGET_${name}_SYMLINK})
+ if(CMAKE_HOST_UNIX)
+ set(LLVM_LINK_OR_COPY create_symlink)
+ else()
+ set(LLVM_LINK_OR_COPY copy)
+ endif()
+ set(dst_path ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${symlink})
+ add_custom_command(TARGET runtimes-${name} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${name}" "${dst_path}")
+
+ foreach(path ${CMAKE_MODULE_PATH})
+ if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+ set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
+ break()
+ endif()
+ endforeach()
+
+ install(SCRIPT ${INSTALL_SYMLINK}
+ CODE "install_symlink(${symlink} ${name} lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})"
+ COMPONENT ${symlink})
+
+ add_custom_target(install-runtimes-${symlink}
+ DEPENDS install-runtimes-${name}
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT="${symlink}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ USES_TERMINAL)
+ add_dependencies(install-runtimes install-runtimes-${symlink})
+ endforeach()
+ endforeach()
endif()
if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73442.240459.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/c370954b/attachment.bin>
More information about the llvm-commits
mailing list