blob: eaecc9cc0ba217ec19ad4d5fdde36c76bf7a7a8a [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. Spenceree6944f2010-09-24 09:01:13 +000020
21set(LLVM_LINK_COMPONENTS
22 jit
23 interpreter
24 nativecodegen
25 BitWriter
26 BitReader
27 AsmParser
28 Core
29 System
30 Support
31 )
32
33set(LLVM_USED_LIBS
34 gtest
35 gtest_main
36 )
37
38add_llvm_unittest(ADT
39 ADT/APFloatTest.cpp
40 ADT/APIntTest.cpp
41 ADT/BitVectorTest.cpp
42 ADT/DAGDeltaAlgorithmTest.cpp
43 ADT/DeltaAlgorithmTest.cpp
44 ADT/DenseMapTest.cpp
45 ADT/DenseSetTest.cpp
46 ADT/ilistTest.cpp
47 ADT/ImmutableSetTest.cpp
Jakob Stoklund Olesen8dc92672010-11-19 04:47:19 +000048 ADT/IntervalMapTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000049 ADT/SmallBitVectorTest.cpp
50 ADT/SmallStringTest.cpp
51 ADT/SmallVectorTest.cpp
52 ADT/SparseBitVectorTest.cpp
53 ADT/StringMapTest.cpp
54 ADT/StringRefTest.cpp
55 ADT/TripleTest.cpp
56 ADT/TwineTest.cpp
Douglas Gregorc576d3d2010-09-27 16:40:43 +000057 )
Michael J. Spenceree6944f2010-09-24 09:01:13 +000058
59add_llvm_unittest(Analysis
60 Analysis/ScalarEvolutionTest.cpp
61 )
62
63add_llvm_unittest(ExecutionEngine
64 ExecutionEngine/ExecutionEngineTest.cpp
65 )
66
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000067set(JITTestsSources
Michael J. Spenceree6944f2010-09-24 09:01:13 +000068 ExecutionEngine/JIT/JITEventListenerTest.cpp
69 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
70 ExecutionEngine/JIT/JITTest.cpp
71 ExecutionEngine/JIT/MultiJITTest.cpp
72 )
73
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000074if(MSVC)
75 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
76endif()
77
78add_llvm_unittest(JIT ${JITTestsSources})
79
Michael J. Spencer12647eb2010-10-11 21:22:34 +000080add_llvm_unittest(Transforms
81 Transforms/Utils/Cloning.cpp
82 )
83
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000084set(VMCoreSources
Michael J. Spencer12647eb2010-10-11 21:22:34 +000085 VMCore/ConstantsTest.cpp
86 VMCore/DerivedTypesTest.cpp
87 VMCore/InstructionsTest.cpp
88 VMCore/MetadataTest.cpp
89 VMCore/PassManagerTest.cpp
NAKAMURA Takumib08ca272010-11-14 12:37:51 +000090 VMCore/ValueMapTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +000091 VMCore/VerifierTest.cpp
92 )
93
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000094# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
95# See issue#331418 in Visual Studio.
96if(MSVC AND MSVC_VERSION LESS 1600)
97 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
98endif()
99
100add_llvm_unittest(VMCore ${VMCoreSources})
101
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000102set(LLVM_LINK_COMPONENTS
103 System
104 Support
105 Core
106 )
107
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000108add_llvm_unittest(Support
109 Support/AllocatorTest.cpp
110 Support/Casting.cpp
111 Support/CommandLineTest.cpp
112 Support/ConstantRangeTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000113 Support/EndianTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000114 Support/LeakDetectorTest.cpp
115 Support/MathExtrasTest.cpp
116 Support/raw_ostream_test.cpp
117 Support/RegexTest.cpp
Michael J. Spencer4c099b82010-10-11 21:56:16 +0000118 Support/SwapByteOrderTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000119 Support/System.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000120 Support/TypeBuilderTest.cpp
121 Support/ValueHandleTest.cpp
122 )