diff options
| author | Shoaib Meenai <smeenai@fb.com> | 2017-12-05 21:49:56 +0000 |
|---|---|---|
| committer | Shoaib Meenai <smeenai@fb.com> | 2017-12-05 21:49:56 +0000 |
| commit | 3376d39717b091c336960a2ca8444a0ac0c15c3c (patch) | |
| tree | 559092aee66b623f5f26ce88040bcad96c44015f /unittests | |
| parent | 08b8ce3f548a304eac4545e5483addd630e7113b (diff) | |
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
| -rw-r--r-- | unittests/change-namespace/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/clang-apply-replacements/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/clang-move/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/clang-query/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/clang-tidy/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/clangd/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/include-fixer/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unittests/include-fixer/find-all-symbols/CMakeLists.txt | 1 |
8 files changed, 8 insertions, 0 deletions
diff --git a/unittests/change-namespace/CMakeLists.txt b/unittests/change-namespace/CMakeLists.txt index 8091cf2c..3745bbdf 100644 --- a/unittests/change-namespace/CMakeLists.txt +++ b/unittests/change-namespace/CMakeLists.txt @@ -16,6 +16,7 @@ add_extra_unittest(ChangeNamespaceTests ) target_link_libraries(ChangeNamespaceTests + PRIVATE clangAST clangASTMatchers clangBasic diff --git a/unittests/clang-apply-replacements/CMakeLists.txt b/unittests/clang-apply-replacements/CMakeLists.txt index f06dae67..180aef10 100644 --- a/unittests/clang-apply-replacements/CMakeLists.txt +++ b/unittests/clang-apply-replacements/CMakeLists.txt @@ -13,6 +13,7 @@ add_extra_unittest(ClangApplyReplacementsTests ) target_link_libraries(ClangApplyReplacementsTests + PRIVATE clangApplyReplacements clangBasic clangToolingCore diff --git a/unittests/clang-move/CMakeLists.txt b/unittests/clang-move/CMakeLists.txt index e393b291..fea15e17 100644 --- a/unittests/clang-move/CMakeLists.txt +++ b/unittests/clang-move/CMakeLists.txt @@ -16,6 +16,7 @@ add_extra_unittest(ClangMoveTests ) target_link_libraries(ClangMoveTests + PRIVATE clangAST clangASTMatchers clangBasic diff --git a/unittests/clang-query/CMakeLists.txt b/unittests/clang-query/CMakeLists.txt index 3f145d20..21d82b77 100644 --- a/unittests/clang-query/CMakeLists.txt +++ b/unittests/clang-query/CMakeLists.txt @@ -12,6 +12,7 @@ add_extra_unittest(ClangQueryTests ) target_link_libraries(ClangQueryTests + PRIVATE clangAST clangASTMatchers clangBasic diff --git a/unittests/clang-tidy/CMakeLists.txt b/unittests/clang-tidy/CMakeLists.txt index c284fd7e..c5644537 100644 --- a/unittests/clang-tidy/CMakeLists.txt +++ b/unittests/clang-tidy/CMakeLists.txt @@ -19,6 +19,7 @@ add_extra_unittest(ClangTidyTests ReadabilityModuleTest.cpp) target_link_libraries(ClangTidyTests + PRIVATE clangAST clangASTMatchers clangBasic diff --git a/unittests/clangd/CMakeLists.txt b/unittests/clangd/CMakeLists.txt index bd0aac0b..98727da2 100644 --- a/unittests/clangd/CMakeLists.txt +++ b/unittests/clangd/CMakeLists.txt @@ -18,6 +18,7 @@ add_extra_unittest(ClangdTests ) target_link_libraries(ClangdTests + PRIVATE clangBasic clangDaemon clangFormat diff --git a/unittests/include-fixer/CMakeLists.txt b/unittests/include-fixer/CMakeLists.txt index caab1cb3..80284a63 100644 --- a/unittests/include-fixer/CMakeLists.txt +++ b/unittests/include-fixer/CMakeLists.txt @@ -17,6 +17,7 @@ add_extra_unittest(IncludeFixerTests ) target_link_libraries(IncludeFixerTests + PRIVATE clangBasic clangFormat clangFrontend diff --git a/unittests/include-fixer/find-all-symbols/CMakeLists.txt b/unittests/include-fixer/find-all-symbols/CMakeLists.txt index 5cd29d0e..5689285f 100644 --- a/unittests/include-fixer/find-all-symbols/CMakeLists.txt +++ b/unittests/include-fixer/find-all-symbols/CMakeLists.txt @@ -13,6 +13,7 @@ add_extra_unittest(FindAllSymbolsTests ) target_link_libraries(FindAllSymbolsTests + PRIVATE clangAST clangASTMatchers clangBasic |
