2013-07-29 08:19:24 +00:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
2017-10-21 11:02:30 +00:00
|
|
|
AllTargetsAsmParsers
|
|
|
|
AllTargetsDescs
|
|
|
|
AllTargetsInfos
|
2020-04-07 22:44:43 -05:00
|
|
|
FrontendOpenMP
|
2024-12-25 11:07:05 +08:00
|
|
|
TargetParser
|
2013-07-29 08:19:24 +00:00
|
|
|
support
|
|
|
|
)
|
|
|
|
|
2020-01-23 16:42:14 -08:00
|
|
|
# Needed by LLVM's CMake checks because this file defines multiple targets.
|
|
|
|
set(LLVM_OPTIONAL_SOURCES ClangTidyMain.cpp ClangTidyToolMain.cpp)
|
|
|
|
|
2024-10-08 07:22:19 +01:00
|
|
|
add_clang_library(clangTidyMain STATIC
|
2013-07-29 08:19:24 +00:00
|
|
|
ClangTidyMain.cpp
|
2020-01-23 16:42:14 -08:00
|
|
|
|
|
|
|
LINK_LIBS
|
2020-06-16 20:43:55 +02:00
|
|
|
clangTidy
|
|
|
|
${ALL_CLANG_TIDY_CHECKS}
|
2020-06-23 11:48:04 -04:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
omp_gen
|
2023-05-10 11:48:11 -07:00
|
|
|
ClangDriverOptions
|
2020-06-16 20:43:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
clang_target_link_libraries(clangTidyMain
|
|
|
|
PRIVATE
|
2020-01-23 16:42:14 -08:00
|
|
|
clangAST
|
|
|
|
clangASTMatchers
|
|
|
|
clangBasic
|
|
|
|
clangTooling
|
|
|
|
clangToolingCore
|
|
|
|
)
|
|
|
|
|
2022-02-01 12:05:20 -05:00
|
|
|
# Support plugins.
|
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
|
|
|
set(support_plugins SUPPORT_PLUGINS)
|
|
|
|
endif()
|
|
|
|
|
2020-01-23 16:42:14 -08:00
|
|
|
add_clang_tool(clang-tidy
|
|
|
|
ClangTidyToolMain.cpp
|
2022-02-01 12:05:20 -05:00
|
|
|
|
|
|
|
DEPENDS
|
[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].
I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.
[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html
Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille
Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits
Tags: #clang, #sanitizers, #lldb, #openmp, #llvm
Differential Revision: https://reviews.llvm.org/D58791
llvm-svn: 355340
2019-03-04 21:19:53 +00:00
|
|
|
clang-resource-headers
|
2022-02-01 12:05:20 -05:00
|
|
|
${support_plugins}
|
2016-07-07 13:19:45 +00:00
|
|
|
)
|
2019-10-04 20:30:02 +00:00
|
|
|
clang_target_link_libraries(clang-tidy
|
[CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.
Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.
Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).
Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.
Differential Revision: https://reviews.llvm.org/D40823
llvm-svn: 319840
2017-12-05 21:49:56 +00:00
|
|
|
PRIVATE
|
2013-12-10 01:41:10 +00:00
|
|
|
clangAST
|
|
|
|
clangASTMatchers
|
2015-03-13 03:47:43 +00:00
|
|
|
clangBasic
|
2013-12-10 01:41:10 +00:00
|
|
|
clangTooling
|
2017-04-12 22:07:47 +00:00
|
|
|
clangToolingCore
|
2019-10-04 20:30:02 +00:00
|
|
|
)
|
|
|
|
target_link_libraries(clang-tidy
|
|
|
|
PRIVATE
|
|
|
|
clangTidy
|
2020-01-23 16:42:14 -08:00
|
|
|
clangTidyMain
|
2019-09-27 12:56:14 +00:00
|
|
|
${ALL_CLANG_TIDY_CHECKS}
|
2013-07-29 08:19:24 +00:00
|
|
|
)
|
|
|
|
|
2024-08-08 06:00:11 -07:00
|
|
|
if(CLANG_PLUGIN_SUPPORT)
|
|
|
|
export_executable_symbols_for_plugins(clang-tidy)
|
|
|
|
endif()
|
|
|
|
|
2017-11-02 01:48:20 +00:00
|
|
|
install(PROGRAMS clang-tidy-diff.py
|
[clang-tools-extra][cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!
It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up
- Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.
- Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.
I figured it was time to make a new revision.
I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.
---
As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.
These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.
Reviewed By: #libunwind, #libc, #libc_abi, compnerd
Differential Revision: https://reviews.llvm.org/D99484
2022-01-16 05:52:22 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
|
2017-11-02 01:48:20 +00:00
|
|
|
COMPONENT clang-tidy)
|
|
|
|
install(PROGRAMS run-clang-tidy.py
|
[clang-tools-extra][cmake] Use `GNUInstallDirs` to support custom installation dirs.
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!
It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up
- Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.
- Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.
I figured it was time to make a new revision.
I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.
---
As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.
These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.
Reviewed By: #libunwind, #libc, #libc_abi, compnerd
Differential Revision: https://reviews.llvm.org/D99484
2022-01-16 05:52:22 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
2021-02-23 12:38:11 +00:00
|
|
|
COMPONENT clang-tidy
|
|
|
|
RENAME run-clang-tidy)
|