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 add_custom_target(UnitTests)
19 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
21 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
22 add_definitions(-DGTEST_HAS_RTTI=0)
23 if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
24 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
26 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
29 if (NOT LLVM_ENABLE_THREADS)
30 add_definitions(-DGTEST_HAS_PTHREAD=0)
33 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
34 add_definitions("-Wno-variadic-macros")
37 set(LLVM_LINK_COMPONENTS
51 LLVMSupport # gtest needs it for raw_ostream.
58 ADT/DAGDeltaAlgorithmTest.cpp
59 ADT/DeltaAlgorithmTest.cpp
65 ADT/ImmutableSetTest.cpp
66 ADT/IntEqClassesTest.cpp
67 ADT/IntervalMapTest.cpp
68 ADT/IntrusiveRefCntPtrTest.cpp
69 ADT/PackedVectorTest.cpp
70 ADT/SmallBitVectorTest.cpp
71 ADT/SmallStringTest.cpp
72 ADT/SmallVectorTest.cpp
73 ADT/SparseBitVectorTest.cpp
79 ADT/VariadicFunctionTest.cpp
82 add_llvm_unittest(Analysis
83 Analysis/ScalarEvolutionTest.cpp
86 if( LLVM_USE_INTEL_JITEVENTS )
87 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
88 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
89 set(ProfileTestSources
90 ExecutionEngine/IntelJITEventListenerTest.cpp
92 set(LLVM_LINK_COMPONENTS
93 ${LLVM_LINK_COMPONENTS}
96 endif( LLVM_USE_INTEL_JITEVENTS )
98 if( LLVM_USE_OPROFILE )
99 set(ProfileTestSources
100 ${ProfileTestSources}
101 ExecutionEngine/OProfileJITEventListenerTest.cpp
103 set(LLVM_LINK_COMPONENTS
104 ${LLVM_LINK_COMPONENTS}
107 endif( LLVM_USE_OPROFILE )
109 add_llvm_unittest(ExecutionEngine
110 ExecutionEngine/ExecutionEngineTest.cpp
111 ExecutionEngine/JITEventListenerTest.cpp
112 ${ProfileTestSources}
116 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
117 ExecutionEngine/JIT/JITTest.cpp
118 ExecutionEngine/JIT/MultiJITTest.cpp
122 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
125 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
128 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
131 add_llvm_unittest(Transforms/Utils
132 Transforms/Utils/Cloning.cpp
136 VMCore/ConstantsTest.cpp
137 VMCore/InstructionsTest.cpp
138 VMCore/MetadataTest.cpp
139 VMCore/PassManagerTest.cpp
140 VMCore/ValueMapTest.cpp
141 VMCore/VerifierTest.cpp
144 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
145 # See issue#331418 in Visual Studio.
146 if(MSVC AND MSVC_VERSION LESS 1600)
147 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
150 add_llvm_unittest(VMCore ${VMCoreSources})
152 add_llvm_unittest(Bitcode
153 Bitcode/BitReaderTest.cpp
156 set(LLVM_LINK_COMPONENTS
161 add_llvm_unittest(Support
162 Support/AllocatorTest.cpp
164 Support/CommandLineTest.cpp
165 Support/ConstantRangeTest.cpp
166 Support/EndianTest.cpp
167 Support/JSONParserTest.cpp
168 Support/LeakDetectorTest.cpp
169 Support/MathExtrasTest.cpp
171 Support/raw_ostream_test.cpp
172 Support/RegexTest.cpp
173 Support/SwapByteOrderTest.cpp
174 Support/TimeValue.cpp
175 Support/TypeBuilderTest.cpp
176 Support/ValueHandleTest.cpp