Add a function for profiling to run at shutdown. Unlike the existing API, this
[llvm/stm8.git] / unittests / CMakeLists.txt
blobda4a6524bd978b4b2090b51d99a03b9743595bd1
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()
18 add_custom_target(UnitTests)
19 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
21 include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
22 add_definitions(-DGTEST_HAS_RTTI=0)
23 if( CMAKE_COMPILER_IS_GNUCXX )
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()
29 if (NOT LLVM_ENABLE_THREADS)
30   add_definitions(-DGTEST_HAS_PTHREAD=0)
31 endif()
33 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
34   add_definitions("-Wno-variadic-macros")
35 endif()
37 set(LLVM_LINK_COMPONENTS
38   jit
39   interpreter
40   nativecodegen
41   BitWriter
42   BitReader
43   AsmParser
44   Core
45   Support
46   )
48 set(LLVM_USED_LIBS
49   gtest
50   gtest_main
51   LLVMSupport # gtest needs it for raw_ostream.
52   )
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/SmallBitVectorTest.cpp
68   ADT/SmallStringTest.cpp
69   ADT/SmallVectorTest.cpp
70   ADT/SparseBitVectorTest.cpp
71   ADT/StringMapTest.cpp
72   ADT/StringRefTest.cpp
73   ADT/TripleTest.cpp
74   ADT/TwineTest.cpp
75  )
77 add_llvm_unittest(Analysis
78   Analysis/ScalarEvolutionTest.cpp
79   )
81 add_llvm_unittest(ExecutionEngine
82   ExecutionEngine/ExecutionEngineTest.cpp
83   )
85 set(JITTestsSources
86   ExecutionEngine/JIT/JITEventListenerTest.cpp
87   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
88   ExecutionEngine/JIT/JITTest.cpp
89   ExecutionEngine/JIT/MultiJITTest.cpp
90   )
92 if(MSVC)
93   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
94 endif()
96 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
98 if(MINGW)
99   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
100 endif()
102 add_llvm_unittest(Transforms/Utils
103   Transforms/Utils/Cloning.cpp
104   )
106 set(VMCoreSources
107   VMCore/ConstantsTest.cpp
108   VMCore/DerivedTypesTest.cpp
109   VMCore/InstructionsTest.cpp
110   VMCore/MetadataTest.cpp
111   VMCore/PassManagerTest.cpp
112   VMCore/ValueMapTest.cpp
113   VMCore/VerifierTest.cpp
114   )
116 # MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
117 # See issue#331418 in Visual Studio.
118 if(MSVC AND MSVC_VERSION LESS 1600)
119   list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
120 endif()
122 add_llvm_unittest(VMCore ${VMCoreSources})
124 set(LLVM_LINK_COMPONENTS
125   Support
126   Core
127   )
129 add_llvm_unittest(Support
130   Support/AllocatorTest.cpp
131   Support/Casting.cpp
132   Support/CommandLineTest.cpp
133   Support/ConstantRangeTest.cpp
134   Support/EndianTest.cpp
135   Support/LeakDetectorTest.cpp
136   Support/MathExtrasTest.cpp
137   Support/Path.cpp
138   Support/raw_ostream_test.cpp
139   Support/RegexTest.cpp
140   Support/SwapByteOrderTest.cpp
141   Support/TimeValue.cpp
142   Support/TypeBuilderTest.cpp
143   Support/ValueHandleTest.cpp
144   )