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)
13 add_llvm_executable(${test_name}Tests ${ARGN})
14 add_dependencies(UnitTests ${test_name}Tests)
15 set_target_properties(${test_name}Tests PROPERTIES FOLDER "Tests")
18 # Visual Studio 2012 only supports up to 8 template parameters in
19 # std::tr1::tuple by default, but gtest requires 10
20 if(MSVC AND MSVC_VERSION EQUAL 1700)
21 add_definitions(-D_VARIADIC_MAX=10)
24 add_custom_target(UnitTests)
25 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
27 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
28 add_definitions(-DGTEST_HAS_RTTI=0)
29 if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
30 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
32 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
35 if (NOT LLVM_ENABLE_THREADS)
36 add_definitions(-DGTEST_HAS_PTHREAD=0)
39 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
40 add_definitions("-Wno-variadic-macros")
43 set(LLVM_LINK_COMPONENTS
57 LLVMSupport # gtest needs it for raw_ostream.
64 ADT/DAGDeltaAlgorithmTest.cpp
65 ADT/DeltaAlgorithmTest.cpp
71 ADT/ImmutableSetTest.cpp
72 ADT/IntEqClassesTest.cpp
73 ADT/IntervalMapTest.cpp
74 ADT/IntrusiveRefCntPtrTest.cpp
75 ADT/PackedVectorTest.cpp
76 ADT/SCCIteratorTest.cpp
77 ADT/SmallPtrSetTest.cpp
78 ADT/SmallStringTest.cpp
79 ADT/SmallVectorTest.cpp
80 ADT/SparseBitVectorTest.cpp
86 ADT/VariadicFunctionTest.cpp
89 add_llvm_unittest(Analysis
90 Analysis/ScalarEvolutionTest.cpp
93 add_llvm_unittest(ExecutionEngine
94 ExecutionEngine/ExecutionEngineTest.cpp
97 if( LLVM_USE_INTEL_JITEVENTS )
98 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
99 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
100 set(ProfileTestSources
101 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
103 set(LLVM_LINK_COMPONENTS
104 ${LLVM_LINK_COMPONENTS}
107 endif( LLVM_USE_INTEL_JITEVENTS )
109 if( LLVM_USE_OPROFILE )
110 set(ProfileTestSources
111 ${ProfileTestSources}
112 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
114 set(LLVM_LINK_COMPONENTS
115 ${LLVM_LINK_COMPONENTS}
118 endif( LLVM_USE_OPROFILE )
121 ExecutionEngine/JIT/JITEventListenerTest.cpp
122 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
123 ExecutionEngine/JIT/JITTest.cpp
124 ExecutionEngine/JIT/MultiJITTest.cpp
125 ${ProfileTestSources}
129 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
132 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
135 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
138 add_llvm_unittest(Transforms/Utils
139 Transforms/Utils/Cloning.cpp
143 VMCore/ConstantsTest.cpp
144 VMCore/DominatorTreeTest.cpp
145 VMCore/InstructionsTest.cpp
146 VMCore/MetadataTest.cpp
147 VMCore/PassManagerTest.cpp
148 VMCore/ValueMapTest.cpp
149 VMCore/VerifierTest.cpp
152 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
153 # See issue#331418 in Visual Studio.
154 if(MSVC AND MSVC_VERSION LESS 1600)
155 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
158 add_llvm_unittest(VMCore ${VMCoreSources})
160 add_llvm_unittest(Bitcode
161 Bitcode/BitReaderTest.cpp
164 set(LLVM_LINK_COMPONENTS
169 add_llvm_unittest(Support
170 Support/AlignOfTest.cpp
171 Support/AllocatorTest.cpp
172 Support/BlockFrequencyTest.cpp
174 Support/CommandLineTest.cpp
175 Support/ConstantRangeTest.cpp
176 Support/DataExtractorTest.cpp
177 Support/EndianTest.cpp
178 Support/IntegersSubsetTest.cpp
179 Support/IRBuilderTest.cpp
180 Support/LeakDetectorTest.cpp
181 Support/ManagedStatic.cpp
182 Support/MathExtrasTest.cpp
183 Support/MDBuilderTest.cpp
185 Support/raw_ostream_test.cpp
186 Support/RegexTest.cpp
187 Support/SwapByteOrderTest.cpp
188 Support/TimeValue.cpp
189 Support/TypeBuilderTest.cpp
190 Support/ValueHandleTest.cpp
191 Support/YAMLParserTest.cpp