07b749800c
First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.
Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.
@beanz added it in d0e1c2a550
to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.
Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.
To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.
For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D117977
67 lines
1.9 KiB
CMake
67 lines
1.9 KiB
CMake
include(GNUInstallDirs)
|
|
include(LLVMDistributionSupport)
|
|
|
|
macro(add_lld_library name)
|
|
cmake_parse_arguments(ARG
|
|
"SHARED"
|
|
""
|
|
""
|
|
${ARGN})
|
|
if(ARG_SHARED)
|
|
set(ARG_ENABLE_SHARED SHARED)
|
|
endif()
|
|
llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})
|
|
set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
|
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
get_target_export_arg(${name} LLD export_to_lldtargets)
|
|
install(TARGETS ${name}
|
|
COMPONENT ${name}
|
|
${export_to_lldtargets}
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
add_llvm_install_targets(install-${name}
|
|
DEPENDS ${name}
|
|
COMPONENT ${name})
|
|
endif()
|
|
set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
|
|
endif()
|
|
endmacro(add_lld_library)
|
|
|
|
macro(add_lld_executable name)
|
|
add_llvm_executable(${name} ${ARGN})
|
|
set_target_properties(${name} PROPERTIES FOLDER "lld executables")
|
|
endmacro(add_lld_executable)
|
|
|
|
macro(add_lld_tool name)
|
|
if (NOT LLD_BUILD_TOOLS)
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
endif()
|
|
|
|
add_lld_executable(${name} ${ARGN})
|
|
|
|
if (LLD_BUILD_TOOLS)
|
|
get_target_export_arg(${name} LLD export_to_lldtargets)
|
|
install(TARGETS ${name}
|
|
${export_to_lldtargets}
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
COMPONENT ${name})
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES)
|
|
add_llvm_install_targets(install-${name}
|
|
DEPENDS ${name}
|
|
COMPONENT ${name})
|
|
endif()
|
|
set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(add_lld_symlink name dest)
|
|
llvm_add_tool_symlink(LLD ${name} ${dest} ALWAYS_GENERATE)
|
|
# Always generate install targets
|
|
llvm_install_symlink(LLD ${name} ${dest} ALWAYS_GENERATE)
|
|
endmacro()
|