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( CMAKE_COMPILER_IS_GNUCXX )
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/SmallBitVectorTest.cpp
68 ADT/SmallStringTest.cpp
69 ADT/SmallVectorTest.cpp
70 ADT/SparseBitVectorTest.cpp
77 add_llvm_unittest(Analysis
78 Analysis/ScalarEvolutionTest.cpp
81 add_llvm_unittest(ExecutionEngine
82 ExecutionEngine/ExecutionEngineTest.cpp
86 ExecutionEngine/JIT/JITEventListenerTest.cpp
87 ExecutionEngine/JIT/JITMemoryManagerTest.cpp
88 ExecutionEngine/JIT/JITTest.cpp
89 ExecutionEngine/JIT/MultiJITTest.cpp
93 list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
96 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
99 set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
102 add_llvm_unittest(Transforms/Utils
103 Transforms/Utils/Cloning.cpp
107 VMCore/ConstantsTest.cpp
108 VMCore/DerivedTypesTest.cpp
109 VMCore/InstructionsTest.cpp
110 VMCore/MetadataTest.cpp
111 VMCore/PassManagerTest.cpp
112 VMCore/ValueMapTest.cpp
113 VMCore/VerifierTest.cpp
116 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
117 # See issue#331418 in Visual Studio.
118 if(MSVC AND MSVC_VERSION LESS 1600)
119 list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
122 add_llvm_unittest(VMCore ${VMCoreSources})
124 set(LLVM_LINK_COMPONENTS
129 add_llvm_unittest(Support
130 Support/AllocatorTest.cpp
132 Support/CommandLineTest.cpp
133 Support/ConstantRangeTest.cpp
134 Support/EndianTest.cpp
135 Support/LeakDetectorTest.cpp
136 Support/MathExtrasTest.cpp
138 Support/raw_ostream_test.cpp
139 Support/RegexTest.cpp
140 Support/SwapByteOrderTest.cpp
141 Support/TimeValue.cpp
142 Support/TypeBuilderTest.cpp
143 Support/ValueHandleTest.cpp