1 function(add_llvm_unittest test_dirname)
2 string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
4 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
5 ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
7 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
8 ${LLVM_BINARY_DIR}/unittests/${test_dirname})
10 if( NOT LLVM_BUILD_TESTS )
11 set(EXCLUDE_FROM_ALL ON)
14 add_llvm_executable(${test_name} ${ARGN})
15 target_link_libraries(${test_name}
18 LLVMSupport # gtest needs it for raw_ostream.
21 add_dependencies(UnitTests ${test_name})
22 set_target_properties(${test_name} PROPERTIES FOLDER "Tests")
25 # Visual Studio 2012 only supports up to 8 template parameters in
26 # std::tr1::tuple by default, but gtest requires 10
27 if(MSVC AND MSVC_VERSION EQUAL 1700)
28 add_definitions(-D_VARIADIC_MAX=10)
31 add_custom_target(UnitTests)
32 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
34 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
35 add_definitions(-DGTEST_HAS_RTTI=0)
36 if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
37 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
39 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
42 if (NOT LLVM_ENABLE_THREADS)
43 add_definitions(-DGTEST_HAS_PTHREAD=0)
46 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
47 add_definitions("-Wno-variadic-macros")
50 set(LLVM_LINK_COMPONENTS
61 add_llvm_unittest(ADTTests
65 ADT/DAGDeltaAlgorithmTest.cpp
66 ADT/DeltaAlgorithmTest.cpp
72 ADT/ImmutableSetTest.cpp
73 ADT/IntEqClassesTest.cpp
74 ADT/IntervalMapTest.cpp
75 ADT/IntrusiveRefCntPtrTest.cpp
76 ADT/PackedVectorTest.cpp
77 ADT/SCCIteratorTest.cpp
78 ADT/SmallPtrSetTest.cpp
79 ADT/SmallStringTest.cpp
80 ADT/SmallVectorTest.cpp
81 ADT/SparseBitVectorTest.cpp
87 ADT/VariadicFunctionTest.cpp
90 add_llvm_unittest(AnalysisTests
91 Analysis/ScalarEvolutionTest.cpp
94 add_llvm_unittest(ExecutionEngineTests
95 ExecutionEngine/ExecutionEngineTest.cpp
98 if( LLVM_USE_INTEL_JITEVENTS )
99 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
100 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
101 set(ProfileTestSources
102 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
104 set(LLVM_LINK_COMPONENTS
105 ${LLVM_LINK_COMPONENTS}
108 endif( LLVM_USE_INTEL_JITEVENTS )
110 if( LLVM_USE_OPROFILE )
111 set(ProfileTestSources
112 ${ProfileTestSources}
113 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
115 set(LLVM_LINK_COMPONENTS
116 ${LLVM_LINK_COMPONENTS}
119 endif( LLVM_USE_OPROFILE )
122 ExecutionEngine/JIT/JITEventListenerTest.cpp
123 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
124 ExecutionEngine/JIT/JITTest.cpp
125 ExecutionEngine/JIT/MultiJITTest.cpp
126 ${ProfileTestSources}
130 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
133 add_llvm_unittest(ExecutionEngine/JITTests
138 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
141 add_llvm_unittest(Transforms/UtilsTests
142 Transforms/Utils/Cloning.cpp
146 VMCore/ConstantsTest.cpp
147 VMCore/DominatorTreeTest.cpp
148 VMCore/InstructionsTest.cpp
149 VMCore/MetadataTest.cpp
150 VMCore/PassManagerTest.cpp
151 VMCore/ValueMapTest.cpp
152 VMCore/VerifierTest.cpp
155 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
156 # See issue#331418 in Visual Studio.
157 if(MSVC AND MSVC_VERSION LESS 1600)
158 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
161 add_llvm_unittest(VMCoreTests
165 add_llvm_unittest(BitcodeTests
166 Bitcode/BitReaderTest.cpp
169 set(LLVM_LINK_COMPONENTS
174 add_llvm_unittest(SupportTests
175 Support/AlignOfTest.cpp
176 Support/AllocatorTest.cpp
177 Support/BlockFrequencyTest.cpp
179 Support/CommandLineTest.cpp
180 Support/ConstantRangeTest.cpp
181 Support/DataExtractorTest.cpp
182 Support/EndianTest.cpp
183 Support/IntegersSubsetTest.cpp
184 Support/IRBuilderTest.cpp
185 Support/LeakDetectorTest.cpp
186 Support/ManagedStatic.cpp
187 Support/MathExtrasTest.cpp
188 Support/MDBuilderTest.cpp
190 Support/raw_ostream_test.cpp
191 Support/RegexTest.cpp
192 Support/SwapByteOrderTest.cpp
193 Support/TimeValue.cpp
194 Support/TypeBuilderTest.cpp
195 Support/ValueHandleTest.cpp
196 Support/YAMLParserTest.cpp