Adds a JSON parser and a benchmark (json-bench) to catch performance regressions.
[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/PackedVectorTest.cpp
68   ADT/SmallBitVectorTest.cpp
69   ADT/SmallStringTest.cpp
70   ADT/SmallVectorTest.cpp
71   ADT/SparseBitVectorTest.cpp
72   ADT/StringMapTest.cpp
73   ADT/StringRefTest.cpp
74   ADT/TripleTest.cpp
75   ADT/TwineTest.cpp
76   ADT/VariadicFunctionTest.cpp
77  )
78
79 add_llvm_unittest(Analysis
80   Analysis/ScalarEvolutionTest.cpp
81   )
82
83 add_llvm_unittest(ExecutionEngine
84   ExecutionEngine/ExecutionEngineTest.cpp
85   )
86
87 set(JITTestsSources
88   ExecutionEngine/JIT/JITEventListenerTest.cpp
89   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
90   ExecutionEngine/JIT/JITTest.cpp
91   ExecutionEngine/JIT/MultiJITTest.cpp
92   )
93
94 if(MSVC)
95   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
96 endif()
97
98 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
99
100 if(MINGW OR CYGWIN)
101   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
102 endif()
103
104 add_llvm_unittest(Transforms/Utils
105   Transforms/Utils/Cloning.cpp
106   )
107
108 set(VMCoreSources
109   VMCore/ConstantsTest.cpp
110   VMCore/InstructionsTest.cpp
111   VMCore/MetadataTest.cpp
112   VMCore/PassManagerTest.cpp
113   VMCore/ValueMapTest.cpp
114   VMCore/VerifierTest.cpp
115   )
116
117 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
118 # See issue#331418 in Visual Studio.
119 if(MSVC AND MSVC_VERSION LESS 1600)
120   list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
121 endif()
122
123 add_llvm_unittest(VMCore ${VMCoreSources})
124
125 set(LLVM_LINK_COMPONENTS
126   Support
127   Core
128   )
129
130 add_llvm_unittest(Support
131   Support/AllocatorTest.cpp
132   Support/Casting.cpp
133   Support/CommandLineTest.cpp
134   Support/ConstantRangeTest.cpp
135   Support/EndianTest.cpp
136   Support/JSONParserTest.cpp
137   Support/LeakDetectorTest.cpp
138   Support/MathExtrasTest.cpp
139   Support/Path.cpp
140   Support/raw_ostream_test.cpp
141   Support/RegexTest.cpp
142   Support/SwapByteOrderTest.cpp
143   Support/TimeValue.cpp
144   Support/TypeBuilderTest.cpp
145   Support/ValueHandleTest.cpp
146   )