blob: c64ab3ce08277e990ac18fd9e8488f770aadc6db [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
Michael J. Spenceree6944f2010-09-24 09:01:13 +000032 Support
33 )
34
35set(LLVM_USED_LIBS
36 gtest
37 gtest_main
Michael J. Spencerf2ca4cb2010-11-24 19:20:05 +000038 LLVMSupport # gtest needs it for raw_ostream.
Michael J. Spenceree6944f2010-09-24 09:01:13 +000039 )
40
41add_llvm_unittest(ADT
42 ADT/APFloatTest.cpp
43 ADT/APIntTest.cpp
44 ADT/BitVectorTest.cpp
45 ADT/DAGDeltaAlgorithmTest.cpp
46 ADT/DeltaAlgorithmTest.cpp
47 ADT/DenseMapTest.cpp
48 ADT/DenseSetTest.cpp
Dale Johannesena197cba2010-11-19 23:23:22 +000049 ADT/FoldingSet.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000050 ADT/ilistTest.cpp
51 ADT/ImmutableSetTest.cpp
Jakob Stoklund Olesen8dc92672010-11-19 04:47:19 +000052 ADT/IntervalMapTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +000053 ADT/SmallBitVectorTest.cpp
54 ADT/SmallStringTest.cpp
55 ADT/SmallVectorTest.cpp
56 ADT/SparseBitVectorTest.cpp
57 ADT/StringMapTest.cpp
58 ADT/StringRefTest.cpp
59 ADT/TripleTest.cpp
60 ADT/TwineTest.cpp
Douglas Gregorc576d3d2010-09-27 16:40:43 +000061 )
Michael J. Spenceree6944f2010-09-24 09:01:13 +000062
63add_llvm_unittest(Analysis
64 Analysis/ScalarEvolutionTest.cpp
65 )
66
67add_llvm_unittest(ExecutionEngine
68 ExecutionEngine/ExecutionEngineTest.cpp
69 )
70
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000071set(JITTestsSources
Michael J. Spenceree6944f2010-09-24 09:01:13 +000072 ExecutionEngine/JIT/JITEventListenerTest.cpp
73 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
74 ExecutionEngine/JIT/JITTest.cpp
75 ExecutionEngine/JIT/MultiJITTest.cpp
76 )
77
NAKAMURA Takumi0f60ddc2010-11-19 03:19:42 +000078if(MSVC)
79 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
80endif()
81
82add_llvm_unittest(JIT ${JITTestsSources})
83
NAKAMURA Takumib9dec1f2010-11-26 09:32:02 +000084if(MINGW)
85 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
86endif()
87
Michael J. Spencer12647eb2010-10-11 21:22:34 +000088add_llvm_unittest(Transforms
89 Transforms/Utils/Cloning.cpp
90 )
91
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +000092set(VMCoreSources
Michael J. Spencer12647eb2010-10-11 21:22:34 +000093 VMCore/ConstantsTest.cpp
94 VMCore/DerivedTypesTest.cpp
95 VMCore/InstructionsTest.cpp
96 VMCore/MetadataTest.cpp
97 VMCore/PassManagerTest.cpp
NAKAMURA Takumib08ca272010-11-14 12:37:51 +000098 VMCore/ValueMapTest.cpp
Michael J. Spencer12647eb2010-10-11 21:22:34 +000099 VMCore/VerifierTest.cpp
100 )
101
NAKAMURA Takumi130a2dd2010-11-19 03:19:32 +0000102# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
103# See issue#331418 in Visual Studio.
104if(MSVC AND MSVC_VERSION LESS 1600)
105 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
106endif()
107
108add_llvm_unittest(VMCore ${VMCoreSources})
109
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000110set(LLVM_LINK_COMPONENTS
Michael J. Spencer12647eb2010-10-11 21:22:34 +0000111 Support
112 Core
113 )
114
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000115add_llvm_unittest(Support
116 Support/AllocatorTest.cpp
117 Support/Casting.cpp
118 Support/CommandLineTest.cpp
119 Support/ConstantRangeTest.cpp
Michael J. Spencer5e0b2bf2010-10-21 20:28:21 +0000120 Support/EndianTest.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000121 Support/LeakDetectorTest.cpp
122 Support/MathExtrasTest.cpp
Michael J. Spencer013d15a2010-11-29 22:29:04 +0000123 Support/Path.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000124 Support/raw_ostream_test.cpp
125 Support/RegexTest.cpp
Michael J. Spencer4c099b82010-10-11 21:56:16 +0000126 Support/SwapByteOrderTest.cpp
Michael J. Spencer013d15a2010-11-29 22:29:04 +0000127 Support/TimeValue.cpp
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000128 Support/TypeBuilderTest.cpp
129 Support/ValueHandleTest.cpp
130 )