Commit Graph

12 Commits

Author SHA1 Message Date
John Ericson 0bb317b7bf Revert "[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore"
This reverts commit d5daa5c5b0.
2022-06-10 19:26:12 +00:00
John Ericson d5daa5c5b0 [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
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
2022-06-10 14:35:18 +00:00
John Ericson 44e3365775 [CMake] Factor out config prefix finding logic
See the docs in the new function for details.

 I think I found every instance of this copy pasted code. Polly could
 also use it, but currently does something different, so I will save the
 behavior change for a future revision.

We get the shared, non-installed CMake modules following the pattern
established in D116472.

It might be good to have LLD and Flang also use this, but that would be
a functional change and so I leave it as future work.

Reviewed By: beanz, lebedev.ri

Differential Revision: https://reviews.llvm.org/D116521
2022-01-07 20:16:18 +00:00
John Ericson 896537048d [lld][CMake] Use `GNUInstallDirs` to support custom installation dirs
Extracted from D99484. My new plan is to start from the outside and work
inward.

Reviewed By: stephenneuendorffer

Differential Revision: https://reviews.llvm.org/D115568
2021-12-31 18:57:57 +00:00
Shoaib Meenai 56f7e5a822 [cmake] Add support for multiple distributions
LLVM's build system contains support for configuring a distribution, but
it can often be useful to be able to configure multiple distributions
(e.g. if you want separate distributions for the tools and the
libraries). Add this support to the build system, along with
documentation and usage examples.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D89177
2021-05-12 11:13:18 -07:00
Matt Arsenault 2b2a961309 lld: Let find_package(LLD) work
Install a cmake config file. Copied exactly from how clang exports.

I also wasn't sure whether the canonical capitalization is "lld" or
"LLD". The project() is still calling this lld, but most places seemed
to capitalize it.
2020-05-14 09:59:53 -04:00
David Zarzycki 3e77b20dba [CMake] Properly conditionalize installation of lld libraries
In what appears to be a copy-and-paste error, lld currently only
installs libraries if the lld tools are configured to build.

Instead, lld should allow the libraries to be installed even if the lld
tools are not being built. Additionally, if users want to only install
the tools and not the libraries, the LLVM way of doing that is by
checking for LLVM_INSTALL_TOOLCHAIN_ONLY.

This fixes PR35960.

llvm-svn: 327126
2018-03-09 13:09:36 +00:00
Shoaib Meenai d6d11f3c73 [lld] Switch to add_llvm_install_targets
This adds install-*-stripped targets that strip during installation.

Differential Revision: https://reviews.llvm.org/D40688

llvm-svn: 319517
2017-12-01 04:17:45 +00:00
Pavel Labath dbcc04a5fa [lld][cmake] Fix BUILD_SHARED_LIBS installation
Summary:
This fixes a regression caused by D28397, which switched lld from using
add_llvm_library to llvm_add_library. The latter does not automatically set up
install rules for libraries, as it's expected the project will set them up
manually based on its own needs.

This adds the install rules to add_lld_library for lld. They were inspired by
the similar add_clang_library macro in clang.

Reviewers: ruiu, beanz, davidlt, EricWF, dtzWill

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D29007

llvm-svn: 292909
2017-01-24 10:41:02 +00:00
Pavel Labath c9fa114b28 [lld][cmake] Fix LLVM_LINK_LLVM_DYLIB build
Summary:
Lld's build had a couple of issues which prevented a successfull
LLVM_LINK_LLVM_DYLIB compilation.

- add_llvm_library vs llvm_add_library: One adds a library to libLLVM.so, other
  one doesn't. Lld was using the wrong one, causing symbols to be mupltiply
  defined in things linking to libLLVM.
- confusion when to use LINK_LIBS vs LINK_COMPONENTS in llvm_add_library
- not using LLVM_LINK_COMPONENTS for add_lld_tool

With these fixes lld compiles and it's test suite passes both in
LLVM_LINK_LLVM_DYLIB mode and without it.

Reviewers: ruiu, beanz

Subscribers: llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28397

llvm-svn: 291432
2017-01-09 09:57:08 +00:00
Petr Hosek f367a2a52b [CMake] Add install target for the lld tool
This is necessary for the distribution targets which assume that
each component has an install target. This also moves the CMake
macros into a separate file akin to other LLVM projects.

Differential Revision: https://reviews.llvm.org/D27876

llvm-svn: 290391
2016-12-23 00:22:47 +00:00
Michael J. Spencer d4eb47c110 Add VTune as an optional external dependency and add task tracking.
llvm-svn: 178940
2013-04-06 00:56:40 +00:00