Factor the logic for setting up a GoogleTest unit test executable into
[oota-llvm.git] / unittests / CMakeLists.txt
1 add_custom_target(UnitTests)
2 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
3
4 function(add_llvm_unittest test_dirname)
5   add_unittest(UnitTests ${test_dirname} ${ARGN})
6 endfunction()
7
8 set(LLVM_LINK_COMPONENTS
9   jit
10   interpreter
11   nativecodegen
12   BitWriter
13   BitReader
14   AsmParser
15   Core
16   Support
17   )
18
19 add_llvm_unittest(ADTTests
20   ADT/APFloatTest.cpp
21   ADT/APIntTest.cpp
22   ADT/BitVectorTest.cpp
23   ADT/DAGDeltaAlgorithmTest.cpp
24   ADT/DeltaAlgorithmTest.cpp
25   ADT/DenseMapTest.cpp
26   ADT/DenseSetTest.cpp
27   ADT/FoldingSet.cpp
28   ADT/HashingTest.cpp
29   ADT/ilistTest.cpp
30   ADT/ImmutableSetTest.cpp
31   ADT/IntEqClassesTest.cpp
32   ADT/IntervalMapTest.cpp
33   ADT/IntrusiveRefCntPtrTest.cpp
34   ADT/PackedVectorTest.cpp
35   ADT/SCCIteratorTest.cpp
36   ADT/SmallPtrSetTest.cpp
37   ADT/SmallStringTest.cpp
38   ADT/SmallVectorTest.cpp
39   ADT/SparseBitVectorTest.cpp
40   ADT/SparseSetTest.cpp
41   ADT/StringMapTest.cpp
42   ADT/StringRefTest.cpp
43   ADT/TripleTest.cpp
44   ADT/TwineTest.cpp
45   ADT/VariadicFunctionTest.cpp
46  )
47
48 add_llvm_unittest(AnalysisTests
49   Analysis/ScalarEvolutionTest.cpp
50   )
51
52 add_llvm_unittest(ExecutionEngineTests
53   ExecutionEngine/ExecutionEngineTest.cpp
54   )
55
56 if( LLVM_USE_INTEL_JITEVENTS )
57   include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
58   link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
59   set(ProfileTestSources
60     ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
61     )
62   set(LLVM_LINK_COMPONENTS
63     ${LLVM_LINK_COMPONENTS}
64     IntelJITEvents
65     ) 
66 endif( LLVM_USE_INTEL_JITEVENTS )
67
68 if( LLVM_USE_OPROFILE )
69   set(ProfileTestSources
70     ${ProfileTestSources}
71     ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
72     )
73   set(LLVM_LINK_COMPONENTS
74     ${LLVM_LINK_COMPONENTS}
75     OProfileJIT
76     )
77 endif( LLVM_USE_OPROFILE )
78
79 set(JITTestsSources
80   ExecutionEngine/JIT/JITEventListenerTest.cpp
81   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
82   ExecutionEngine/JIT/JITTest.cpp
83   ExecutionEngine/JIT/MultiJITTest.cpp
84   ${ProfileTestSources}
85   )
86
87 if(MSVC)
88   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
89 endif()
90
91 add_llvm_unittest(ExecutionEngine/JITTests
92   ${JITTestsSources}
93   )
94
95 if(MINGW OR CYGWIN)
96   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
97 endif()
98
99 add_llvm_unittest(Transforms/UtilsTests
100   Transforms/Utils/Cloning.cpp
101   )
102
103 set(VMCoreSources
104   VMCore/ConstantsTest.cpp
105   VMCore/DominatorTreeTest.cpp
106   VMCore/InstructionsTest.cpp
107   VMCore/MetadataTest.cpp
108   VMCore/PassManagerTest.cpp
109   VMCore/ValueMapTest.cpp
110   VMCore/VerifierTest.cpp
111   )
112
113 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
114 # See issue#331418 in Visual Studio.
115 if(MSVC AND MSVC_VERSION LESS 1600)
116   list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
117 endif()
118
119 add_llvm_unittest(VMCoreTests
120   ${VMCoreSources}
121   )
122
123 add_llvm_unittest(BitcodeTests
124   Bitcode/BitReaderTest.cpp
125   )
126
127 set(LLVM_LINK_COMPONENTS
128   Support
129   Core
130   )
131
132 add_llvm_unittest(SupportTests
133   Support/AlignOfTest.cpp
134   Support/AllocatorTest.cpp
135   Support/BlockFrequencyTest.cpp
136   Support/Casting.cpp
137   Support/CommandLineTest.cpp
138   Support/ConstantRangeTest.cpp
139   Support/DataExtractorTest.cpp
140   Support/EndianTest.cpp
141   Support/IntegersSubsetTest.cpp
142   Support/IRBuilderTest.cpp
143   Support/LeakDetectorTest.cpp
144   Support/ManagedStatic.cpp
145   Support/MathExtrasTest.cpp
146   Support/MDBuilderTest.cpp
147   Support/Path.cpp
148   Support/raw_ostream_test.cpp
149   Support/RegexTest.cpp
150   Support/SwapByteOrderTest.cpp
151   Support/TimeValue.cpp
152   Support/TypeBuilderTest.cpp
153   Support/ValueHandleTest.cpp
154   Support/YAMLParserTest.cpp
155   )