1
- include (LLVMParseArguments )
2
-
3
- # add_clang_unittest(test_dirname file1.cpp file2.cpp ...
4
- # [USED_LIBS lib1 lib2])
1
+ # add_clang_unittest(test_dirname file1.cpp file2.cpp)
5
2
#
6
3
# Will compile the list of files together and link against the clang
7
- # libraries in the USED_LIBS. Produces a binary named
8
- # 'basename(test_dirname)Tests'.
9
- function (add_clang_unittest )
10
- parse_arguments (CLANG_UNITTEST "USED_LIBS" "" ${ARGN} )
11
- list (GET CLANG_UNITTEST_DEFAULT_ARGS 0 test_dirname )
12
- list (REMOVE_AT CLANG_UNITTEST_DEFAULT_ARGS 0 )
13
-
4
+ # Produces a binary named 'basename(test_dirname)'.
5
+ function (add_clang_unittest test_dirname )
14
6
string (REGEX MATCH "([^/]+)$" test_name ${test_dirname} )
15
7
if (CMAKE_BUILD_TYPE )
16
8
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
@@ -22,10 +14,16 @@ function(add_clang_unittest)
22
14
if ( NOT LLVM_BUILD_TESTS )
23
15
set (EXCLUDE_FROM_ALL ON )
24
16
endif ()
25
- add_clang_executable (${test_name} Tests ${CLANG_UNITTEST_DEFAULT_ARGS} )
26
- target_link_libraries (${test_name} Tests ${CLANG_UNITTEST_USED_LIBS} )
27
- add_dependencies (ClangUnitTests ${test_name} Tests )
28
- set_target_properties (${test_name} Tests PROPERTIES FOLDER "Clang tests" )
17
+
18
+ add_clang_executable (${test_name} ${ARGN} )
19
+ target_link_libraries (${test_name}
20
+ gtest
21
+ gtest_main
22
+ LLVMSupport # gtest needs it for raw_ostream.
23
+ )
24
+
25
+ add_dependencies (ClangUnitTests ${test_name} )
26
+ set_target_properties (${test_name} PROPERTIES FOLDER "Clang tests" )
29
27
endfunction ()
30
28
31
29
add_custom_target (ClangUnitTests )
@@ -48,27 +46,37 @@ if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
48
46
add_definitions ("-Wno-variadic-macros" )
49
47
endif ()
50
48
51
- add_clang_unittest (Basic
49
+ add_clang_unittest (BasicTests
52
50
Basic/FileManagerTest.cpp
53
51
Basic/SourceManagerTest.cpp
54
- USED_LIBS gtest gtest_main clangLex
55
- )
52
+ )
53
+ target_link_libraries (BasicTests
54
+ clangLex
55
+ )
56
56
57
- add_clang_unittest (Lex
57
+ add_clang_unittest (LexTests
58
58
Lex/LexerTest.cpp
59
- USED_LIBS gtest gtest_main clangLex
60
- )
59
+ )
60
+ target_link_libraries (LexTests
61
+ clangLex
62
+ )
61
63
62
- add_clang_unittest (Frontend
64
+ add_clang_unittest (FrontendTests
63
65
Frontend/FrontendActionTest.cpp
64
- USED_LIBS gtest gtest_main clangFrontend
65
- )
66
+ )
67
+ target_link_libraries (FrontendTests
68
+ clangFrontend
69
+ )
66
70
67
- add_clang_unittest (Tooling
71
+ add_clang_unittest (ToolingTests
68
72
Tooling/CompilationDatabaseTest.cpp
69
73
Tooling/ToolingTest.cpp
70
74
Tooling/RecursiveASTVisitorTest.cpp
71
75
Tooling/RefactoringTest.cpp
72
76
Tooling/RewriterTest.cpp
73
- USED_LIBS gtest gtest_main clangAST clangTooling clangRewrite
74
- )
77
+ )
78
+ target_link_libraries (ToolingTests
79
+ clangAST
80
+ clangTooling
81
+ clangRewrite
82
+ )
0 commit comments