Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 1 | function(add_llvm_unittest test_name) |
| 2 | if (CMAKE_BUILD_TYPE) |
| 3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY |
| 4 | ${LLVM_BINARY_DIR}/unittests/${test_name}/${CMAKE_BUILD_TYPE}) |
| 5 | else() |
| 6 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY |
| 7 | ${LLVM_BINARY_DIR}/unittests/${test_name}) |
| 8 | endif() |
| 9 | if( NOT LLVM_BUILD_TESTS ) |
| 10 | set(EXCLUDE_FROM_ALL ON) |
| 11 | endif() |
Oscar Fuentes | 066de85 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 12 | add_llvm_executable(${test_name}Tests ${ARGN}) |
Oscar Fuentes | da97563 | 2010-10-28 14:38:35 +0000 | [diff] [blame] | 13 | add_dependencies(UnitTests ${test_name}Tests) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 14 | endfunction() |
| 15 | |
Oscar Fuentes | da97563 | 2010-10-28 14:38:35 +0000 | [diff] [blame] | 16 | add_custom_target(UnitTests) |
| 17 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 18 | include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) |
Michael J. Spencer | 8a806ae | 2010-10-19 18:04:19 +0000 | [diff] [blame] | 19 | add_definitions(-DGTEST_HAS_RTTI=0) |
Michael J. Spencer | f2ca4cb | 2010-11-24 19:20:05 +0000 | [diff] [blame] | 20 | if (NOT LLVM_ENABLE_THREADS) |
| 21 | add_definitions(-DGTEST_HAS_PTHREAD=0) |
| 22 | endif() |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 23 | |
| 24 | set(LLVM_LINK_COMPONENTS |
| 25 | jit |
| 26 | interpreter |
| 27 | nativecodegen |
| 28 | BitWriter |
| 29 | BitReader |
| 30 | AsmParser |
| 31 | Core |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 32 | Support |
| 33 | ) |
| 34 | |
| 35 | set(LLVM_USED_LIBS |
| 36 | gtest |
| 37 | gtest_main |
Michael J. Spencer | f2ca4cb | 2010-11-24 19:20:05 +0000 | [diff] [blame] | 38 | LLVMSupport # gtest needs it for raw_ostream. |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 39 | ) |
| 40 | |
| 41 | add_llvm_unittest(ADT |
| 42 | ADT/APFloatTest.cpp |
| 43 | ADT/APIntTest.cpp |
| 44 | ADT/BitVectorTest.cpp |
| 45 | ADT/DAGDeltaAlgorithmTest.cpp |
| 46 | ADT/DeltaAlgorithmTest.cpp |
| 47 | ADT/DenseMapTest.cpp |
| 48 | ADT/DenseSetTest.cpp |
Dale Johannesen | a197cba | 2010-11-19 23:23:22 +0000 | [diff] [blame] | 49 | ADT/FoldingSet.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 50 | ADT/ilistTest.cpp |
| 51 | ADT/ImmutableSetTest.cpp |
Jakob Stoklund Olesen | 8dc9267 | 2010-11-19 04:47:19 +0000 | [diff] [blame] | 52 | ADT/IntervalMapTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 53 | ADT/SmallBitVectorTest.cpp |
| 54 | ADT/SmallStringTest.cpp |
| 55 | ADT/SmallVectorTest.cpp |
| 56 | ADT/SparseBitVectorTest.cpp |
| 57 | ADT/StringMapTest.cpp |
| 58 | ADT/StringRefTest.cpp |
| 59 | ADT/TripleTest.cpp |
| 60 | ADT/TwineTest.cpp |
Douglas Gregor | c576d3d | 2010-09-27 16:40:43 +0000 | [diff] [blame] | 61 | ) |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 62 | |
| 63 | add_llvm_unittest(Analysis |
| 64 | Analysis/ScalarEvolutionTest.cpp |
| 65 | ) |
| 66 | |
| 67 | add_llvm_unittest(ExecutionEngine |
| 68 | ExecutionEngine/ExecutionEngineTest.cpp |
| 69 | ) |
| 70 | |
NAKAMURA Takumi | 0f60ddc | 2010-11-19 03:19:42 +0000 | [diff] [blame] | 71 | set(JITTestsSources |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 72 | ExecutionEngine/JIT/JITEventListenerTest.cpp |
| 73 | ExecutionEngine/JIT/JITMemoryManagerTest.cpp |
| 74 | ExecutionEngine/JIT/JITTest.cpp |
| 75 | ExecutionEngine/JIT/MultiJITTest.cpp |
| 76 | ) |
| 77 | |
NAKAMURA Takumi | 0f60ddc | 2010-11-19 03:19:42 +0000 | [diff] [blame] | 78 | if(MSVC) |
| 79 | list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def) |
| 80 | endif() |
| 81 | |
| 82 | add_llvm_unittest(JIT ${JITTestsSources}) |
| 83 | |
NAKAMURA Takumi | b9dec1f | 2010-11-26 09:32:02 +0000 | [diff] [blame] | 84 | if(MINGW) |
| 85 | set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols) |
| 86 | endif() |
| 87 | |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 88 | add_llvm_unittest(Transforms |
| 89 | Transforms/Utils/Cloning.cpp |
| 90 | ) |
| 91 | |
NAKAMURA Takumi | 130a2dd | 2010-11-19 03:19:32 +0000 | [diff] [blame] | 92 | set(VMCoreSources |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 93 | VMCore/ConstantsTest.cpp |
| 94 | VMCore/DerivedTypesTest.cpp |
| 95 | VMCore/InstructionsTest.cpp |
| 96 | VMCore/MetadataTest.cpp |
| 97 | VMCore/PassManagerTest.cpp |
NAKAMURA Takumi | b08ca27 | 2010-11-14 12:37:51 +0000 | [diff] [blame] | 98 | VMCore/ValueMapTest.cpp |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 99 | VMCore/VerifierTest.cpp |
| 100 | ) |
| 101 | |
NAKAMURA Takumi | 130a2dd | 2010-11-19 03:19:32 +0000 | [diff] [blame] | 102 | # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug. |
| 103 | # See issue#331418 in Visual Studio. |
| 104 | if(MSVC AND MSVC_VERSION LESS 1600) |
| 105 | list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp) |
| 106 | endif() |
| 107 | |
| 108 | add_llvm_unittest(VMCore ${VMCoreSources}) |
| 109 | |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 110 | set(LLVM_LINK_COMPONENTS |
Michael J. Spencer | 12647eb | 2010-10-11 21:22:34 +0000 | [diff] [blame] | 111 | Support |
| 112 | Core |
| 113 | ) |
| 114 | |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 115 | add_llvm_unittest(Support |
| 116 | Support/AllocatorTest.cpp |
| 117 | Support/Casting.cpp |
| 118 | Support/CommandLineTest.cpp |
| 119 | Support/ConstantRangeTest.cpp |
Michael J. Spencer | 5e0b2bf | 2010-10-21 20:28:21 +0000 | [diff] [blame] | 120 | Support/EndianTest.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 121 | Support/LeakDetectorTest.cpp |
| 122 | Support/MathExtrasTest.cpp |
Michael J. Spencer | 013d15a | 2010-11-29 22:29:04 +0000 | [diff] [blame^] | 123 | Support/Path.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 124 | Support/raw_ostream_test.cpp |
| 125 | Support/RegexTest.cpp |
Michael J. Spencer | 4c099b8 | 2010-10-11 21:56:16 +0000 | [diff] [blame] | 126 | Support/SwapByteOrderTest.cpp |
Michael J. Spencer | 013d15a | 2010-11-29 22:29:04 +0000 | [diff] [blame^] | 127 | Support/TimeValue.cpp |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 128 | Support/TypeBuilderTest.cpp |
| 129 | Support/ValueHandleTest.cpp |
| 130 | ) |