blob: 6baf80c39bfb584002006a2c97bed9e048af52f7 [file] [log] [blame]
NAKAMURA Takumib3d37e32010-12-07 07:41:23 +00001function(add_llvm_unittest test_dirname)
2 string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
Michael J. Spenceree6944f2010-09-24 09:01:13 +00003 if (CMAKE_BUILD_TYPE)
4 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
NAKAMURA Takumib3d37e32010-12-07 07:41:23 +00005 ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
Michael J. Spenceree6944f2010-09-24 09:01:13 +00006 else()
7 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
NAKAMURA Takumib3d37e32010-12-07 07:41:23 +00008 ${LLVM_BINARY_DIR}/unittests/${test_dirname})
Michael J. Spenceree6944f2010-09-24 09:01:13 +00009 endif()
10 if( NOT LLVM_BUILD_TESTS )
11 set(EXCLUDE_FROM_ALL ON)
12 endif()
Chandler Carruth45df6f92012-06-21 01:35:09 +000013
Chandler Carruthb1081af2012-06-21 02:02:48 +000014 add_llvm_executable(${test_name} ${ARGN})
15 target_link_libraries(${test_name}
Chandler Carruth45df6f92012-06-21 01:35:09 +000016 gtest
17 gtest_main
18 LLVMSupport # gtest needs it for raw_ostream.
19 )
20
Chandler Carruthb1081af2012-06-21 02:02:48 +000021 add_dependencies(UnitTests ${test_name})
22 set_target_properties(${test_name} PROPERTIES FOLDER "Tests")
Michael J. Spenceree6944f2010-09-24 09:01:13 +000023endfunction()
24
Justin Holewinskic82fd372012-06-06 03:11:20 +000025# Visual Studio 2012 only supports up to 8 template parameters in
26# std::tr1::tuple by default, but gtest requires 10
27if(MSVC AND MSVC_VERSION EQUAL 1700)
28 add_definitions(-D_VARIADIC_MAX=10)
29endif ()
30
Oscar Fuentesda975632010-10-28 14:38:35 +000031add_custom_target(UnitTests)
Oscar Fuentes0b85d072011-02-20 22:06:10 +000032set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
Oscar Fuentesda975632010-10-28 14:38:35 +000033
Michael J. Spenceree6944f2010-09-24 09:01:13 +000034include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
Michael J. Spencer8a806ae2010-10-19 18:04:19 +000035add_definitions(-DGTEST_HAS_RTTI=0)
Oscar Fuentes104e9922011-05-11 13:53:08 +000036if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
Oscar Fuentes3bf22792011-01-13 15:31:45 +000037 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
38elseif( MSVC )
39 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
40endif()
41
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +000042if (NOT LLVM_ENABLE_THREADS)
43 add_definitions(-DGTEST_HAS_PTHREAD=0)
44endif()
Michael J. Spenceree6944f2010-09-24 09:01:13 +000045
Frits van Bommel729b2942010-12-07 10:22:07 +000046if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
47 add_definitions("-Wno-variadic-macros")
48endif()
49
Michael J. Spenceree6944f2010-09-24 09:01:13 +000050set(LLVM_LINK_COMPONENTS
51 jit
52 interpreter
53 nativecodegen
54 BitWriter
55 BitReader
56 AsmParser
57 Core
Michael J. Spenceree6944f2010-09-24 09:01:13 +000058 Support
59 )
60
Chandler Carruthb1081af2012-06-21 02:02:48 +000061add_llvm_unittest(ADTTests
Michael J. Spenceree6944f2010-09-24 09:01:13 +000062 ADT/APFloatTest.cpp
63 ADT/APIntTest.cpp
64 ADT/BitVectorTest.cpp
65 ADT/DAGDeltaAlgorithmTest.cpp
66 ADT/DeltaAlgorithmTest.cpp
67 ADT/DenseMapTest.cpp
68 ADT/DenseSetTest.cpp
Dale Johannesena197cba2010-11-19 23:23:22 +000069 ADT/FoldingSet.cpp
Talin1a4b19e2012-02-18 21:00:49 +000070 ADT/HashingTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000071 ADT/ilistTest.cpp
72 ADT/ImmutableSetTest.cpp
Jakob Stoklund Olesen2a6899c2010-12-21 00:04:46 +000073 ADT/IntEqClassesTest.cpp
Jakob Stoklund Olesen8dc92672010-11-19 04:47:19 +000074 ADT/IntervalMapTest.cpp
Manuel Klimek41aa1082012-01-31 19:58:34 +000075 ADT/IntrusiveRefCntPtrTest.cpp
Argyrios Kyrtzidis0f5b6872011-06-15 19:19:09 +000076 ADT/PackedVectorTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +000077 ADT/SCCIteratorTest.cpp
78 ADT/SmallPtrSetTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000079 ADT/SmallStringTest.cpp
80 ADT/SmallVectorTest.cpp
81 ADT/SparseBitVectorTest.cpp
Jakob Stoklund Olesen62588622012-02-22 00:56:08 +000082 ADT/SparseSetTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000083 ADT/StringMapTest.cpp
84 ADT/StringRefTest.cpp
85 ADT/TripleTest.cpp
86 ADT/TwineTest.cpp
Chandler Carruthd916ce32011-12-16 08:58:59 +000087 ADT/VariadicFunctionTest.cpp
Douglas Gregorc576d3d2010-09-27 16:40:43 +000088 )
Michael J. Spenceree6944f2010-09-24 09:01:13 +000089
Chandler Carruthb1081af2012-06-21 02:02:48 +000090add_llvm_unittest(AnalysisTests
Michael J. Spenceree6944f2010-09-24 09:01:13 +000091 Analysis/ScalarEvolutionTest.cpp
92 )
93
Chandler Carruthb1081af2012-06-21 02:02:48 +000094add_llvm_unittest(ExecutionEngineTests
Eli Benderskyf963cd32012-03-15 06:49:31 +000095 ExecutionEngine/ExecutionEngineTest.cpp
96 )
97
Eli Bendersky61b18512012-03-13 08:33:15 +000098if( LLVM_USE_INTEL_JITEVENTS )
99 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
100 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
101 set(ProfileTestSources
Eli Benderskyf963cd32012-03-15 06:49:31 +0000102 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
Eli Bendersky61b18512012-03-13 08:33:15 +0000103 )
104 set(LLVM_LINK_COMPONENTS
105 ${LLVM_LINK_COMPONENTS}
106 IntelJITEvents
107 )
108endif( LLVM_USE_INTEL_JITEVENTS )
109
110if( LLVM_USE_OPROFILE )
111 set(ProfileTestSources
112 ${ProfileTestSources}
Eli Benderskyf963cd32012-03-15 06:49:31 +0000113 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
Eli Bendersky61b18512012-03-13 08:33:15 +0000114 )
115 set(LLVM_LINK_COMPONENTS
116 ${LLVM_LINK_COMPONENTS}
117 OProfileJIT
118 )
119endif( LLVM_USE_OPROFILE )
120
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +0000121set(JITTestsSources
Eli Benderskyf963cd32012-03-15 06:49:31 +0000122 ExecutionEngine/JIT/JITEventListenerTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000123 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
124 ExecutionEngine/JIT/JITTest.cpp
125 ExecutionEngine/JIT/MultiJITTest.cpp
Eli Benderskyf963cd32012-03-15 06:49:31 +0000126 ${ProfileTestSources}
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000127 )
128
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +0000129if(MSVC)
130 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
131endif()
132
Chandler Carruthb1081af2012-06-21 02:02:48 +0000133add_llvm_unittest(ExecutionEngine/JITTests
134 ${JITTestsSources}
135 )
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +0000136
NAKAMURA Takumide0cfe82011-12-16 06:21:08 +0000137if(MINGW OR CYGWIN)
NAKAMURA Takumib9dec1f2010-11-26 09:32:02 +0000138 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
139endif()
140
Chandler Carruthb1081af2012-06-21 02:02:48 +0000141add_llvm_unittest(Transforms/UtilsTests
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000142 Transforms/Utils/Cloning.cpp
143 )
144
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +0000145set(VMCoreSources
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000146 VMCore/ConstantsTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000147 VMCore/DominatorTreeTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000148 VMCore/InstructionsTest.cpp
149 VMCore/MetadataTest.cpp
150 VMCore/PassManagerTest.cpp
NAKAMURA Takumib08ca272010-11-14 12:37:51 +0000151 VMCore/ValueMapTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000152 VMCore/VerifierTest.cpp
153 )
154
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +0000155# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
156# See issue#331418 in Visual Studio.
157if(MSVC AND MSVC_VERSION LESS 1600)
158 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
159endif()
160
Chandler Carruthb1081af2012-06-21 02:02:48 +0000161add_llvm_unittest(VMCoreTests
162 ${VMCoreSources}
163 )
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +0000164
Chandler Carruthb1081af2012-06-21 02:02:48 +0000165add_llvm_unittest(BitcodeTests
Chandler Carruth972cc0d2012-01-02 09:19:48 +0000166 Bitcode/BitReaderTest.cpp
167 )
168
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000169set(LLVM_LINK_COMPONENTS
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000170 Support
171 Core
172 )
173
Chandler Carruthb1081af2012-06-21 02:02:48 +0000174add_llvm_unittest(SupportTests
Chandler Carruth585de7a2012-06-16 08:52:57 +0000175 Support/AlignOfTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000176 Support/AllocatorTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000177 Support/BlockFrequencyTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000178 Support/Casting.cpp
179 Support/CommandLineTest.cpp
180 Support/ConstantRangeTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000181 Support/DataExtractorTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000182 Support/EndianTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000183 Support/IntegersSubsetTest.cpp
184 Support/IRBuilderTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000185 Support/LeakDetectorTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000186 Support/ManagedStatic.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000187 Support/MathExtrasTest.cpp
Benjamin Kramer044de9c2012-06-17 14:42:49 +0000188 Support/MDBuilderTest.cpp
Michael J. Spencer013d15a2010-11-29 22:29:04 +0000189 Support/Path.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000190 Support/raw_ostream_test.cpp
191 Support/RegexTest.cpp
Michael J. Spencer4c099b82010-10-11 21:56:16 +0000192 Support/SwapByteOrderTest.cpp
Michael J. Spencer013d15a2010-11-29 22:29:04 +0000193 Support/TimeValue.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000194 Support/TypeBuilderTest.cpp
195 Support/ValueHandleTest.cpp
Michael J. Spencer93210e82012-04-03 23:09:22 +0000196 Support/YAMLParserTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000197 )