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/SmallStringTest.cpp
77 ADT/SmallVectorTest.cpp
78 ADT/SparseBitVectorTest.cpp
84 ADT/VariadicFunctionTest.cpp
87 add_llvm_unittest(Analysis
88 Analysis/ScalarEvolutionTest.cpp
91 add_llvm_unittest(ExecutionEngine
92 ExecutionEngine/ExecutionEngineTest.cpp
95 if( LLVM_USE_INTEL_JITEVENTS )
96 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
97 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
98 set(ProfileTestSources
99 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
101 set(LLVM_LINK_COMPONENTS
102 ${LLVM_LINK_COMPONENTS}
105 endif( LLVM_USE_INTEL_JITEVENTS )
107 if( LLVM_USE_OPROFILE )
108 set(ProfileTestSources
109 ${ProfileTestSources}
110 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
112 set(LLVM_LINK_COMPONENTS
113 ${LLVM_LINK_COMPONENTS}
116 endif( LLVM_USE_OPROFILE )
119 ExecutionEngine/JIT/JITEventListenerTest.cpp
120 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
121 ExecutionEngine/JIT/JITTest.cpp
122 ExecutionEngine/JIT/MultiJITTest.cpp
123 ${ProfileTestSources}
127 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
130 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
133 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
136 add_llvm_unittest(Transforms/Utils
137 Transforms/Utils/Cloning.cpp
141 VMCore/ConstantsTest.cpp
142 VMCore/InstructionsTest.cpp
143 VMCore/MetadataTest.cpp
144 VMCore/PassManagerTest.cpp
145 VMCore/ValueMapTest.cpp
146 VMCore/VerifierTest.cpp
147 VMCore/DominatorTreeTest.cpp
150 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
151 # See issue#331418 in Visual Studio.
152 if(MSVC AND MSVC_VERSION LESS 1600)
153 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
156 add_llvm_unittest(VMCore ${VMCoreSources})
158 add_llvm_unittest(Bitcode
159 Bitcode/BitReaderTest.cpp
162 set(LLVM_LINK_COMPONENTS
167 add_llvm_unittest(Support
168 Support/AlignOfTest.cpp
169 Support/AllocatorTest.cpp
171 Support/CommandLineTest.cpp
172 Support/ConstantRangeTest.cpp
173 Support/EndianTest.cpp
174 Support/LeakDetectorTest.cpp
175 Support/MathExtrasTest.cpp
177 Support/raw_ostream_test.cpp
178 Support/RegexTest.cpp
179 Support/SwapByteOrderTest.cpp
180 Support/TimeValue.cpp
181 Support/TypeBuilderTest.cpp
182 Support/ValueHandleTest.cpp
183 Support/YAMLParserTest.cpp