blob: 41e20cfc902df7bfedbe785d9c7cde2ba8199a17 [file] [log] [blame]
Michael J. Spenceree6944f2010-09-24 09:01:13 +00001function(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()
Oscar Fuentes066de852010-09-25 20:25:25 +000012 add_llvm_executable(${test_name}Tests ${ARGN})
Oscar Fuentesda975632010-10-28 14:38:35 +000013 add_dependencies(UnitTests ${test_name}Tests)
Michael J. Spenceree6944f2010-09-24 09:01:13 +000014endfunction()
15
Oscar Fuentesda975632010-10-28 14:38:35 +000016add_custom_target(UnitTests)
17
Michael J. Spenceree6944f2010-09-24 09:01:13 +000018include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
Michael J. Spencer8a806ae2010-10-19 18:04:19 +000019add_definitions(-DGTEST_HAS_RTTI=0)
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +000020if (NOT LLVM_ENABLE_THREADS)
21 add_definitions(-DGTEST_HAS_PTHREAD=0)
22endif()
Michael J. Spenceree6944f2010-09-24 09:01:13 +000023
24set(LLVM_LINK_COMPONENTS
25 jit
26 interpreter
27 nativecodegen
28 BitWriter
29 BitReader
30 AsmParser
31 Core
32 System
33 Support
34 )
35
36set(LLVM_USED_LIBS
37 gtest
38 gtest_main
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +000039 LLVMSupport # gtest needs it for raw_ostream.
Michael J. Spenceree6944f2010-09-24 09:01:13 +000040 )
41
42add_llvm_unittest(ADT
43 ADT/APFloatTest.cpp
44 ADT/APIntTest.cpp
45 ADT/BitVectorTest.cpp
46 ADT/DAGDeltaAlgorithmTest.cpp
47 ADT/DeltaAlgorithmTest.cpp
48 ADT/DenseMapTest.cpp
49 ADT/DenseSetTest.cpp
Dale Johannesena197cba2010-11-19 23:23:22 +000050 ADT/FoldingSet.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000051 ADT/ilistTest.cpp
52 ADT/ImmutableSetTest.cpp
Jakob Stoklund Olesen8dc92672010-11-19 04:47:19 +000053 ADT/IntervalMapTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000054 ADT/SmallBitVectorTest.cpp
55 ADT/SmallStringTest.cpp
56 ADT/SmallVectorTest.cpp
57 ADT/SparseBitVectorTest.cpp
58 ADT/StringMapTest.cpp
59 ADT/StringRefTest.cpp
60 ADT/TripleTest.cpp
61 ADT/TwineTest.cpp
Douglas Gregorc576d3d2010-09-27 16:40:43 +000062 )
Michael J. Spenceree6944f2010-09-24 09:01:13 +000063
64add_llvm_unittest(Analysis
65 Analysis/ScalarEvolutionTest.cpp
66 )
67
68add_llvm_unittest(ExecutionEngine
69 ExecutionEngine/ExecutionEngineTest.cpp
70 )
71
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000072set(JITTestsSources
Michael J. Spenceree6944f2010-09-24 09:01:13 +000073 ExecutionEngine/JIT/JITEventListenerTest.cpp
74 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
75 ExecutionEngine/JIT/JITTest.cpp
76 ExecutionEngine/JIT/MultiJITTest.cpp
77 )
78
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000079if(MSVC)
80 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
81endif()
82
83add_llvm_unittest(JIT ${JITTestsSources})
84
Michael J. Spencer12647eb2010-10-11 21:22:34 +000085add_llvm_unittest(Transforms
86 Transforms/Utils/Cloning.cpp
87 )
88
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000089set(VMCoreSources
Michael J. Spencer12647eb2010-10-11 21:22:34 +000090 VMCore/ConstantsTest.cpp
91 VMCore/DerivedTypesTest.cpp
92 VMCore/InstructionsTest.cpp
93 VMCore/MetadataTest.cpp
94 VMCore/PassManagerTest.cpp
NAKAMURA Takumib08ca272010-11-14 12:37:51 +000095 VMCore/ValueMapTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +000096 VMCore/VerifierTest.cpp
97 )
98
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000099# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
100# See issue#331418 in Visual Studio.
101if(MSVC AND MSVC_VERSION LESS 1600)
102 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
103endif()
104
105add_llvm_unittest(VMCore ${VMCoreSources})
106
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000107set(LLVM_LINK_COMPONENTS
108 System
109 Support
110 Core
111 )
112
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000113add_llvm_unittest(Support
114 Support/AllocatorTest.cpp
115 Support/Casting.cpp
116 Support/CommandLineTest.cpp
117 Support/ConstantRangeTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000118 Support/EndianTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000119 Support/LeakDetectorTest.cpp
120 Support/MathExtrasTest.cpp
121 Support/raw_ostream_test.cpp
122 Support/RegexTest.cpp
Michael J. Spencer4c099b82010-10-11 21:56:16 +0000123 Support/SwapByteOrderTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000124 Support/TypeBuilderTest.cpp
125 Support/ValueHandleTest.cpp
126 )
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +0000127
128set(LLVM_LINK_COMPONENTS
129 System
130 )
131
132add_llvm_unittest(System
133 System/Path.cpp
134 System/TimeValue.cpp
135 )