NAKAMURA Takumi | b3d37e3 | 2010-12-07 07:41:23 +0000 | [diff] [blame] | 1 | function(add_llvm_unittest test_dirname) |
| 2 | string(REGEX MATCH "([^/]+)$" test_name ${test_dirname}) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 3 | if (CMAKE_BUILD_TYPE) |
| 4 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY |
NAKAMURA Takumi | b3d37e3 | 2010-12-07 07:41:23 +0000 | [diff] [blame] | 5 | ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE}) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 6 | else() |
| 7 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY |
NAKAMURA Takumi | b3d37e3 | 2010-12-07 07:41:23 +0000 | [diff] [blame] | 8 | ${LLVM_BINARY_DIR}/unittests/${test_dirname}) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 9 | endif() |
| 10 | if( NOT LLVM_BUILD_TESTS ) |
| 11 | set(EXCLUDE_FROM_ALL ON) |
| 12 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 13 | add_llvm_executable(${test_name}Tests ${ARGN}) |
Oscar Fuentes | da97563 | 2010-10-28 14:38:35 +0000 | [diff] [blame] | 14 | add_dependencies(UnitTests ${test_name}Tests) |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 15 | set_target_properties(${test_name}Tests PROPERTIES FOLDER "Tests") |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 16 | endfunction() |
| 17 | |
Oscar Fuentes | da97563 | 2010-10-28 14:38:35 +0000 | [diff] [blame] | 18 | add_custom_target(UnitTests) |
Oscar Fuentes | 0b85d07 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 19 | set_target_properties(UnitTests PROPERTIES FOLDER "Tests") |
Oscar Fuentes | da97563 | 2010-10-28 14:38:35 +0000 | [diff] [blame] | 20 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 21 | include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) |
Michael J. Spencer | 8a806ae | 2010-10-19 18:04:19 +0000 | [diff] [blame] | 22 | add_definitions(-DGTEST_HAS_RTTI=0) |
Oscar Fuentes | 104e992 | 2011-05-11 13:53:08 +0000 | [diff] [blame] | 23 | if( LLVM_COMPILER_IS_GCC_COMPATIBLE ) |
Oscar Fuentes | 3bf2279 | 2011-01-13 15:31:45 +0000 | [diff] [blame] | 24 | llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti") |
| 25 | elseif( MSVC ) |
| 26 | llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-") |
| 27 | endif() |
| 28 | |
Michael J. Spencer | f2ca4cb | 2010-11-24 19:20:05 +0000 | [diff] [blame] | 29 | if (NOT LLVM_ENABLE_THREADS) |
| 30 | add_definitions(-DGTEST_HAS_PTHREAD=0) |
| 31 | endif() |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 32 | |
Frits van Bommel | 729b294 | 2010-12-07 10:22:07 +0000 | [diff] [blame] | 33 | if(SUPPORTS_NO_VARIADIC_MACROS_FLAG) |
| 34 | add_definitions("-Wno-variadic-macros") |
| 35 | endif() |
| 36 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 37 | set(LLVM_LINK_COMPONENTS |
| 38 | jit |
| 39 | interpreter |
| 40 | nativecodegen |
| 41 | BitWriter |
| 42 | BitReader |
| 43 | AsmParser |
| 44 | Core |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 45 | Support |
| 46 | ) |
| 47 | |
| 48 | set(LLVM_USED_LIBS |
| 49 | gtest |
| 50 | gtest_main |
Michael J. Spencer | f2ca4cb | 2010-11-24 19:20:05 +0000 | [diff] [blame] | 51 | LLVMSupport # gtest needs it for raw_ostream. |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 52 | ) |
| 53 | |
| 54 | add_llvm_unittest(ADT |
| 55 | ADT/APFloatTest.cpp |
| 56 | ADT/APIntTest.cpp |
| 57 | ADT/BitVectorTest.cpp |
| 58 | ADT/DAGDeltaAlgorithmTest.cpp |
| 59 | ADT/DeltaAlgorithmTest.cpp |
| 60 | ADT/DenseMapTest.cpp |
| 61 | ADT/DenseSetTest.cpp |
Dale Johannesen | a197cba | 2010-11-19 23:23:22 +0000 | [diff] [blame] | 62 | ADT/FoldingSet.cpp |
Talin | 1a4b19e | 2012-02-18 21:00:49 +0000 | [diff] [blame] | 63 | ADT/HashingTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 64 | ADT/ilistTest.cpp |
| 65 | ADT/ImmutableSetTest.cpp |
Jakob Stoklund Olesen | 2a6899c | 2010-12-21 00:04:46 +0000 | [diff] [blame] | 66 | ADT/IntEqClassesTest.cpp |
Jakob Stoklund Olesen | 8dc9267 | 2010-11-19 04:47:19 +0000 | [diff] [blame] | 67 | ADT/IntervalMapTest.cpp |
Manuel Klimek | 41aa108 | 2012-01-31 19:58:34 +0000 | [diff] [blame] | 68 | ADT/IntrusiveRefCntPtrTest.cpp |
Argyrios Kyrtzidis | 0f5b687 | 2011-06-15 19:19:09 +0000 | [diff] [blame] | 69 | ADT/PackedVectorTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 70 | ADT/SmallBitVectorTest.cpp |
| 71 | ADT/SmallStringTest.cpp |
| 72 | ADT/SmallVectorTest.cpp |
| 73 | ADT/SparseBitVectorTest.cpp |
Jakob Stoklund Olesen | 6258862 | 2012-02-22 00:56:08 +0000 | [diff] [blame] | 74 | ADT/SparseSetTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 75 | ADT/StringMapTest.cpp |
| 76 | ADT/StringRefTest.cpp |
| 77 | ADT/TripleTest.cpp |
| 78 | ADT/TwineTest.cpp |
Chandler Carruth | d916ce3 | 2011-12-16 08:58:59 +0000 | [diff] [blame] | 79 | ADT/VariadicFunctionTest.cpp |
Douglas Gregor | c576d3d | 2010-09-27 16:40:43 +0000 | [diff] [blame] | 80 | ) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 81 | |
| 82 | add_llvm_unittest(Analysis |
| 83 | Analysis/ScalarEvolutionTest.cpp |
| 84 | ) |
| 85 | |
Eli Bendersky | 61b1851 | 2012-03-13 08:33:15 +0000 | [diff] [blame^] | 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 |
| 91 | ) |
| 92 | set(LLVM_LINK_COMPONENTS |
| 93 | ${LLVM_LINK_COMPONENTS} |
| 94 | IntelJITEvents |
| 95 | ) |
| 96 | endif( LLVM_USE_INTEL_JITEVENTS ) |
| 97 | |
| 98 | if( LLVM_USE_OPROFILE ) |
| 99 | set(ProfileTestSources |
| 100 | ${ProfileTestSources} |
| 101 | ExecutionEngine/OProfileJITEventListenerTest.cpp |
| 102 | ) |
| 103 | set(LLVM_LINK_COMPONENTS |
| 104 | ${LLVM_LINK_COMPONENTS} |
| 105 | OProfileJIT |
| 106 | ) |
| 107 | endif( LLVM_USE_OPROFILE ) |
| 108 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 109 | add_llvm_unittest(ExecutionEngine |
| 110 | ExecutionEngine/ExecutionEngineTest.cpp |
Eli Bendersky | 61b1851 | 2012-03-13 08:33:15 +0000 | [diff] [blame^] | 111 | ExecutionEngine/JITEventListenerTest.cpp |
| 112 | ${ProfileTestSources} |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 113 | ) |
| 114 | |
NAKAMURA Takumi | 0f60ddc | 2010-11-19 03:19:42 +0000 | [diff] [blame] | 115 | set(JITTestsSources |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 116 | ExecutionEngine/JIT/JITMemoryManagerTest.cpp |
| 117 | ExecutionEngine/JIT/JITTest.cpp |
| 118 | ExecutionEngine/JIT/MultiJITTest.cpp |
| 119 | ) |
| 120 | |
NAKAMURA Takumi | 0f60ddc | 2010-11-19 03:19:42 +0000 | [diff] [blame] | 121 | if(MSVC) |
| 122 | list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def) |
| 123 | endif() |
| 124 | |
NAKAMURA Takumi | b3d37e3 | 2010-12-07 07:41:23 +0000 | [diff] [blame] | 125 | add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources}) |
NAKAMURA Takumi | 0f60ddc | 2010-11-19 03:19:42 +0000 | [diff] [blame] | 126 | |
NAKAMURA Takumi | de0cfe8 | 2011-12-16 06:21:08 +0000 | [diff] [blame] | 127 | if(MINGW OR CYGWIN) |
NAKAMURA Takumi | b9dec1f | 2010-11-26 09:32:02 +0000 | [diff] [blame] | 128 | set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols) |
| 129 | endif() |
| 130 | |
NAKAMURA Takumi | b3d37e3 | 2010-12-07 07:41:23 +0000 | [diff] [blame] | 131 | add_llvm_unittest(Transforms/Utils |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 132 | Transforms/Utils/Cloning.cpp |
| 133 | ) |
| 134 | |
NAKAMURA Takumi | 130a2dd | 2010-11-19 03:19:32 +0000 | [diff] [blame] | 135 | set(VMCoreSources |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 136 | VMCore/ConstantsTest.cpp |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 137 | VMCore/InstructionsTest.cpp |
| 138 | VMCore/MetadataTest.cpp |
| 139 | VMCore/PassManagerTest.cpp |
NAKAMURA Takumi | b08ca27 | 2010-11-14 12:37:51 +0000 | [diff] [blame] | 140 | VMCore/ValueMapTest.cpp |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 141 | VMCore/VerifierTest.cpp |
| 142 | ) |
| 143 | |
NAKAMURA Takumi | 130a2dd | 2010-11-19 03:19:32 +0000 | [diff] [blame] | 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) |
| 148 | endif() |
| 149 | |
| 150 | add_llvm_unittest(VMCore ${VMCoreSources}) |
| 151 | |
Chandler Carruth | 972cc0d | 2012-01-02 09:19:48 +0000 | [diff] [blame] | 152 | add_llvm_unittest(Bitcode |
| 153 | Bitcode/BitReaderTest.cpp |
| 154 | ) |
| 155 | |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 156 | set(LLVM_LINK_COMPONENTS |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 157 | Support |
| 158 | Core |
| 159 | ) |
| 160 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 161 | add_llvm_unittest(Support |
| 162 | Support/AllocatorTest.cpp |
| 163 | Support/Casting.cpp |
| 164 | Support/CommandLineTest.cpp |
| 165 | Support/ConstantRangeTest.cpp |
Michael J. Spencer | 5e0b2bf | 2010-10-21 20:28:21 +0000 | [diff] [blame] | 166 | Support/EndianTest.cpp |
Manuel Klimek | 76f1301 | 2011-12-16 13:09:10 +0000 | [diff] [blame] | 167 | Support/JSONParserTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 168 | Support/LeakDetectorTest.cpp |
| 169 | Support/MathExtrasTest.cpp |
Michael J. Spencer | 013d15a | 2010-11-29 22:29:04 +0000 | [diff] [blame] | 170 | Support/Path.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 171 | Support/raw_ostream_test.cpp |
| 172 | Support/RegexTest.cpp |
Michael J. Spencer | 4c099b8 | 2010-10-11 21:56:16 +0000 | [diff] [blame] | 173 | Support/SwapByteOrderTest.cpp |
Michael J. Spencer | 013d15a | 2010-11-29 22:29:04 +0000 | [diff] [blame] | 174 | Support/TimeValue.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 175 | Support/TypeBuilderTest.cpp |
| 176 | Support/ValueHandleTest.cpp |
| 177 | ) |