[PATCH] D101070: [llvm][cmake] Make `install_symlink` robust to absolute dirs.
John Ericson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 25 08:40:15 PDT 2022
Ericson2314 updated this revision to Diff 447358.
Ericson2314 added a comment.
Rebase, make caller responsible for making paths absolute
This avoids module resolution issues.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101070/new/
https://reviews.llvm.org/D101070
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/LLVMInstallSymlink.cmake
Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===================================================================
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -1,22 +1,26 @@
# We need to execute this script at installation time because the
# DESTDIR environment variable may be unset at configuration time.
# See PR8397.
+#
+# `outdir` must be an absolute path. This module gets a very reduced
+# `CMAKE_MODULE_PATH` so it is easier to make the caller the responsible
+# for this.
include(GNUInstallDirs)
function(install_symlink name target outdir)
set(DESTDIR $ENV{DESTDIR})
- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+ set(outdir "${DESTDIR}${outdir}")
message(STATUS "Creating ${name}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
- WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
+ WORKING_DIRECTORY "${outdir}" ERROR_VARIABLE has_err)
if(CMAKE_HOST_WIN32 AND has_err)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
- WORKING_DIRECTORY "${bindir}")
+ WORKING_DIRECTORY "${outdir}")
endif()
endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1950,7 +1950,7 @@
function(add_lit_testsuites project directory)
if (NOT LLVM_ENABLE_IDE)
cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER" "PARAMS;DEPENDS;ARGS" ${ARGN})
-
+
if (NOT ARG_FOLDER)
set(ARG_FOLDER "Test Subdirectories")
endif()
@@ -2006,11 +2006,14 @@
set(output_dir lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 AND "${type}" STREQUAL "SHARED")
- set(output_dir bin)
+ set(output_dir "${CMAKE_INSTALL_BINDIR}")
endif()
+ # `install_symlink` needs an absoute path.
+ extend_path(output_dir "${CMAKE_INSTALL_PREFIX}" "${output_dir}")
+
install(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
+ CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\")"
COMPONENT ${component})
endfunction()
@@ -2045,8 +2048,11 @@
set(full_dest llvm${CMAKE_EXECUTABLE_SUFFIX})
endif()
+ # `install_symlink` needs an absoute path.
+ extend_path(output_dir "${CMAKE_INSTALL_PREFIX}" "${${project}_TOOLS_INSTALL_DIR}")
+
install(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(${full_name} ${full_dest} ${${project}_TOOLS_INSTALL_DIR})"
+ CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\")"
COMPONENT ${component})
if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101070.447358.patch
Type: text/x-patch
Size: 2791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220725/a107cd5d/attachment.bin>
More information about the cfe-commits
mailing list