2012-06-21 10:04:39 +08:00
|
|
|
# add_clang_unittest(test_dirname file1.cpp file2.cpp)
|
2011-02-20 02:06:01 +08:00
|
|
|
#
|
|
|
|
# Will compile the list of files together and link against the clang
|
2012-06-21 10:04:39 +08:00
|
|
|
# Produces a binary named 'basename(test_dirname)'.
|
|
|
|
function(add_clang_unittest test_dirname)
|
2011-02-15 15:54:28 +08:00
|
|
|
string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
|
|
|
${CLANG_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE})
|
|
|
|
else()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
|
|
|
${CLANG_BINARY_DIR}/unittests/${test_dirname})
|
|
|
|
endif()
|
|
|
|
if( NOT LLVM_BUILD_TESTS )
|
|
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
|
|
endif()
|
2012-06-21 10:04:39 +08:00
|
|
|
|
|
|
|
add_clang_executable(${test_name} ${ARGN})
|
|
|
|
target_link_libraries(${test_name}
|
|
|
|
gtest
|
|
|
|
gtest_main
|
|
|
|
LLVMSupport # gtest needs it for raw_ostream.
|
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(ClangUnitTests ${test_name})
|
|
|
|
set_target_properties(${test_name} PROPERTIES FOLDER "Clang tests")
|
2011-02-15 15:54:28 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_custom_target(ClangUnitTests)
|
2011-02-21 06:06:44 +08:00
|
|
|
set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
|
2011-02-15 15:54:28 +08:00
|
|
|
|
|
|
|
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
2012-06-21 08:40:48 +08:00
|
|
|
|
2011-02-15 15:54:28 +08:00
|
|
|
add_definitions(-DGTEST_HAS_RTTI=0)
|
2011-05-11 21:53:30 +08:00
|
|
|
if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
|
2011-02-15 15:54:28 +08:00
|
|
|
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
|
|
|
|
elseif( MSVC )
|
|
|
|
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_THREADS)
|
|
|
|
add_definitions(-DGTEST_HAS_PTHREAD=0)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
|
|
|
|
add_definitions("-Wno-variadic-macros")
|
|
|
|
endif()
|
|
|
|
|
2012-06-21 10:04:39 +08:00
|
|
|
add_clang_unittest(BasicTests
|
2011-02-16 13:45:20 +08:00
|
|
|
Basic/FileManagerTest.cpp
|
2011-12-22 00:56:29 +08:00
|
|
|
Basic/SourceManagerTest.cpp
|
2012-06-21 10:04:39 +08:00
|
|
|
)
|
|
|
|
target_link_libraries(BasicTests
|
|
|
|
clangLex
|
|
|
|
)
|
2011-02-16 13:45:20 +08:00
|
|
|
|
2012-06-21 10:04:39 +08:00
|
|
|
add_clang_unittest(LexTests
|
2012-01-19 23:59:01 +08:00
|
|
|
Lex/LexerTest.cpp
|
2012-06-21 10:04:39 +08:00
|
|
|
)
|
|
|
|
target_link_libraries(LexTests
|
|
|
|
clangLex
|
|
|
|
)
|
2012-01-19 23:59:01 +08:00
|
|
|
|
2012-06-21 10:04:39 +08:00
|
|
|
add_clang_unittest(FrontendTests
|
2011-02-15 15:54:28 +08:00
|
|
|
Frontend/FrontendActionTest.cpp
|
2012-06-21 10:04:39 +08:00
|
|
|
)
|
|
|
|
target_link_libraries(FrontendTests
|
|
|
|
clangFrontend
|
|
|
|
)
|
2012-04-04 20:07:46 +08:00
|
|
|
|
2012-06-21 10:04:39 +08:00
|
|
|
add_clang_unittest(ToolingTests
|
2012-04-04 20:07:46 +08:00
|
|
|
Tooling/CompilationDatabaseTest.cpp
|
|
|
|
Tooling/ToolingTest.cpp
|
2012-04-19 16:48:53 +08:00
|
|
|
Tooling/RecursiveASTVisitorTest.cpp
|
2012-05-24 00:29:20 +08:00
|
|
|
Tooling/RefactoringTest.cpp
|
2012-05-23 01:01:35 +08:00
|
|
|
Tooling/RewriterTest.cpp
|
2012-06-21 10:04:39 +08:00
|
|
|
)
|
|
|
|
target_link_libraries(ToolingTests
|
|
|
|
clangAST
|
|
|
|
clangTooling
|
|
|
|
clangRewrite
|
|
|
|
)
|