[llvm] 7f9e6f6 - [llvm][cmake] Make `install_symlink` workflow work with absolute install dirs
John Ericson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 20:14:51 PDT 2022
Author: John Ericson
Date: 2022-07-26T03:14:46Z
New Revision: 7f9e6f6fa6547b9c5648d96fd96920467c8b3e84
URL: https://github.com/llvm/llvm-project/commit/7f9e6f6fa6547b9c5648d96fd96920467c8b3e84
DIFF: https://github.com/llvm/llvm-project/commit/7f9e6f6fa6547b9c5648d96fd96920467c8b3e84.diff
LOG: [llvm][cmake] Make `install_symlink` workflow work with absolute install dirs
If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the absolute path gets prepended with `CMAKE_INSTALL_PREFIX`.
The `extend_path` function does what we want, but it is currently internal-only. So easier to just inline the one small case of it we need.
Also fix one stray `bin` -> `CMAKE_INSTALL_BINDIR`
Reviewed By: sebastian-ne
Differential Revision: https://reviews.llvm.org/D101070
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/LLVMInstallSymlink.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 365742d3e8357..057431208322e 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1953,7 +1953,7 @@ endfunction()
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()
@@ -2009,11 +2009,11 @@ function(llvm_install_library_symlink name dest type)
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(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
+ CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\")"
COMPONENT ${component})
endfunction()
@@ -2048,8 +2048,10 @@ function(llvm_install_symlink project name dest)
set(full_dest llvm${CMAKE_EXECUTABLE_SUFFIX})
endif()
+ set(output_dir "${${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)
diff --git a/llvm/cmake/modules/LLVMInstallSymlink.cmake b/llvm/cmake/modules/LLVMInstallSymlink.cmake
index b5c35f706cb7e..e9be04aceb3d3 100644
--- a/llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ b/llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -6,17 +6,20 @@ include(GNUInstallDirs)
function(install_symlink name target outdir)
set(DESTDIR $ENV{DESTDIR})
- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+ if(NOT IS_ABSOLUTE "${outdir}")
+ set(outdir "${CMAKE_INSTALL_PREFIX}/${outdir}")
+ endif()
+ 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()
More information about the llvm-commits
mailing list