CMake: Fix warning in gtest header used by unit tests.
[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 endfunction()
16
17 add_custom_target(UnitTests)
18
19 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
20 add_definitions(-DGTEST_HAS_RTTI=0)
21 if (NOT LLVM_ENABLE_THREADS)
22   add_definitions(-DGTEST_HAS_PTHREAD=0)
23 endif()
24
25 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
26   add_definitions("-Wno-variadic-macros")
27 endif()
28
29 set(LLVM_LINK_COMPONENTS
30   jit
31   interpreter
32   nativecodegen
33   BitWriter
34   BitReader
35   AsmParser
36   Core
37   Support
38   )
39
40 set(LLVM_USED_LIBS
41   gtest
42   gtest_main
43   LLVMSupport # gtest needs it for raw_ostream.
44   )
45
46 add_llvm_unittest(ADT
47   ADT/APFloatTest.cpp
48   ADT/APIntTest.cpp
49   ADT/BitVectorTest.cpp
50   ADT/DAGDeltaAlgorithmTest.cpp
51   ADT/DeltaAlgorithmTest.cpp
52   ADT/DenseMapTest.cpp
53   ADT/DenseSetTest.cpp
54   ADT/FoldingSet.cpp
55   ADT/ilistTest.cpp
56   ADT/ImmutableSetTest.cpp
57   ADT/IntervalMapTest.cpp
58   ADT/SmallBitVectorTest.cpp
59   ADT/SmallStringTest.cpp
60   ADT/SmallVectorTest.cpp
61   ADT/SparseBitVectorTest.cpp
62   ADT/StringMapTest.cpp
63   ADT/StringRefTest.cpp
64   ADT/TripleTest.cpp
65   ADT/TwineTest.cpp
66  )
67
68 add_llvm_unittest(Analysis
69   Analysis/ScalarEvolutionTest.cpp
70   )
71
72 add_llvm_unittest(ExecutionEngine
73   ExecutionEngine/ExecutionEngineTest.cpp
74   )
75
76 set(JITTestsSources
77   ExecutionEngine/JIT/JITEventListenerTest.cpp
78   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
79   ExecutionEngine/JIT/JITTest.cpp
80   ExecutionEngine/JIT/MultiJITTest.cpp
81   )
82
83 if(MSVC)
84   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
85 endif()
86
87 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
88
89 if(MINGW)
90   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
91 endif()
92
93 add_llvm_unittest(Transforms/Utils
94   Transforms/Utils/Cloning.cpp
95   )
96
97 set(VMCoreSources
98   VMCore/ConstantsTest.cpp
99   VMCore/DerivedTypesTest.cpp
100   VMCore/InstructionsTest.cpp
101   VMCore/MetadataTest.cpp
102   VMCore/PassManagerTest.cpp
103   VMCore/ValueMapTest.cpp
104   VMCore/VerifierTest.cpp
105   )
106
107 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
108 # See issue#331418 in Visual Studio.
109 if(MSVC AND MSVC_VERSION LESS 1600)
110   list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
111 endif()
112
113 add_llvm_unittest(VMCore ${VMCoreSources})
114
115 set(LLVM_LINK_COMPONENTS
116   Support
117   Core
118   )
119
120 add_llvm_unittest(Support
121   Support/AllocatorTest.cpp
122   Support/Casting.cpp
123   Support/CommandLineTest.cpp
124   Support/ConstantRangeTest.cpp
125   Support/EndianTest.cpp
126   Support/LeakDetectorTest.cpp
127   Support/MathExtrasTest.cpp
128   Support/Path.cpp
129   Support/raw_ostream_test.cpp
130   Support/RegexTest.cpp
131   Support/SwapByteOrderTest.cpp
132   Support/TimeValue.cpp
133   Support/TypeBuilderTest.cpp
134   Support/ValueHandleTest.cpp
135   )