Files
clang-p2996/llvm/cmake/modules/LLVMInstallSymlink.cmake
John Ericson 7f9e6f6fa6 [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
2022-07-26 03:14:46 +00:00

26 lines
747 B
CMake

# We need to execute this script at installation time because the
# DESTDIR environment variable may be unset at configuration time.
# See PR8397.
include(GNUInstallDirs)
function(install_symlink name target outdir)
set(DESTDIR $ENV{DESTDIR})
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 "${outdir}" ERROR_VARIABLE has_err)
if(CMAKE_HOST_WIN32 AND has_err)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
WORKING_DIRECTORY "${outdir}")
endif()
endfunction()