Home | History | Annotate | Download | only in unittests
      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  )
     77 
     78 add_llvm_unittest(Analysis
     79   Analysis/ScalarEvolutionTest.cpp
     80   )
     81 
     82 add_llvm_unittest(ExecutionEngine
     83   ExecutionEngine/ExecutionEngineTest.cpp
     84   )
     85 
     86 set(JITTestsSources
     87   ExecutionEngine/JIT/JITEventListenerTest.cpp
     88   ExecutionEngine/JIT/JITMemoryManagerTest.cpp
     89   ExecutionEngine/JIT/JITTest.cpp
     90   ExecutionEngine/JIT/MultiJITTest.cpp
     91   )
     92 
     93 if(MSVC)
     94   list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
     95 endif()
     96 
     97 add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
     98 
     99 if(MINGW)
    100   set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
    101 endif()
    102 
    103 add_llvm_unittest(Transforms/Utils
    104   Transforms/Utils/Cloning.cpp
    105   )
    106 
    107 set(VMCoreSources
    108   VMCore/ConstantsTest.cpp
    109   VMCore/InstructionsTest.cpp
    110   VMCore/MetadataTest.cpp
    111   VMCore/PassManagerTest.cpp
    112   VMCore/ValueMapTest.cpp
    113   VMCore/VerifierTest.cpp
    114   )
    115 
    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()
    121 
    122 add_llvm_unittest(VMCore ${VMCoreSources})
    123 
    124 set(LLVM_LINK_COMPONENTS
    125   Support
    126   Core
    127   )
    128 
    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   )
    145