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/SmallBitVectorTest.cpp
77 ADT/SmallStringTest.cpp
78 ADT/SmallVectorTest.cpp
79 ADT/SparseBitVectorTest.cpp
85 ADT/VariadicFunctionTest.cpp
88 add_llvm_unittest(Analysis
89 Analysis/ScalarEvolutionTest.cpp
92 add_llvm_unittest(ExecutionEngine
93 ExecutionEngine/ExecutionEngineTest.cpp
96 if( LLVM_USE_INTEL_JITEVENTS )
97 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
98 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
99 set(ProfileTestSources
100 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
102 set(LLVM_LINK_COMPONENTS
103 ${LLVM_LINK_COMPONENTS}
106 endif( LLVM_USE_INTEL_JITEVENTS )
108 if( LLVM_USE_OPROFILE )
109 set(ProfileTestSources
110 ${ProfileTestSources}
111 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
113 set(LLVM_LINK_COMPONENTS
114 ${LLVM_LINK_COMPONENTS}
117 endif( LLVM_USE_OPROFILE )
120 ExecutionEngine/JIT/JITEventListenerTest.cpp
121 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
122 ExecutionEngine/JIT/JITTest.cpp
123 ExecutionEngine/JIT/MultiJITTest.cpp
124 ${ProfileTestSources}
128 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
131 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
134 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
137 add_llvm_unittest(Transforms/Utils
138 Transforms/Utils/Cloning.cpp
142 VMCore/ConstantsTest.cpp
143 VMCore/InstructionsTest.cpp
144 VMCore/MetadataTest.cpp
145 VMCore/PassManagerTest.cpp
146 VMCore/ValueMapTest.cpp
147 VMCore/VerifierTest.cpp
148 VMCore/DominatorTreeTest.cpp
151 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
152 # See issue#331418 in Visual Studio.
153 if(MSVC AND MSVC_VERSION LESS 1600)
154 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
157 add_llvm_unittest(VMCore ${VMCoreSources})
159 add_llvm_unittest(Bitcode
160 Bitcode/BitReaderTest.cpp
163 set(LLVM_LINK_COMPONENTS
168 add_llvm_unittest(Support
169 Support/AlignOfTest.cpp
170 Support/AllocatorTest.cpp
172 Support/CommandLineTest.cpp
173 Support/ConstantRangeTest.cpp
174 Support/EndianTest.cpp
175 Support/LeakDetectorTest.cpp
176 Support/MathExtrasTest.cpp
178 Support/raw_ostream_test.cpp
179 Support/RegexTest.cpp
180 Support/SwapByteOrderTest.cpp
181 Support/TimeValue.cpp
182 Support/TypeBuilderTest.cpp
183 Support/ValueHandleTest.cpp
184 Support/YAMLParserTest.cpp