@@ -23,35 +23,57 @@ include(CMakeParseArguments)
23
23
# Defines a new test executable target with the given target name, sources, and
24
24
# dependencies. Implicitly adds DEPENDS on gtest and gtest_main.
25
25
function (cc_test name )
26
- set (multi DEPENDS SOURCES INCLUDES DEFINES
27
- ANDROID_DEPENDS ANDROID_SOURCES ANDROID_INCLUDES ANDROID_DEFINES
28
- IOS_DEPENDS IOS_SOURCES IOS_INCLUDES IOS_DEFINES
29
- DESKTOP_DEPENDS DESKTOP_SOURCES DESKTOP_INCLUDES DESKTOP_DEFINES )
26
+ if (ANDROID OR IOS )
27
+ return ()
28
+ endif ()
29
+
30
+ set (multi DEPENDS SOURCES INCLUDES DEFINES )
30
31
# Parse the arguments into cc_test_SOURCES and cc_test_DEPENDS.
31
32
cmake_parse_arguments (cc_test "" "" "${multi} " ${ARGN} )
32
33
33
34
list (APPEND cc_test_DEPENDS gmock gtest gtest_main )
34
- if (ANDROID )
35
- list (APPEND cc_test_SOURCES "${cc_test_ANDROID_SOURCES} " )
36
- list (APPEND cc_test_DEPENDS "${cc_test_ANDROID_DEPENDS} " )
37
- list (APPEND cc_test_INCLUDES "${cc_test_ANDROID_INCLUDES} " )
38
- list (APPEND cc_test_DEFINES "${cc_test_ANDROID_DEFINES} " )
39
- elseif (IOS )
40
- list (APPEND cc_test_SOURCES "${cc_test_IOS_SOURCES} " )
41
- list (APPEND cc_test_DEPENDS
42
- "${cc_test_IOS_DEPENDS} "
43
- "-framework CoreFoundation"
44
- "-framework Foundation"
45
- )
46
- list (APPEND cc_test_INCLUDES "${cc_test_IOS_INCLUDES} " )
47
- list (APPEND cc_test_DEFINES "${cc_test_IOS_DEFINES} " )
48
- else ()
49
- list (APPEND cc_test_SOURCES "${cc_test_DESKTOP_SOURCES} " )
50
- list (APPEND cc_test_DEPENDS "${cc_test_DESKTOP_DEPENDS} " )
51
- list (APPEND cc_test_INCLUDES "${cc_test_DESKTOP_INCLUDES} " )
52
- list (APPEND cc_test_DEFINES "${cc_test_DESKTOP_DEFINES} " )
35
+
36
+ add_executable (${name} ${cc_test_SOURCES} )
37
+ add_test (${name} ${name} )
38
+ target_include_directories (${name}
39
+ PRIVATE
40
+ ${FIREBASE_SOURCE_DIR}
41
+ ${cc_test_INCLUDES}
42
+ )
43
+ target_link_libraries (${name} PRIVATE ${cc_test_DEPENDS} )
44
+ target_compile_definitions (${name}
45
+ PRIVATE
46
+ -DINTERNAL_EXPERIMENTAL=1
47
+ ${cc_test_DEFINES}
48
+ )
49
+ endfunction ()
50
+
51
+ # cc_test_on_ios(
52
+ # target
53
+ # SOURCES sources...
54
+ # DEPENDS libraries...
55
+ # )
56
+ #
57
+ # Defines a new test executable target with the given target name, sources, and
58
+ # dependencies. Implicitly adds DEPENDS on gtest, gtest_main, Foundation and
59
+ # CoreFoundation frameworks.
60
+ function (cc_test_on_ios name )
61
+ if (NOT IOS )
62
+ return ()
53
63
endif ()
54
64
65
+ set (multi DEPENDS SOURCES INCLUDES DEFINES )
66
+ # Parse the arguments into cc_test_SOURCES and cc_test_DEPENDS.
67
+ cmake_parse_arguments (cc_test "" "" "${multi} " ${ARGN} )
68
+
69
+ list (APPEND cc_test_DEPENDS
70
+ gmock
71
+ gtest
72
+ gtest_main
73
+ "-framework CoreFoundation"
74
+ "-framework Foundation"
75
+ )
76
+
55
77
add_executable (${name} ${cc_test_SOURCES} )
56
78
add_test (${name} ${name} )
57
79
target_include_directories (${name}
@@ -65,4 +87,4 @@ function(cc_test name)
65
87
-DINTERNAL_EXPERIMENTAL=1
66
88
${cc_test_DEFINES}
67
89
)
68
- endfunction ()
90
+ endfunction ()
0 commit comments