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)
|
2010-09-24 17:01:13 +08:00
|
|
|
endfunction()
|
|
|
|
|
2010-10-28 22:38:35 +08:00
|
|
|
add_custom_target(UnitTests)
|
|
|
|
|
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-01-13 23:31:45 +08:00
|
|
|
if( CMAKE_COMPILER_IS_GNUCXX )
|
|
|
|
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
|
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
|
2010-09-24 17:01:13 +08:00
|
|
|
ADT/SmallBitVectorTest.cpp
|
|
|
|
ADT/SmallStringTest.cpp
|
|
|
|
ADT/SmallVectorTest.cpp
|
|
|
|
ADT/SparseBitVectorTest.cpp
|
|
|
|
ADT/StringMapTest.cpp
|
|
|
|
ADT/StringRefTest.cpp
|
|
|
|
ADT/TripleTest.cpp
|
|
|
|
ADT/TwineTest.cpp
|
2010-09-28 00:40:43 +08:00
|
|
|
)
|
2010-09-24 17:01:13 +08:00
|
|
|
|
|
|
|
add_llvm_unittest(Analysis
|
|
|
|
Analysis/ScalarEvolutionTest.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_llvm_unittest(ExecutionEngine
|
|
|
|
ExecutionEngine/ExecutionEngineTest.cpp
|
|
|
|
)
|
|
|
|
|
2010-11-19 11:19:42 +08:00
|
|
|
set(JITTestsSources
|
2010-09-24 17:01:13 +08:00
|
|
|
ExecutionEngine/JIT/JITEventListenerTest.cpp
|
|
|
|
ExecutionEngine/JIT/JITMemoryManagerTest.cpp
|
|
|
|
ExecutionEngine/JIT/JITTest.cpp
|
|
|
|
ExecutionEngine/JIT/MultiJITTest.cpp
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
2010-11-26 17:32:02 +08:00
|
|
|
if(MINGW)
|
|
|
|
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
|
|
|
|
VMCore/DerivedTypesTest.cpp
|
|
|
|
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})
|
|
|
|
|
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
|
|
|
|
Support/AllocatorTest.cpp
|
|
|
|
Support/Casting.cpp
|
|
|
|
Support/CommandLineTest.cpp
|
|
|
|
Support/ConstantRangeTest.cpp
|
2010-10-22 04:28:21 +08:00
|
|
|
Support/EndianTest.cpp
|
2010-09-24 17:01:13 +08:00
|
|
|
Support/LeakDetectorTest.cpp
|
|
|
|
Support/MathExtrasTest.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
|
|
|
|
)
|