Merge System into Support.
[oota-llvm.git] / unittests / CMakeLists.txt
1 function(add_llvm_unittest test_name)
2   if (CMAKE_BUILD_TYPE)
3     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
4       ${LLVM_BINARY_DIR}/unittests/${test_name}/${CMAKE_BUILD_TYPE})
5   else()
6     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
7       ${LLVM_BINARY_DIR}/unittests/${test_name})
8   endif()
9   if( NOT LLVM_BUILD_TESTS )
10     set(EXCLUDE_FROM_ALL ON)
11   endif()
12   add_llvm_executable(${test_name}Tests ${ARGN})
13   add_dependencies(UnitTests ${test_name}Tests)
14 endfunction()
15
16 add_custom_target(UnitTests)
17
18 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
19 add_definitions(-DGTEST_HAS_RTTI=0)
20 if (NOT LLVM_ENABLE_THREADS)
21   add_definitions(-DGTEST_HAS_PTHREAD=0)
22 endif()
23
24 set(LLVM_LINK_COMPONENTS
25   jit
26   interpreter
27   nativecodegen
28   BitWriter
29   BitReader
30   AsmParser
31   Core
32   Support
33   )
34
35 set(LLVM_USED_LIBS
36   gtest
37   gtest_main
38   LLVMSupport # gtest needs it for raw_ostream.
39   )
40
41 add_llvm_unittest(ADT
42   ADT/APFloatTest.cpp
43   ADT/APIntTest.cpp
44   ADT/BitVectorTest.cpp
45   ADT/DAGDeltaAlgorithmTest.cpp
46   ADT/DeltaAlgorithmTest.cpp
47   ADT/DenseMapTest.cpp
48   ADT/DenseSetTest.cpp
49   ADT/FoldingSet.cpp
50   ADT/ilistTest.cpp
51   ADT/ImmutableSetTest.cpp
52   ADT/IntervalMapTest.cpp
53   ADT/SmallBitVectorTest.cpp
54   ADT/SmallStringTest.cpp
55   ADT/SmallVectorTest.cpp
56   ADT/SparseBitVectorTest.cpp
57   ADT/StringMapTest.cpp
58   ADT/StringRefTest.cpp
59   ADT/TripleTest.cpp
60   ADT/TwineTest.cpp
61  )
62
63 add_llvm_unittest(Analysis
64   Analysis/ScalarEvolutionTest.cpp
65   )
66
67 add_llvm_unittest(ExecutionEngine
68   ExecutionEngine/ExecutionEngineTest.cpp
69   )
70
71 set(JITTestsSources
72   ExecutionEngine/JIT/JITEventListenerTest.cpp
73   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
74   ExecutionEngine/JIT/JITTest.cpp
75   ExecutionEngine/JIT/MultiJITTest.cpp
76   )
77
78 if(MSVC)
79   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
80 endif()
81
82 add_llvm_unittest(JIT ${JITTestsSources})
83
84 if(MINGW)
85   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
86 endif()
87
88 add_llvm_unittest(Transforms
89   Transforms/Utils/Cloning.cpp
90   )
91
92 set(VMCoreSources
93   VMCore/ConstantsTest.cpp
94   VMCore/DerivedTypesTest.cpp
95   VMCore/InstructionsTest.cpp
96   VMCore/MetadataTest.cpp
97   VMCore/PassManagerTest.cpp
98   VMCore/ValueMapTest.cpp
99   VMCore/VerifierTest.cpp
100   )
101
102 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
103 # See issue#331418 in Visual Studio.
104 if(MSVC AND MSVC_VERSION LESS 1600)
105   list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
106 endif()
107
108 add_llvm_unittest(VMCore ${VMCoreSources})
109
110 set(LLVM_LINK_COMPONENTS
111   Support
112   Core
113   )
114
115 add_llvm_unittest(Support
116   Support/AllocatorTest.cpp
117   Support/Casting.cpp
118   Support/CommandLineTest.cpp
119   Support/ConstantRangeTest.cpp
120   Support/EndianTest.cpp
121   Support/LeakDetectorTest.cpp
122   Support/MathExtrasTest.cpp
123   Support/raw_ostream_test.cpp
124   Support/RegexTest.cpp
125   Support/SwapByteOrderTest.cpp
126   Support/TypeBuilderTest.cpp
127   Support/ValueHandleTest.cpp
128   )
129
130 set(LLVM_LINK_COMPONENTS
131   Support
132   )
133
134 add_llvm_unittest(System
135   System/Path.cpp
136   System/TimeValue.cpp
137   )