blob: 7953fac3bfae273b654d2c276405fc04cc00e518 [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
NAKAMURA Takumib9dec1f2010-11-26 09:32:02 +000085if(MINGW)
86 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
87endif()
88
Michael J. Spencer12647eb2010-10-11 21:22:34 +000089add_llvm_unittest(Transforms
90 Transforms/Utils/Cloning.cpp
91 )
92
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000093set(VMCoreSources
Michael J. Spencer12647eb2010-10-11 21:22:34 +000094 VMCore/ConstantsTest.cpp
95 VMCore/DerivedTypesTest.cpp
96 VMCore/InstructionsTest.cpp
97 VMCore/MetadataTest.cpp
98 VMCore/PassManagerTest.cpp
NAKAMURA Takumib08ca272010-11-14 12:37:51 +000099 VMCore/ValueMapTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000100 VMCore/VerifierTest.cpp
101 )
102
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +0000103# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
104# See issue#331418 in Visual Studio.
105if(MSVC AND MSVC_VERSION LESS 1600)
106 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
107endif()
108
109add_llvm_unittest(VMCore ${VMCoreSources})
110
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000111set(LLVM_LINK_COMPONENTS
112 System
113 Support
114 Core
115 )
116
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000117add_llvm_unittest(Support
118 Support/AllocatorTest.cpp
119 Support/Casting.cpp
120 Support/CommandLineTest.cpp
121 Support/ConstantRangeTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000122 Support/EndianTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000123 Support/LeakDetectorTest.cpp
124 Support/MathExtrasTest.cpp
125 Support/raw_ostream_test.cpp
126 Support/RegexTest.cpp
Michael J. Spencer4c099b82010-10-11 21:56:16 +0000127 Support/SwapByteOrderTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000128 Support/TypeBuilderTest.cpp
129 Support/ValueHandleTest.cpp
130 )
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +0000131
132set(LLVM_LINK_COMPONENTS
133 System
134 )
135
136add_llvm_unittest(System
137 System/Path.cpp
138 System/TimeValue.cpp
139 )