File tree Expand file tree Collapse file tree 6 files changed +120
-0
lines changed Expand file tree Collapse file tree 6 files changed +120
-0
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,20 @@ option(FIREBASE_INCLUDE_REMOTE_CONFIG
37
37
"Include the Firebase Remote Config library." ON )
38
38
option (FIREBASE_INCLUDE_STORAGE
39
39
"Include the Cloud Storage for Firebase library." ON )
40
+ option (FIREBASE_CPP_BUILD_TESTS
41
+ "Enable the Firebase C++ Build Tests." OFF )
40
42
41
43
list (INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR} /cmake )
42
44
include (external_rules )
43
45
46
+ if (FIREBASE_CPP_BUILD_TESTS )
47
+ enable_testing ()
48
+ include (test_rules )
49
+ # Copy the custom CTest file into the binary directory, so that it is used.
50
+ configure_file (${CMAKE_CURRENT_LIST_DIR} /cmake/CTestCustom.cmake
51
+ ${CMAKE_BINARY_DIR} )
52
+ endif ()
53
+
44
54
# Occasionally ANDROID is not being set correctly when invoked by gradle, so
45
55
# set it manually if ANDROID_NDK has been defined.
46
56
if (DEFINED ANDROID_NDK )
@@ -90,6 +100,10 @@ set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
90
100
# so that the sub Firebase projects can depend upon it if necessary.
91
101
add_external_library (flatbuffers )
92
102
103
+ if (FIREBASE_CPP_BUILD_TESTS )
104
+ add_external_library (googletest )
105
+ endif ()
106
+
93
107
# Some of the external libraries are not used for mobile.
94
108
if (NOT ANDROID AND NOT IOS )
95
109
# Build curl as a static library
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 Google
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Define the tests that need to be ignored.
16
+ set (CTEST_CUSTOM_TESTS_IGNORE
17
+ ${CTEST_CUSTOM_TESTS_IGNORE}
18
+ # Tests from libuv, that can't be disabled normally.
19
+ uv_test
20
+ uv_test_a
21
+ # Tests from zlib, that can't be disabled normally.
22
+ example
23
+ example64
24
+ )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ project(Firebase-cpp-download C CXX)
23
23
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} )
24
24
25
25
include (flatbuffers )
26
+ include (googletest )
26
27
27
28
# Some of the external dependencies are not needed for mobile.
28
29
if (${FIREBASE_EXTERNAL_PLATFORM} STREQUAL "DESKTOP" )
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 Google
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ include (ExternalProject )
16
+
17
+ if (TARGET googletest OR NOT DOWNLOAD_GOOGLETEST )
18
+ return ()
19
+ endif ()
20
+
21
+ # Googletest 1.8.0 fails to build on VS 2017:
22
+ # https://github.com/google/googletest/issues/1111.
23
+ #
24
+ # No release has been made since, so just pick a commit since then.
25
+ set (commit ba96d0b1161f540656efdaed035b3c062b60e006 ) # master@{2018-07-10}
26
+
27
+ ExternalProject_Add (
28
+ googletest
29
+
30
+ DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
31
+ DOWNLOAD_NAME googletest-${commit}.tar.gz
32
+ URL https://github.com/google/googletest/archive/${commit}.tar.gz
33
+ URL_HASH SHA256=949c556896cf31ed52e53449e17a1276b8b26d3ee5932f5ca49ee929f4b35c51
34
+
35
+ PREFIX ${PROJECT_BINARY_DIR}
36
+
37
+ CONFIGURE_COMMAND ""
38
+ BUILD_COMMAND ""
39
+ INSTALL_COMMAND ""
40
+ TEST_COMMAND ""
41
+ )
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ function(download_external_sources)
61
61
-DFIREBASE_EXTERNAL_PLATFORM=${external_platform}
62
62
-DDOWNLOAD_CURL=${DOWNLOAD_CURL}
63
63
-DDOWNLOAD_FLATBUFFERS=${DOWNLOAD_FLATBUFFERS}
64
+ -DDOWNLOAD_GOOGLETEST=${FIREBASE_CPP_BUILD_TESTS}
64
65
-DDOWNLOAD_LIBUV=${DOWNLOAD_LIBUV}
65
66
-DDOWNLOAD_NANOPB=${DOWNLOAD_NANOPB}
66
67
-DDOWNLOAD_UWEBSOCKETS=${DOWNLOAD_UWEBSOCKETS}
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 Google
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ include (CMakeParseArguments )
16
+
17
+ # cc_test(
18
+ # target
19
+ # SOURCES sources...
20
+ # DEPENDS libraries...
21
+ # )
22
+ #
23
+ # Defines a new test executable target with the given target name, sources, and
24
+ # dependencies. Implicitly adds DEPENDS on gtest and gtest_main.
25
+ function (cc_test name )
26
+ set (multi DEPENDS SOURCES )
27
+ # Parse the arguments into cc_test_SOURCES and cc_test_DEPENDS.
28
+ cmake_parse_arguments (cc_test "" "" "${multi} " ${ARGN} )
29
+
30
+ list (APPEND cc_test_DEPENDS gtest gtest_main )
31
+
32
+ add_executable (${name} ${cc_test_SOURCES} )
33
+ add_test (${name} ${name} )
34
+ target_include_directories (${name}
35
+ PRIVATE
36
+ ${FIREBASE_SOURCE_DIR}
37
+ )
38
+ target_link_libraries (${name} PRIVATE ${cc_test_DEPENDS} )
39
+ endfunction ()
You can’t perform that action at this time.
0 commit comments