2010-12-07 15:41:23 +08:00
|
|
|
function(add_llvm_unittest test_dirname)
|
|
|
|
string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
|
2010-09-24 17:01:13 +08:00
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
2010-12-07 15:41:23 +08:00
|
|
|
${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
|
2010-09-24 17:01:13 +08:00
|
|
|
else()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
2010-12-07 15:41:23 +08:00
|
|
|
${LLVM_BINARY_DIR}/unittests/${test_dirname})
|
2010-09-24 17:01:13 +08:00
|
|
|
endif()
|
|
|
|
if( NOT LLVM_BUILD_TESTS )
|
|
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
|
|
endif()
|
2010-09-26 04:25:25 +08:00
|
|
|
add_llvm_executable(${test_name}Tests ${ARGN})
|
2010-10-28 22:38:35 +08:00
|
|
|
add_dependencies(UnitTests ${test_name}Tests)
|
2011-02-21 06:06:10 +08:00
|
|
|
set_target_properties(${test_name}Tests PROPERTIES FOLDER "Tests")
|
2010-09-24 17:01:13 +08:00
|
|
|
endfunction()
|
|
|
|
|
2012-06-06 11:11:20 +08:00
|
|
|
# Visual Studio 2012 only supports up to 8 template parameters in
|
|
|
|
# std::tr1::tuple by default, but gtest requires 10
|
|
|
|
if(MSVC AND MSVC_VERSION EQUAL 1700)
|
|
|
|
add_definitions(-D_VARIADIC_MAX=10)
|
|
|
|
endif ()
|
|
|
|
|
2010-10-28 22:38:35 +08:00
|
|
|
add_custom_target(UnitTests)
|
2011-02-21 06:06:10 +08:00
|
|
|
set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
|
2010-10-28 22:38:35 +08:00
|
|
|
|
2010-09-24 17:01:13 +08:00
|
|
|
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
2010-10-20 02:04:19 +08:00
|
|
|
add_definitions(-DGTEST_HAS_RTTI=0)
|
2011-05-11 21:53:08 +08:00
|
|
|
if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
|
2011-01-13 23:31:45 +08:00
|
|
|
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
|
|
|
|
elseif( MSVC )
|
|
|
|
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
|
|
|
|
endif()
|
|
|
|
|
2010-11-25 03:20:05 +08:00
|
|
|
if (NOT LLVM_ENABLE_THREADS)
|
|
|
|
add_definitions(-DGTEST_HAS_PTHREAD=0)
|
|
|
|
endif()
|
2010-09-24 17:01:13 +08:00
|
|
|
|
2010-12-07 18:22:07 +08:00
|
|
|
if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
|
|
|
|
add_definitions("-Wno-variadic-macros")
|
|
|
|
endif()
|
|
|
|
|
2010-09-24 17:01:13 +08:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
jit
|
|
|
|
interpreter
|
|
|
|
nativecodegen
|
|
|
|
BitWriter
|
|
|
|
BitReader
|
|
|
|
AsmParser
|
|
|
|
Core
|
|
|
|
Support
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LLVM_USED_LIBS
|
|
|
|
gtest
|
|
|
|
gtest_main
|
2010-11-25 03:20:05 +08:00
|
|
|
LLVMSupport # gtest needs it for raw_ostream.
|
2010-09-24 17:01:13 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_llvm_unittest(ADT
|
|
|
|
ADT/APFloatTest.cpp
|
|
|
|
ADT/APIntTest.cpp
|
|
|
|
ADT/BitVectorTest.cpp
|
|
|
|
ADT/DAGDeltaAlgorithmTest.cpp
|
|
|
|
ADT/DeltaAlgorithmTest.cpp
|
|
|
|
ADT/DenseMapTest.cpp
|
|
|
|
ADT/DenseSetTest.cpp
|
2010-11-20 07:23:22 +08:00
|
|
|
ADT/FoldingSet.cpp
|
2012-02-19 05:00:49 +08:00
|
|
|
ADT/HashingTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
ADT/ilistTest.cpp
|
|
|
|
ADT/ImmutableSetTest.cpp
|
2010-12-21 08:04:46 +08:00
|
|
|
ADT/IntEqClassesTest.cpp
|
2010-11-19 12:47:19 +08:00
|
|
|
ADT/IntervalMapTest.cpp
|
2012-02-01 03:58:34 +08:00
|
|
|
ADT/IntrusiveRefCntPtrTest.cpp
|
2011-06-16 03:19:09 +08:00
|
|
|
ADT/PackedVectorTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
ADT/SCCIteratorTest.cpp
|
|
|
|
ADT/SmallPtrSetTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
ADT/SmallStringTest.cpp
|
|
|
|
ADT/SmallVectorTest.cpp
|
|
|
|
ADT/SparseBitVectorTest.cpp
|
2012-02-22 08:56:08 +08:00
|
|
|
ADT/SparseSetTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
ADT/StringMapTest.cpp
|
|
|
|
ADT/StringRefTest.cpp
|
|
|
|
ADT/TripleTest.cpp
|
|
|
|
ADT/TwineTest.cpp
|
2011-12-16 16:58:59 +08:00
|
|
|
ADT/VariadicFunctionTest.cpp
|
2010-09-28 00:40:43 +08:00
|
|
|
)
|
2010-09-24 17:01:13 +08:00
|
|
|
|
|
|
|
add_llvm_unittest(Analysis
|
|
|
|
Analysis/ScalarEvolutionTest.cpp
|
|
|
|
)
|
|
|
|
|
2012-03-15 14:49:31 +08:00
|
|
|
add_llvm_unittest(ExecutionEngine
|
|
|
|
ExecutionEngine/ExecutionEngineTest.cpp
|
|
|
|
)
|
|
|
|
|
2012-03-13 16:33:15 +08:00
|
|
|
if( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
|
|
|
|
link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
|
|
|
|
set(ProfileTestSources
|
2012-03-15 14:49:31 +08:00
|
|
|
ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
|
2012-03-13 16:33:15 +08:00
|
|
|
)
|
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_LINK_COMPONENTS}
|
|
|
|
IntelJITEvents
|
|
|
|
)
|
|
|
|
endif( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
|
|
|
|
if( LLVM_USE_OPROFILE )
|
|
|
|
set(ProfileTestSources
|
|
|
|
${ProfileTestSources}
|
2012-03-15 14:49:31 +08:00
|
|
|
ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
|
2012-03-13 16:33:15 +08:00
|
|
|
)
|
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_LINK_COMPONENTS}
|
|
|
|
OProfileJIT
|
|
|
|
)
|
|
|
|
endif( LLVM_USE_OPROFILE )
|
|
|
|
|
2010-11-19 11:19:42 +08:00
|
|
|
set(JITTestsSources
|
2012-03-15 14:49:31 +08:00
|
|
|
ExecutionEngine/JIT/JITEventListenerTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
ExecutionEngine/JIT/JITMemoryManagerTest.cpp
|
|
|
|
ExecutionEngine/JIT/JITTest.cpp
|
|
|
|
ExecutionEngine/JIT/MultiJITTest.cpp
|
2012-03-15 14:49:31 +08:00
|
|
|
${ProfileTestSources}
|
2010-09-24 17:01:13 +08:00
|
|
|
)
|
|
|
|
|
2010-11-19 11:19:42 +08:00
|
|
|
if(MSVC)
|
|
|
|
list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
|
|
|
|
endif()
|
|
|
|
|
2010-12-07 15:41:23 +08:00
|
|
|
add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources})
|
2010-11-19 11:19:42 +08:00
|
|
|
|
2011-12-16 14:21:08 +08:00
|
|
|
if(MINGW OR CYGWIN)
|
2010-11-26 17:32:02 +08:00
|
|
|
set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
|
|
|
|
endif()
|
|
|
|
|
2010-12-07 15:41:23 +08:00
|
|
|
add_llvm_unittest(Transforms/Utils
|
2010-10-12 05:22:34 +08:00
|
|
|
Transforms/Utils/Cloning.cpp
|
|
|
|
)
|
|
|
|
|
2010-11-19 11:19:32 +08:00
|
|
|
set(VMCoreSources
|
2010-10-12 05:22:34 +08:00
|
|
|
VMCore/ConstantsTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
VMCore/DominatorTreeTest.cpp
|
2010-10-12 05:22:34 +08:00
|
|
|
VMCore/InstructionsTest.cpp
|
|
|
|
VMCore/MetadataTest.cpp
|
|
|
|
VMCore/PassManagerTest.cpp
|
2010-11-14 20:37:51 +08:00
|
|
|
VMCore/ValueMapTest.cpp
|
2010-10-12 05:22:34 +08:00
|
|
|
VMCore/VerifierTest.cpp
|
|
|
|
)
|
|
|
|
|
2010-11-19 11:19:32 +08:00
|
|
|
# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
|
|
|
|
# See issue#331418 in Visual Studio.
|
|
|
|
if(MSVC AND MSVC_VERSION LESS 1600)
|
|
|
|
list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_llvm_unittest(VMCore ${VMCoreSources})
|
|
|
|
|
2012-01-02 17:19:48 +08:00
|
|
|
add_llvm_unittest(Bitcode
|
|
|
|
Bitcode/BitReaderTest.cpp
|
|
|
|
)
|
|
|
|
|
2010-10-12 05:22:34 +08:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
Support
|
|
|
|
Core
|
|
|
|
)
|
|
|
|
|
2010-09-24 17:01:13 +08:00
|
|
|
add_llvm_unittest(Support
|
2012-06-16 16:52:57 +08:00
|
|
|
Support/AlignOfTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/AllocatorTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
Support/BlockFrequencyTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/Casting.cpp
|
|
|
|
Support/CommandLineTest.cpp
|
|
|
|
Support/ConstantRangeTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
Support/DataExtractorTest.cpp
|
2010-10-22 04:28:21 +08:00
|
|
|
Support/EndianTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
Support/IntegersSubsetTest.cpp
|
|
|
|
Support/IRBuilderTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/LeakDetectorTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
Support/ManagedStatic.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/MathExtrasTest.cpp
|
2012-06-17 22:42:49 +08:00
|
|
|
Support/MDBuilderTest.cpp
|
2010-11-30 06:29:04 +08:00
|
|
|
Support/Path.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/raw_ostream_test.cpp
|
|
|
|
Support/RegexTest.cpp
|
2010-10-12 05:56:16 +08:00
|
|
|
Support/SwapByteOrderTest.cpp
|
2010-11-30 06:29:04 +08:00
|
|
|
Support/TimeValue.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/TypeBuilderTest.cpp
|
|
|
|
Support/ValueHandleTest.cpp
|
2012-04-04 07:09:22 +08:00
|
|
|
Support/YAMLParserTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
)
|