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
64 ADT/ImmutableSetTest.cpp
65 ADT/IntEqClassesTest.cpp
66 ADT/IntervalMapTest.cpp
67 ADT/IntrusiveRefCntPtrTest.cpp
68 ADT/PackedVectorTest.cpp
69 ADT/SmallBitVectorTest.cpp
70 ADT/SmallStringTest.cpp
71 ADT/SmallVectorTest.cpp
72 ADT/SparseBitVectorTest.cpp
77 ADT/VariadicFunctionTest.cpp
80 add_llvm_unittest(Analysis
81 Analysis/ScalarEvolutionTest.cpp
84 add_llvm_unittest(ExecutionEngine
85 ExecutionEngine/ExecutionEngineTest.cpp
89 ExecutionEngine/JIT/JITEventListenerTest.cpp
90 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
91 ExecutionEngine/JIT/JITTest.cpp
92 ExecutionEngine/JIT/MultiJITTest.cpp
96 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
99 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
102 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
105 add_llvm_unittest(Transforms/Utils
106 Transforms/Utils/Cloning.cpp
110 VMCore/ConstantsTest.cpp
111 VMCore/InstructionsTest.cpp
112 VMCore/MetadataTest.cpp
113 VMCore/PassManagerTest.cpp
114 VMCore/ValueMapTest.cpp
115 VMCore/VerifierTest.cpp
118 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
119 # See issue#331418 in Visual Studio.
120 if(MSVC AND MSVC_VERSION LESS 1600)
121 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
124 add_llvm_unittest(VMCore ${VMCoreSources})
126 add_llvm_unittest(Bitcode
127 Bitcode/BitReaderTest.cpp
130 set(LLVM_LINK_COMPONENTS
135 add_llvm_unittest(Support
136 Support/AllocatorTest.cpp
138 Support/CommandLineTest.cpp
139 Support/ConstantRangeTest.cpp
140 Support/EndianTest.cpp
141 Support/JSONParserTest.cpp
142 Support/LeakDetectorTest.cpp
143 Support/MathExtrasTest.cpp
145 Support/raw_ostream_test.cpp
146 Support/RegexTest.cpp
147 Support/SwapByteOrderTest.cpp
148 Support/TimeValue.cpp
149 Support/TypeBuilderTest.cpp
150 Support/ValueHandleTest.cpp