llvm.org GIT mirror llvm / 7c888ee
Completely refactor the structuring of unittest CMake files to match the Makefiles, the CMake files in every other part of the LLVM tree, and sanity. This should also restore the output tree structure of all the unit tests, sorry for breaking that, and thanks for letting me know. The fundamental change is to put a CMakeLists.txt file in the unittest directory, with a single test binary produced from it. This has several advantages: - No more weird directory stripping in the unittest macro, allowing it to be used more readily in other projects. - No more directory prefixes on all the source files. - Allows correct and precise use of LLVM's per-directory dependency system. - Allows use of the checking logic for source files that have not been added to the CMake build. This uncovered a file being skipped with CMake in LLVM and one in Clang's unit tests. - Makes Specifying conditional compilation or other custom logic for JIT tests easier. It did require adding the concept of an explicit 'optional' source file to the CMake build so that the missing-file check can skip cases where the file is *supposed* to be missing. =] This is another chunk of refactoring the CMake build in order to make it usable for other clients like CompilerRT / ASan / TSan. Note that this is interdependent with a Clang CMake change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158909 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 7 years ago
12 changed file(s) with 193 addition(s) and 155 deletion(s). Raw diff Collapse all Expand all
148148 endmacro(add_llvm_external_project)
149149
150150 # Generic support for adding a unittest.
151 function(add_unittest test_suite test_dirname)
152 string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
151 function(add_unittest test_suite test_name)
153152 if (CMAKE_BUILD_TYPE)
154153 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
155 ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname}/${CMAKE_BUILD_TYPE})
154 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
156155 else()
157 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
158 ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname})
156 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
159157 endif()
160158 if( NOT LLVM_BUILD_TESTS )
161159 set(EXCLUDE_FROM_ALL ON)
8080 file(GLOB globbed *.cpp)
8181 foreach(g ${globbed})
8282 get_filename_component(fn ${g} NAME)
83 list(FIND listed ${fn} idx)
83 list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
8484 if( idx LESS 0 )
85 message(SEND_ERROR "Found unknown source file ${g}
85 list(FIND listed ${fn} idx)
86 if( idx LESS 0 )
87 message(SEND_ERROR "Found unknown source file ${g}
8688 Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
89 endif()
8790 endif()
8891 endforeach()
8992 endfunction(llvm_check_source_file_list)
0 set(LLVM_LINK_COMPONENTS
1 Support
2 )
3
4 add_llvm_unittest(ADTTests
5 APFloatTest.cpp
6 APIntTest.cpp
7 BitVectorTest.cpp
8 DAGDeltaAlgorithmTest.cpp
9 DeltaAlgorithmTest.cpp
10 DenseMapTest.cpp
11 DenseSetTest.cpp
12 FoldingSet.cpp
13 HashingTest.cpp
14 ilistTest.cpp
15 ImmutableSetTest.cpp
16 IntEqClassesTest.cpp
17 IntervalMapTest.cpp
18 IntrusiveRefCntPtrTest.cpp
19 PackedVectorTest.cpp
20 SCCIteratorTest.cpp
21 SmallPtrSetTest.cpp
22 SmallStringTest.cpp
23 SmallVectorTest.cpp
24 SparseBitVectorTest.cpp
25 SparseSetTest.cpp
26 StringMapTest.cpp
27 StringRefTest.cpp
28 TripleTest.cpp
29 TwineTest.cpp
30 VariadicFunctionTest.cpp
31 )
0 set(LLVM_LINK_COMPONENTS
1 Analysis
2 )
3
4 add_llvm_unittest(AnalysisTests
5 ScalarEvolutionTest.cpp
6 )
0 set(LLVM_LINK_COMPONENTS
1 BitReader
2 BitWriter
3 )
4
5 add_llvm_unittest(BitcodeTests
6 BitReaderTest.cpp
7 )
44 add_unittest(UnitTests ${test_dirname} ${ARGN})
55 endfunction()
66
7 set(LLVM_LINK_COMPONENTS
8 jit
9 interpreter
10 nativecodegen
11 BitWriter
12 BitReader
13 AsmParser
14 Core
15 Support
16 )
17
18 add_llvm_unittest(ADTTests
19 ADT/APFloatTest.cpp
20 ADT/APIntTest.cpp
21 ADT/BitVectorTest.cpp
22 ADT/DAGDeltaAlgorithmTest.cpp
23 ADT/DeltaAlgorithmTest.cpp
24 ADT/DenseMapTest.cpp
25 ADT/DenseSetTest.cpp
26 ADT/FoldingSet.cpp
27 ADT/HashingTest.cpp
28 ADT/ilistTest.cpp
29 ADT/ImmutableSetTest.cpp
30 ADT/IntEqClassesTest.cpp
31 ADT/IntervalMapTest.cpp
32 ADT/IntrusiveRefCntPtrTest.cpp
33 ADT/PackedVectorTest.cpp
34 ADT/SCCIteratorTest.cpp
35 ADT/SmallPtrSetTest.cpp
36 ADT/SmallStringTest.cpp
37 ADT/SmallVectorTest.cpp
38 ADT/SparseBitVectorTest.cpp
39 ADT/SparseSetTest.cpp
40 ADT/StringMapTest.cpp
41 ADT/StringRefTest.cpp
42 ADT/TripleTest.cpp
43 ADT/TwineTest.cpp
44 ADT/VariadicFunctionTest.cpp
45 )
46
47 add_llvm_unittest(AnalysisTests
48 Analysis/ScalarEvolutionTest.cpp
49 )
50
51 add_llvm_unittest(ExecutionEngineTests
52 ExecutionEngine/ExecutionEngineTest.cpp
53 )
54
55 if( LLVM_USE_INTEL_JITEVENTS )
56 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
57 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
58 set(ProfileTestSources
59 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
60 )
61 set(LLVM_LINK_COMPONENTS
62 ${LLVM_LINK_COMPONENTS}
63 IntelJITEvents
64 )
65 endif( LLVM_USE_INTEL_JITEVENTS )
66
67 if( LLVM_USE_OPROFILE )
68 set(ProfileTestSources
69 ${ProfileTestSources}
70 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
71 )
72 set(LLVM_LINK_COMPONENTS
73 ${LLVM_LINK_COMPONENTS}
74 OProfileJIT
75 )
76 endif( LLVM_USE_OPROFILE )
77
78 set(JITTestsSources
79 ExecutionEngine/JIT/JITEventListenerTest.cpp
80 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
81 ExecutionEngine/JIT/JITTest.cpp
82 ExecutionEngine/JIT/MultiJITTest.cpp
83 ${ProfileTestSources}
84 )
85
86 if(MSVC)
87 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
88 endif()
89
90 add_llvm_unittest(ExecutionEngine/JITTests
91 ${JITTestsSources}
92 )
93
94 if(MINGW OR CYGWIN)
95 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
96 endif()
97
98 add_llvm_unittest(Transforms/UtilsTests
99 Transforms/Utils/Cloning.cpp
100 )
101
102 set(VMCoreSources
103 VMCore/ConstantsTest.cpp
104 VMCore/DominatorTreeTest.cpp
105 VMCore/InstructionsTest.cpp
106 VMCore/MetadataTest.cpp
107 VMCore/PassManagerTest.cpp
108 VMCore/ValueMapTest.cpp
109 VMCore/VerifierTest.cpp
110 )
111
112 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
113 # See issue#331418 in Visual Studio.
114 if(MSVC AND MSVC_VERSION LESS 1600)
115 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
116 endif()
117
118 add_llvm_unittest(VMCoreTests
119 ${VMCoreSources}
120 )
121
122 add_llvm_unittest(BitcodeTests
123 Bitcode/BitReaderTest.cpp
124 )
125
126 set(LLVM_LINK_COMPONENTS
127 Support
128 Core
129 )
130
131 add_llvm_unittest(SupportTests
132 Support/AlignOfTest.cpp
133 Support/AllocatorTest.cpp
134 Support/BlockFrequencyTest.cpp
135 Support/Casting.cpp
136 Support/CommandLineTest.cpp
137 Support/ConstantRangeTest.cpp
138 Support/DataExtractorTest.cpp
139 Support/EndianTest.cpp
140 Support/IntegersSubsetTest.cpp
141 Support/IRBuilderTest.cpp
142 Support/LeakDetectorTest.cpp
143 Support/ManagedStatic.cpp
144 Support/MathExtrasTest.cpp
145 Support/MDBuilderTest.cpp
146 Support/Path.cpp
147 Support/raw_ostream_test.cpp
148 Support/RegexTest.cpp
149 Support/SwapByteOrderTest.cpp
150 Support/TimeValue.cpp
151 Support/TypeBuilderTest.cpp
152 Support/ValueHandleTest.cpp
153 Support/YAMLParserTest.cpp
154 )
7 add_subdirectory(ADT)
8 add_subdirectory(Analysis)
9 add_subdirectory(ExecutionEngine)
10 add_subdirectory(Bitcode)
11 add_subdirectory(Support)
12 add_subdirectory(Transforms)
13 add_subdirectory(VMCore)
0 set(LLVM_LINK_COMPONENTS
1 jit
2 interpreter
3 nativecodegen
4 )
5
6 add_llvm_unittest(ExecutionEngineTests
7 ExecutionEngineTest.cpp
8 )
9
10 add_subdirectory(JIT)
0 set(LLVM_LINK_COMPONENTS
1 jit
2 interpreter
3 nativecodegen
4 )
5
6 # HACK: Declare a couple of source files as optionally compiled to satisfy the
7 # missing-file-checker in LLVM's weird CMake build.
8 set(LLVM_OPTIONAL_SOURCES
9 IntelJITEventListenerTest.cpp
10 OProfileJITEventListenerTest.cpp
11 )
12
13 if( LLVM_USE_INTEL_JITEVENTS )
14 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
15 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
16 set(ProfileTestSources
17 IntelJITEventListenerTest.cpp
18 )
19 set(LLVM_LINK_COMPONENTS
20 ${LLVM_LINK_COMPONENTS}
21 IntelJITEvents
22 )
23 endif( LLVM_USE_INTEL_JITEVENTS )
24
25 if( LLVM_USE_OPROFILE )
26 set(ProfileTestSources
27 ${ProfileTestSources}
28 OProfileJITEventListenerTest.cpp
29 )
30 set(LLVM_LINK_COMPONENTS
31 ${LLVM_LINK_COMPONENTS}
32 OProfileJIT
33 )
34 endif( LLVM_USE_OPROFILE )
35
36 set(JITTestsSources
37 JITEventListenerTest.cpp
38 JITMemoryManagerTest.cpp
39 JITTest.cpp
40 MultiJITTest.cpp
41 ${ProfileTestSources}
42 )
43
44 if(MSVC)
45 list(APPEND JITTestsSources JITTests.def)
46 endif()
47
48 add_llvm_unittest(ExecutionEngine/JITTests
49 ${JITTestsSources}
50 )
51
52 if(MINGW OR CYGWIN)
53 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
54 endif()
0 set(LLVM_LINK_COMPONENTS
1 Support
2 Core
3 )
4
5 add_llvm_unittest(SupportTests
6 AlignOfTest.cpp
7 AllocatorTest.cpp
8 BlockFrequencyTest.cpp
9 Casting.cpp
10 CommandLineTest.cpp
11 ConstantRangeTest.cpp
12 DataExtractorTest.cpp
13 EndianTest.cpp
14 IntegersSubsetTest.cpp
15 IRBuilderTest.cpp
16 LeakDetectorTest.cpp
17 ManagedStatic.cpp
18 MathExtrasTest.cpp
19 MDBuilderTest.cpp
20 Path.cpp
21 raw_ostream_test.cpp
22 RegexTest.cpp
23 SwapByteOrderTest.cpp
24 TimeValue.cpp
25 TypeBuilderTest.cpp
26 ValueHandleTest.cpp
27 YAMLParserTest.cpp
28 )
0 add_subdirectory(Utils)
0 set(LLVM_LINK_COMPONENTS
1 TransformUtils
2 )
3
4 add_llvm_unittest(UtilsTests
5 Cloning.cpp
6 Local.cpp
7 )
0 set(LLVM_LINK_COMPONENTS
1 asmparser
2 analysis
3 core
4 ipa
5 target
6 )
7
8 set(VMCoreSources
9 ConstantsTest.cpp
10 DominatorTreeTest.cpp
11 InstructionsTest.cpp
12 MetadataTest.cpp
13 PassManagerTest.cpp
14 ValueMapTest.cpp
15 VerifierTest.cpp
16 )
17
18 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
19 # See issue#331418 in Visual Studio.
20 if(MSVC AND MSVC_VERSION LESS 1600)
21 list(REMOVE_ITEM VMCoreSources ValueMapTest.cpp)
22 endif()
23
24 add_llvm_unittest(VMCoreTests
25 ${VMCoreSources}
26 )