RefCountedBaseVPTR needs the IntrusiveRefCntPtrInfo as friend,
[oota-llvm.git] / unittests / CMakeLists.txt
1 function(add_llvm_unittest test_dirname)
2   string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
3   if (CMAKE_BUILD_TYPE)
4     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
5       ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
6   else()
7     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
8       ${LLVM_BINARY_DIR}/unittests/${test_dirname})
9   endif()
10   if( NOT LLVM_BUILD_TESTS )
11     set(EXCLUDE_FROM_ALL ON)
12   endif()
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")
16 endfunction()
17
18 add_custom_target(UnitTests)
19 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
20
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")
25 elseif( MSVC )
26   llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
27 endif()
28
29 if (NOT LLVM_ENABLE_THREADS)
30   add_definitions(-DGTEST_HAS_PTHREAD=0)
31 endif()
32
33 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
34   add_definitions("-Wno-variadic-macros")
35 endif()
36
37 set(LLVM_LINK_COMPONENTS
38   jit
39   interpreter
40   nativecodegen
41   BitWriter
42   BitReader
43   AsmParser
44   Core
45   Support
46   )
47
48 set(LLVM_USED_LIBS
49   gtest
50   gtest_main
51   LLVMSupport # gtest needs it for raw_ostream.
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
62   ADT/FoldingSet.cpp
63   ADT/ilistTest.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
73   ADT/StringMapTest.cpp
74   ADT/StringRefTest.cpp
75   ADT/TripleTest.cpp
76   ADT/TwineTest.cpp
77   ADT/VariadicFunctionTest.cpp
78  )
79
80 add_llvm_unittest(Analysis
81   Analysis/ScalarEvolutionTest.cpp
82   )
83
84 add_llvm_unittest(ExecutionEngine
85   ExecutionEngine/ExecutionEngineTest.cpp
86   )
87
88 set(JITTestsSources
89   ExecutionEngine/JIT/JITEventListenerTest.cpp
90   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
91   ExecutionEngine/JIT/JITTest.cpp
92   ExecutionEngine/JIT/MultiJITTest.cpp
93   )
94
95 if(MSVC)
96   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
97 endif()
98
99 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
100
101 if(MINGW OR CYGWIN)
102   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
103 endif()
104
105 add_llvm_unittest(Transforms/Utils
106   Transforms/Utils/Cloning.cpp
107   )
108
109 set(VMCoreSources
110   VMCore/ConstantsTest.cpp
111   VMCore/InstructionsTest.cpp
112   VMCore/MetadataTest.cpp
113   VMCore/PassManagerTest.cpp
114   VMCore/ValueMapTest.cpp
115   VMCore/VerifierTest.cpp
116   )
117
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)
122 endif()
123
124 add_llvm_unittest(VMCore ${VMCoreSources})
125
126 add_llvm_unittest(Bitcode
127   Bitcode/BitReaderTest.cpp
128   )
129
130 set(LLVM_LINK_COMPONENTS
131   Support
132   Core
133   )
134
135 add_llvm_unittest(Support
136   Support/AllocatorTest.cpp
137   Support/Casting.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
144   Support/Path.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
151   )