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}Tests ${ARGN})
15 target_link_libraries(${test_name}Tests
18 LLVMSupport # gtest needs it for raw_ostream.
21 add_dependencies(UnitTests ${test_name}Tests)
22 set_target_properties(${test_name}Tests 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
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(Analysis
91 Analysis/ScalarEvolutionTest.cpp
94 add_llvm_unittest(ExecutionEngine
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/JIT ${JITTestsSources})
136 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
139 add_llvm_unittest(Transforms/Utils
140 Transforms/Utils/Cloning.cpp
144 VMCore/ConstantsTest.cpp
145 VMCore/DominatorTreeTest.cpp
146 VMCore/InstructionsTest.cpp
147 VMCore/MetadataTest.cpp
148 VMCore/PassManagerTest.cpp
149 VMCore/ValueMapTest.cpp
150 VMCore/VerifierTest.cpp
153 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
154 # See issue#331418 in Visual Studio.
155 if(MSVC AND MSVC_VERSION LESS 1600)
156 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
159 add_llvm_unittest(VMCore ${VMCoreSources})
161 add_llvm_unittest(Bitcode
162 Bitcode/BitReaderTest.cpp
165 set(LLVM_LINK_COMPONENTS
170 add_llvm_unittest(Support
171 Support/AlignOfTest.cpp
172 Support/AllocatorTest.cpp
173 Support/BlockFrequencyTest.cpp
175 Support/CommandLineTest.cpp
176 Support/ConstantRangeTest.cpp
177 Support/DataExtractorTest.cpp
178 Support/EndianTest.cpp
179 Support/IntegersSubsetTest.cpp
180 Support/IRBuilderTest.cpp
181 Support/LeakDetectorTest.cpp
182 Support/ManagedStatic.cpp
183 Support/MathExtrasTest.cpp
184 Support/MDBuilderTest.cpp
186 Support/raw_ostream_test.cpp
187 Support/RegexTest.cpp
188 Support/SwapByteOrderTest.cpp
189 Support/TimeValue.cpp
190 Support/TypeBuilderTest.cpp
191 Support/ValueHandleTest.cpp
192 Support/YAMLParserTest.cpp