Skip to content

Commit 03a791f

Browse files
authored
Revert "[cmake] Refactor clang unittest cmake" (llvm#134022)
Reverts llvm#133545 This change is breaking several buildbots as well as developer's builds. Reverting to allow people to make progress.
1 parent 97dcbde commit 03a791f

File tree

28 files changed

+289
-162
lines changed

28 files changed

+289
-162
lines changed

clang/unittests/AST/ByteCode/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ add_clang_unittest(InterpTests
22
BitcastBuffer.cpp
33
Descriptor.cpp
44
toAPValue.cpp
5-
CLANG_LIBS
5+
)
6+
7+
clang_target_link_libraries(InterpTests
8+
PRIVATE
69
clangAST
710
clangASTMatchers
811
clangBasic
912
clangFrontend
1013
clangSerialization
1114
clangTooling
12-
LINK_LIBS
13-
clangTesting
1415
)
16+
17+
target_link_libraries(InterpTests
18+
PRIVATE
19+
clangTesting
20+
)

clang/unittests/AST/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
Support
4+
TargetParser
5+
)
6+
7+
18
add_subdirectory(ByteCode)
29

310
add_clang_unittest(ASTTests
@@ -36,20 +43,22 @@ add_clang_unittest(ASTTests
3643
TemplateNameTest.cpp
3744
TypePrinterTest.cpp
3845
UnresolvedSetTest.cpp
39-
CLANG_LIBS
46+
)
47+
48+
clang_target_link_libraries(ASTTests
49+
PRIVATE
4050
clangAST
4151
clangASTMatchers
4252
clangBasic
4353
clangFrontend
4454
clangLex
4555
clangSerialization
4656
clangTooling
47-
LINK_LIBS
57+
)
58+
59+
target_link_libraries(ASTTests
60+
PRIVATE
4861
clangTesting
4962
LLVMTestingAnnotations
5063
LLVMTestingSupport
51-
LLVM_COMPONENTS
52-
FrontendOpenMP
53-
Support
54-
TargetParser
55-
)
64+
)
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
Support
4+
TargetParser
5+
)
6+
17
add_clang_unittest(ASTMatchersTests
28
ASTMatchersInternalTest.cpp
39
ASTMatchersNodeTest.cpp
410
ASTMatchersNarrowingTest.cpp
511
ASTMatchersTraversalTest.cpp
612
GtestMatchersTest.cpp
7-
CLANG_LIBS
13+
)
14+
15+
clang_target_link_libraries(ASTMatchersTests
16+
PRIVATE
817
clangAST
918
clangASTMatchers
1019
clangBasic
1120
clangFrontend
1221
clangSerialization
1322
clangTooling
14-
LINK_LIBS
23+
)
24+
25+
target_link_libraries(ASTMatchersTests
26+
PRIVATE
1527
clangTesting
1628
LLVMTestingSupport
17-
LLVM_COMPONENTS
18-
FrontendOpenMP
19-
Support
20-
TargetParser
21-
)
29+
)
2230

2331
add_subdirectory(Dynamic)
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
Support
4+
)
5+
16
add_clang_unittest(DynamicASTMatchersTests
27
VariantValueTest.cpp
38
ParserTest.cpp
49
RegistryTest.cpp
5-
CLANG_LIBS
10+
)
11+
12+
clang_target_link_libraries(DynamicASTMatchersTests
13+
PRIVATE
614
clangAST
715
clangASTMatchers
816
clangBasic
917
clangDynamicASTMatchers
1018
clangFrontend
1119
clangSerialization
1220
clangTooling
13-
LINK_LIBS
21+
)
22+
23+
target_link_libraries(DynamicASTMatchersTests
24+
PRIVATE
1425
clangTesting
15-
LLVM_COMPONENTS
16-
FrontendOpenMP
17-
Support
1826
)
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
Support
4+
)
5+
16
add_clang_unittest(ClangAnalysisTests
27
CFGDominatorTree.cpp
38
CFGTest.cpp
@@ -6,7 +11,10 @@ add_clang_unittest(ClangAnalysisTests
611
IntervalPartitionTest.cpp
712
MacroExpansionContextTest.cpp
813
UnsafeBufferUsageTest.cpp
9-
CLANG_LIBS
14+
)
15+
16+
clang_target_link_libraries(ClangAnalysisTests
17+
PRIVATE
1018
clangAST
1119
clangASTMatchers
1220
clangAnalysis
@@ -15,12 +23,12 @@ add_clang_unittest(ClangAnalysisTests
1523
clangLex
1624
clangSerialization
1725
clangTooling
18-
LINK_LIBS
26+
)
27+
28+
target_link_libraries(ClangAnalysisTests
29+
PRIVATE
1930
clangTesting
2031
LLVMTestingSupport
21-
LLVM_COMPONENTS
22-
FrontendOpenMP
23-
Support
2432
)
2533

2634
add_subdirectory(FlowSensitive)

clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
Support
4+
)
5+
16
add_clang_unittest(ClangAnalysisFlowSensitiveTests
27
ArenaTest.cpp
38
ASTOpsTest.cpp
@@ -25,7 +30,10 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests
2530
UncheckedOptionalAccessModelTest.cpp
2631
ValueTest.cpp
2732
WatchedLiteralsSolverTest.cpp
28-
CLANG_LIBS
33+
)
34+
35+
clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
36+
PRIVATE
2937
clangAST
3038
clangASTMatchers
3139
clangAnalysis
@@ -36,11 +44,11 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests
3644
clangLex
3745
clangSerialization
3846
clangTooling
39-
LINK_LIBS
47+
)
48+
49+
target_link_libraries(ClangAnalysisFlowSensitiveTests
50+
PRIVATE
4051
clangTesting
4152
LLVMTestingAnnotations
4253
LLVMTestingSupport
43-
LLVM_COMPONENTS
44-
FrontendOpenMP
45-
Support
4654
)

clang/unittests/Basic/CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Support
3+
)
4+
15
add_clang_unittest(BasicTests
26
CharInfoTest.cpp
37
DarwinSDKInfoTest.cpp
@@ -8,11 +12,15 @@ add_clang_unittest(BasicTests
812
SanitizersTest.cpp
913
SarifTest.cpp
1014
SourceManagerTest.cpp
11-
CLANG_LIBS
15+
)
16+
17+
clang_target_link_libraries(BasicTests
18+
PRIVATE
1219
clangBasic
1320
clangLex
14-
LINK_LIBS
15-
LLVMTestingSupport
16-
LLVM_COMPONENTS
17-
Support
1821
)
22+
23+
target_link_libraries(BasicTests
24+
PRIVATE
25+
LLVMTestingSupport
26+
)

clang/unittests/CMakeLists.txt

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,12 @@ if(CLANG_BUILT_STANDALONE)
1515
endif()
1616
endif()
1717

18-
# add_clang_unittest(test_name file1.cpp file2.cpp)
18+
# add_clang_unittest(test_dirname file1.cpp file2.cpp)
1919
#
2020
# Will compile the list of files together and link against the clang
21-
# Produces a binary named 'basename(test_name)'.
22-
function(add_clang_unittest test_name)
23-
cmake_parse_arguments(ARG
24-
""
25-
""
26-
"CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS"
27-
${ARGN})
28-
29-
if (NOT ${test_name} MATCHES "Tests$")
30-
message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find it.")
31-
endif()
32-
33-
# LLVM_COMPONENTS is for LLVM_LINK_COMPONENTS deps, and must be before
34-
# add_unittest.
35-
list(APPEND LLVM_LINK_COMPONENTS ${ARG_LLVM_COMPONENTS})
36-
37-
add_unittest(ClangUnitTests ${test_name} ${ARG_UNPARSED_ARGUMENTS})
38-
39-
# Clang libs either come from the entire dylib, or individual libraries.
40-
if (CLANG_LINK_CLANG_DYLIB)
41-
list(APPEND ARG_LINK_LIBS clang-cpp)
42-
else()
43-
list(APPEND ARG_LINK_LIBS ${ARG_CLANG_LIBS})
44-
endif()
45-
46-
# LINK_LIBS is for normal library dependencies.
47-
target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
21+
# Produces a binary named 'basename(test_dirname)'.
22+
function(add_clang_unittest test_dirname)
23+
add_unittest(ClangUnitTests ${test_dirname} ${ARGN})
4824
endfunction()
4925

5026
add_subdirectory(Basic)
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Core
3+
Support
4+
TargetParser
5+
)
6+
17
add_clang_unittest(ClangCodeGenTests
28
BufferSourceTest.cpp
39
CodeGenExternalTest.cpp
410
TBAAMetadataTest.cpp
511
CheckTargetFeaturesTest.cpp
6-
CLANG_LIBS
12+
)
13+
14+
clang_target_link_libraries(ClangCodeGenTests
15+
PRIVATE
716
clangAST
817
clangBasic
918
clangCodeGen
1019
clangFrontend
1120
clangLex
1221
clangParse
1322
clangSerialization
14-
LLVM_COMPONENTS
15-
Core
16-
Support
17-
TargetParser
1823
)
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
set(LLVM_LINK_COMPONENTS
2+
${LLVM_TARGETS_TO_BUILD}
3+
Support
4+
)
5+
16
add_clang_unittest(CrossTUTests
27
CrossTranslationUnitTest.cpp
3-
CLANG_LIBS
8+
)
9+
10+
clang_target_link_libraries(CrossTUTests
11+
PRIVATE
412
clangAST
513
clangBasic
614
clangCrossTU
715
clangFrontend
816
clangSerialization
917
clangTooling
10-
LLVM_COMPONENTS
11-
Support
1218
)
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME STREQUAL Windows)
22

3+
set(LLVM_LINK_COMPONENTS
4+
Support
5+
)
6+
37
add_clang_unittest(DirectoryWatcherTests
48
DirectoryWatcherTest.cpp
5-
LINK_LIBS
9+
)
10+
11+
target_link_libraries(DirectoryWatcherTests
12+
PRIVATE
613
LLVMTestingSupport
714
clangDirectoryWatcher
8-
LLVM_COMPONENTS
9-
Support
1015
)
1116

1217
endif()

clang/unittests/Driver/CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
set(LLVM_LINK_COMPONENTS
2+
${LLVM_TARGETS_TO_BUILD}
3+
MC
4+
Option
5+
Support
6+
TargetParser
7+
)
8+
19
add_clang_unittest(ClangDriverTests
210
DistroTest.cpp
311
DXCModeTest.cpp
@@ -7,15 +15,12 @@ add_clang_unittest(ClangDriverTests
715
MultilibBuilderTest.cpp
816
MultilibTest.cpp
917
SanitizerArgsTest.cpp
10-
CLANG_LIBS
18+
)
19+
20+
clang_target_link_libraries(ClangDriverTests
21+
PRIVATE
1122
clangDriver
1223
clangBasic
1324
clangFrontend # For TextDiagnosticPrinter.
1425
clangSerialization
15-
LLVM_COMPONENTS
16-
${LLVM_TARGETS_TO_BUILD}
17-
MC
18-
Option
19-
Support
20-
TargetParser
2126
)

0 commit comments

Comments
 (0)