blob: 61ea1ee55af4dadcb1796e27c14ab343370e8f2a [file] [log] [blame]
NAKAMURA Takumi7291ebc2010-12-07 07:41:23 +00001function(add_llvm_unittest test_dirname)
2 string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
Michael J. Spencer10d274d2010-09-24 09:01:13 +00003 if (CMAKE_BUILD_TYPE)
4 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
NAKAMURA Takumi7291ebc2010-12-07 07:41:23 +00005 ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
Michael J. Spencer10d274d2010-09-24 09:01:13 +00006 else()
7 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
NAKAMURA Takumi7291ebc2010-12-07 07:41:23 +00008 ${LLVM_BINARY_DIR}/unittests/${test_dirname})
Michael J. Spencer10d274d2010-09-24 09:01:13 +00009 endif()
10 if( NOT LLVM_BUILD_TESTS )
11 set(EXCLUDE_FROM_ALL ON)
12 endif()
Oscar Fuentes46d8a932010-09-25 20:25:25 +000013 add_llvm_executable(${test_name}Tests ${ARGN})
Oscar Fuentesb1f93802010-10-28 14:38:35 +000014 add_dependencies(UnitTests ${test_name}Tests)
Michael J. Spencer10d274d2010-09-24 09:01:13 +000015endfunction()
16
Oscar Fuentesb1f93802010-10-28 14:38:35 +000017add_custom_target(UnitTests)
18
Michael J. Spencer10d274d2010-09-24 09:01:13 +000019include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
Michael J. Spencer58efb6d2010-10-19 18:04:19 +000020add_definitions(-DGTEST_HAS_RTTI=0)
Michael J. Spencer98847782010-11-24 19:20:05 +000021if (NOT LLVM_ENABLE_THREADS)
22 add_definitions(-DGTEST_HAS_PTHREAD=0)
23endif()
Michael J. Spencer10d274d2010-09-24 09:01:13 +000024
Frits van Bommel716f34c2010-12-07 10:22:07 +000025if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
26 add_definitions("-Wno-variadic-macros")
27endif()
28
Michael J. Spencer10d274d2010-09-24 09:01:13 +000029set(LLVM_LINK_COMPONENTS
30 jit
31 interpreter
32 nativecodegen
33 BitWriter
34 BitReader
35 AsmParser
36 Core
Michael J. Spencer10d274d2010-09-24 09:01:13 +000037 Support
38 )
39
40set(LLVM_USED_LIBS
41 gtest
42 gtest_main
Michael J. Spencer98847782010-11-24 19:20:05 +000043 LLVMSupport # gtest needs it for raw_ostream.
Michael J. Spencer10d274d2010-09-24 09:01:13 +000044 )
45
46add_llvm_unittest(ADT
47 ADT/APFloatTest.cpp
48 ADT/APIntTest.cpp
49 ADT/BitVectorTest.cpp
50 ADT/DAGDeltaAlgorithmTest.cpp
51 ADT/DeltaAlgorithmTest.cpp
52 ADT/DenseMapTest.cpp
53 ADT/DenseSetTest.cpp
Dale Johannesen87a98b52010-11-19 23:23:22 +000054 ADT/FoldingSet.cpp
Michael J. Spencer10d274d2010-09-24 09:01:13 +000055 ADT/ilistTest.cpp
56 ADT/ImmutableSetTest.cpp
Jakob Stoklund Olesenbaee6552010-12-21 00:04:46 +000057 ADT/IntEqClassesTest.cpp
Jakob Stoklund Olesen345945e2010-11-19 04:47:19 +000058 ADT/IntervalMapTest.cpp
Michael J. Spencer10d274d2010-09-24 09:01:13 +000059 ADT/SmallBitVectorTest.cpp
60 ADT/SmallStringTest.cpp
61 ADT/SmallVectorTest.cpp
62 ADT/SparseBitVectorTest.cpp
63 ADT/StringMapTest.cpp
64 ADT/StringRefTest.cpp
65 ADT/TripleTest.cpp
66 ADT/TwineTest.cpp
Douglas Gregorcc277152010-09-27 16:40:43 +000067 )
Michael J. Spencer10d274d2010-09-24 09:01:13 +000068
69add_llvm_unittest(Analysis
70 Analysis/ScalarEvolutionTest.cpp
71 )
72
73add_llvm_unittest(ExecutionEngine
74 ExecutionEngine/ExecutionEngineTest.cpp
75 )
76
NAKAMURA Takumi1818edb2010-11-19 03:19:42 +000077set(JITTestsSources
Michael J. Spencer10d274d2010-09-24 09:01:13 +000078 ExecutionEngine/JIT/JITEventListenerTest.cpp
79 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
80 ExecutionEngine/JIT/JITTest.cpp
81 ExecutionEngine/JIT/MultiJITTest.cpp
82 )
83
NAKAMURA Takumi1818edb2010-11-19 03:19:42 +000084if(MSVC)
85 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
86endif()
87
NAKAMURA Takumi7291ebc2010-12-07 07:41:23 +000088add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
NAKAMURA Takumi1818edb2010-11-19 03:19:42 +000089
NAKAMURA Takumi98fa0152010-11-26 09:32:02 +000090if(MINGW)
91 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
92endif()
93
NAKAMURA Takumi7291ebc2010-12-07 07:41:23 +000094add_llvm_unittest(Transforms/Utils
Michael J. Spencer88278892010-10-11 21:22:34 +000095 Transforms/Utils/Cloning.cpp
96 )
97
NAKAMURA Takumi7a953ba2010-11-19 03:19:32 +000098set(VMCoreSources
Michael J. Spencer88278892010-10-11 21:22:34 +000099 VMCore/ConstantsTest.cpp
100 VMCore/DerivedTypesTest.cpp
101 VMCore/InstructionsTest.cpp
102 VMCore/MetadataTest.cpp
103 VMCore/PassManagerTest.cpp
NAKAMURA Takumidddfdc82010-11-14 12:37:51 +0000104 VMCore/ValueMapTest.cpp
Michael J. Spencer88278892010-10-11 21:22:34 +0000105 VMCore/VerifierTest.cpp
106 )
107
NAKAMURA Takumi7a953ba2010-11-19 03:19:32 +0000108# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
109# See issue#331418 in Visual Studio.
110if(MSVC AND MSVC_VERSION LESS 1600)
111 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
112endif()
113
114add_llvm_unittest(VMCore ${VMCoreSources})
115
Michael J. Spencer88278892010-10-11 21:22:34 +0000116set(LLVM_LINK_COMPONENTS
Michael J. Spencer88278892010-10-11 21:22:34 +0000117 Support
118 Core
119 )
120
Michael J. Spencer10d274d2010-09-24 09:01:13 +0000121add_llvm_unittest(Support
122 Support/AllocatorTest.cpp
123 Support/Casting.cpp
124 Support/CommandLineTest.cpp
125 Support/ConstantRangeTest.cpp
Michael J. Spencerb550b662010-10-21 20:28:21 +0000126 Support/EndianTest.cpp
Michael J. Spencer10d274d2010-09-24 09:01:13 +0000127 Support/LeakDetectorTest.cpp
128 Support/MathExtrasTest.cpp
Michael J. Spencer3ef91c52010-11-29 22:29:04 +0000129 Support/Path.cpp
Michael J. Spencer10d274d2010-09-24 09:01:13 +0000130 Support/raw_ostream_test.cpp
131 Support/RegexTest.cpp
Michael J. Spencerded95b72010-10-11 21:56:16 +0000132 Support/SwapByteOrderTest.cpp
Michael J. Spencer3ef91c52010-11-29 22:29:04 +0000133 Support/TimeValue.cpp
Michael J. Spencer10d274d2010-09-24 09:01:13 +0000134 Support/TypeBuilderTest.cpp
135 Support/ValueHandleTest.cpp
136 )