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)
17 add_custom_target(UnitTests)
19 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
20 add_definitions(-DGTEST_HAS_RTTI=0)
21 if( CMAKE_COMPILER_IS_GNUCXX )
22 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
24 llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
27 if (NOT LLVM_ENABLE_THREADS)
28 add_definitions(-DGTEST_HAS_PTHREAD=0)
31 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
32 add_definitions("-Wno-variadic-macros")
35 set(LLVM_LINK_COMPONENTS
49 LLVMSupport # gtest needs it for raw_ostream.
56 ADT/DAGDeltaAlgorithmTest.cpp
57 ADT/DeltaAlgorithmTest.cpp
62 ADT/ImmutableSetTest.cpp
63 ADT/IntEqClassesTest.cpp
64 ADT/IntervalMapTest.cpp
65 ADT/SmallBitVectorTest.cpp
66 ADT/SmallStringTest.cpp
67 ADT/SmallVectorTest.cpp
68 ADT/SparseBitVectorTest.cpp
75 add_llvm_unittest(Analysis
76 Analysis/ScalarEvolutionTest.cpp
79 add_llvm_unittest(ExecutionEngine
80 ExecutionEngine/ExecutionEngineTest.cpp
84 ExecutionEngine/JIT/JITEventListenerTest.cpp
85 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
86 ExecutionEngine/JIT/JITTest.cpp
87 ExecutionEngine/JIT/MultiJITTest.cpp
91 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
94 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
97 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
100 add_llvm_unittest(Transforms/Utils
101 Transforms/Utils/Cloning.cpp
105 VMCore/ConstantsTest.cpp
106 VMCore/DerivedTypesTest.cpp
107 VMCore/InstructionsTest.cpp
108 VMCore/MetadataTest.cpp
109 VMCore/PassManagerTest.cpp
110 VMCore/ValueMapTest.cpp
111 VMCore/VerifierTest.cpp
114 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
115 # See issue#331418 in Visual Studio.
116 if(MSVC AND MSVC_VERSION LESS 1600)
117 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
120 add_llvm_unittest(VMCore ${VMCoreSources})
122 set(LLVM_LINK_COMPONENTS
127 add_llvm_unittest(Support
128 Support/AllocatorTest.cpp
130 Support/CommandLineTest.cpp
131 Support/ConstantRangeTest.cpp
132 Support/EndianTest.cpp
133 Support/LeakDetectorTest.cpp
134 Support/MathExtrasTest.cpp
136 Support/raw_ostream_test.cpp
137 Support/RegexTest.cpp
138 Support/SwapByteOrderTest.cpp
139 Support/TimeValue.cpp
140 Support/TypeBuilderTest.cpp
141 Support/ValueHandleTest.cpp