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
3737 "Include the Firebase Remote Config library." ON )
3838option (FIREBASE_INCLUDE_STORAGE
3939 "Include the Cloud Storage for Firebase library." ON )
40+ option (FIREBASE_CPP_BUILD_TESTS
41+ "Enable the Firebase C++ Build Tests." OFF )
4042
4143list (INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR} /cmake)
4244include (external_rules)
4345
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+
4454# Occasionally ANDROID is not being set correctly when invoked by gradle, so
4555# set it manually if ANDROID_NDK has been defined.
4656if (DEFINED ANDROID_NDK)
@@ -90,6 +100,10 @@ set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
90100# so that the sub Firebase projects can depend upon it if necessary.
91101add_external_library(flatbuffers)
92102
103+ if (FIREBASE_CPP_BUILD_TESTS)
104+ add_external_library(googletest)
105+ endif ()
106+
93107# Some of the external libraries are not used for mobile.
94108if (NOT ANDROID AND NOT IOS)
95109 # 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)
2323list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} )
2424
2525include (flatbuffers)
26+ include (googletest)
2627
2728# Some of the external dependencies are not needed for mobile.
2829if (${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)
6161 -DFIREBASE_EXTERNAL_PLATFORM=${external_platform}
6262 -DDOWNLOAD_CURL=${DOWNLOAD_CURL}
6363 -DDOWNLOAD_FLATBUFFERS=${DOWNLOAD_FLATBUFFERS}
64+ -DDOWNLOAD_GOOGLETEST=${FIREBASE_CPP_BUILD_TESTS}
6465 -DDOWNLOAD_LIBUV=${DOWNLOAD_LIBUV}
6566 -DDOWNLOAD_NANOPB=${DOWNLOAD_NANOPB}
6667 -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