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 add_llvm_unittest(ExecutionEngine
87 ExecutionEngine/ExecutionEngineTest.cpp
90 if( LLVM_USE_INTEL_JITEVENTS )
91 include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
92 link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
93 set(ProfileTestSources
94 ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
96 set(LLVM_LINK_COMPONENTS
97 ${LLVM_LINK_COMPONENTS}
100 endif( LLVM_USE_INTEL_JITEVENTS )
102 if( LLVM_USE_OPROFILE )
103 set(ProfileTestSources
104 ${ProfileTestSources}
105 ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
107 set(LLVM_LINK_COMPONENTS
108 ${LLVM_LINK_COMPONENTS}
111 endif( LLVM_USE_OPROFILE )
114 ExecutionEngine/JIT/JITEventListenerTest.cpp
115 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
116 ExecutionEngine/JIT/JITTest.cpp
117 ExecutionEngine/JIT/MultiJITTest.cpp
118 ${ProfileTestSources}
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