Skip to content

Commit 896a5df

Browse files
wilhuffschnecle
authored andcommitted
Shorten CMake Objective-C targets (#5323)
* Shorten firebase_firestore_example_app ... and: * Migrate to firebase_ios_add_executable * Use globs for specifying sources * Migrate Example/Tests/API to new CMake primitives * Migrate Example/Tests/Integration to new CMake primitives * Migrate Example/Tests/SpecTests to new CMake primitives * Migrate Example/Tests/Util to new CMake primitives Rename firebase_firestore_objc_test_util to firestore_objc_testing. * Migrate fuzzing to new CMake primitives Rewrite firebase_ios_cc_fuzz_test to match the other primitives. * Add firebase_ios_add_objc_test * Migrate Example/Benchmarks to new CMake primitives
1 parent 6e0b7e0 commit 896a5df

File tree

8 files changed

+172
-192
lines changed

8 files changed

+172
-192
lines changed

Firestore/Example/App/CMakeLists.txt

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,59 +17,36 @@ if(NOT APPLE)
1717
endif()
1818

1919
if(IOS)
20-
add_executable(
21-
firebase_firestore_example_app MACOSX_BUNDLE
22-
iOS/FIRAppDelegate.h
23-
iOS/FIRAppDelegate.m
24-
iOS/FIRViewController.h
25-
iOS/FIRViewController.m
26-
iOS/main.m
27-
)
28-
29-
target_compile_options(
30-
firebase_firestore_example_app
31-
PRIVATE ${FIREBASE_IOS_OBJC_FLAGS}
32-
)
20+
file(GLOB sources iOS/*.h iOS/*.m)
21+
firebase_ios_add_executable(firestore_objc_host_app MACOSX_BUNDLE ${sources})
3322

3423
target_link_libraries(
35-
firebase_firestore_example_app
36-
PRIVATE
37-
"-framework UIKit"
24+
firestore_objc_host_app PRIVATE
3825
"-framework Foundation"
26+
"-framework UIKit"
3927
)
4028

4129
set_target_properties(
42-
firebase_firestore_example_app PROPERTIES
30+
firestore_objc_host_app PROPERTIES
4331
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/iOS/Firestore-Info.plist
4432
RESOURCE GoogleService-Info.plist
4533
)
4634

4735
else()
4836
# Assume macOS
4937

50-
add_executable(
51-
firebase_firestore_example_app MACOSX_BUNDLE
52-
macOS/AppDelegate.h
53-
macOS/AppDelegate.m
54-
macOS/main.m
55-
)
56-
57-
target_compile_options(
58-
firebase_firestore_example_app
59-
PRIVATE ${FIREBASE_IOS_OBJC_FLAGS}
60-
)
38+
file(GLOB sources macOS/*.h macOS/*.m)
39+
firebase_ios_add_executable(firestore_objc_host_app MACOSX_BUNDLE ${sources})
6140

6241
target_link_libraries(
63-
firebase_firestore_example_app
64-
PRIVATE
42+
firestore_objc_host_app PRIVATE
6543
"-framework AppKit"
6644
"-framework Foundation"
6745
)
6846

6947
set_target_properties(
70-
firebase_firestore_example_app PROPERTIES
48+
firestore_objc_host_app PROPERTIES
7149
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/Info.plist
7250
RESOURCE GoogleService-Info.plist
7351
)
74-
7552
endif()

Firestore/Example/Benchmarks/CMakeLists.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if(FIREBASE_IOS_BUILD_BENCHMARKS AND APPLE)
16-
firebase_ios_cc_binary(
17-
firebase_firestore_remote_document_cache_benchmark
18-
SOURCES
19-
remote_document_cache_benchmark.mm
20-
DEPENDS
21-
FirebaseFirestore
22-
benchmark
23-
benchmark_main
24-
firestore_testutil
25-
)
15+
if(NOT FIREBASE_IOS_BUILD_BENCHMARKS OR NOT APPLE)
16+
return()
2617
endif()
18+
19+
firebase_ios_add_executable(
20+
firestore_remote_document_cache_benchmark
21+
remote_document_cache_benchmark.mm
22+
)
23+
24+
target_link_libraries(
25+
firestore_remote_document_cache_benchmark PRIVATE
26+
FirebaseFirestore
27+
benchmark
28+
benchmark_main
29+
firestore_testutil
30+
)

Firestore/Example/Tests/API/CMakeLists.txt

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,18 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if(APPLE)
16-
firebase_ios_objc_test(
17-
firebase_firestore_objc_api_test
18-
HOST firebase_firestore_example_app
19-
SOURCES
20-
FIRCollectionReferenceTests.mm
21-
FIRDocumentReferenceTests.mm
22-
FIRDocumentSnapshotTests.mm
23-
FIRFieldPathTests.mm
24-
FIRFieldValueTests.mm
25-
FIRFirestoreTests.mm
26-
FIRGeoPointTests.mm
27-
FIRQuerySnapshotTests.mm
28-
FIRQueryUnitTests.mm
29-
FIRSnapshotMetadataTests.mm
30-
FIRTimestampTest.m
31-
FSTAPIHelpers.h
32-
FSTAPIHelpers.mm
33-
FSTUserDataConverterTests.mm
34-
DEPENDS
35-
FirebaseFirestore
36-
firebase_firestore_objc_test_util
37-
)
38-
endif(APPLE)
15+
if(NOT FIREBASE_IOS_BUILD_TESTS OR NOT APPLE)
16+
return()
17+
endif()
18+
19+
file(GLOB sources *.h *.mm)
20+
firebase_ios_add_objc_test(
21+
firestore_objc_api_test
22+
firestore_objc_host_app
23+
${sources}
24+
)
25+
target_link_libraries(
26+
firestore_objc_api_test PRIVATE
27+
FirebaseFirestore
28+
firestore_objc_testing
29+
)

Firestore/Example/Tests/Integration/CMakeLists.txt

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,21 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if(NOT APPLE)
15+
if(NOT FIREBASE_IOS_BUILD_TESTS OR NOT APPLE)
1616
return()
1717
endif()
1818

19-
firebase_ios_objc_test(
20-
firebase_firestore_objc_integration_test
21-
HOST firebase_firestore_example_app
22-
SOURCES
23-
FSTSmokeTests.mm
24-
FSTDatastoreTests.mm
25-
FSTTransactionTests.mm
26-
API/FIRArrayTransformTests.mm
27-
API/FIRFieldsTests.mm
28-
API/FIRNumericTransformTests.mm
29-
API/FIRTypeTests.mm
30-
API/FIRCursorTests.mm
31-
API/FIRFirestoreSourceTests.mm
32-
API/FIRQueryTests.mm
33-
API/FIRValidationTests.mm
34-
API/FIRDatabaseTests.mm
35-
API/FIRListenerRegistrationTests.mm
36-
API/FIRServerTimestampTests.mm
37-
API/FIRWriteBatchTests.mm
38-
DEPENDS
39-
FirebaseFirestore
40-
firebase_firestore_objc_test_util
19+
file(GLOB sources *.h *.mm API/*.h API/*.mm)
20+
21+
firebase_ios_add_objc_test(
22+
firestore_objc_integration_test
23+
firestore_objc_host_app
24+
${sources}
25+
)
26+
27+
target_link_libraries(
28+
firestore_objc_integration_test PRIVATE
29+
FirebaseFirestore
30+
firestore_core
31+
firestore_objc_testing
4132
)

Firestore/Example/Tests/SpecTests/CMakeLists.txt

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
if(APPLE)
16-
firebase_ios_objc_test(
17-
firebase_firestore_objc_spec_test
18-
HOST firebase_firestore_example_app
19-
SOURCES
20-
FSTLevelDBSpecTests.mm
21-
FSTMemorySpecTests.mm
22-
FSTMockDatastore.h
23-
FSTMockDatastore.mm
24-
FSTSpecTests.h
25-
FSTSpecTests.mm
26-
FSTSyncEngineTestDriver.h
27-
FSTSyncEngineTestDriver.mm
28-
DEPENDS
29-
FirebaseFirestore
30-
firebase_firestore_objc_test_util
31-
firestore_local_testing
32-
firestore_remote_testing
33-
# Force this to run in the project-wide binary directory so that relative
34-
# paths used during compilation are usable.
35-
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
36-
)
37-
endif(APPLE)
15+
if(NOT FIREBASE_IOS_BUILD_TESTS OR NOT APPLE)
16+
return()
17+
endif()
18+
19+
file(GLOB sources *.h *.mm)
20+
21+
firebase_ios_add_objc_test(
22+
firestore_objc_spec_test
23+
firestore_objc_host_app
24+
${sources}
25+
)
26+
27+
target_link_libraries(
28+
firestore_objc_spec_test PRIVATE
29+
FirebaseFirestore
30+
firestore_local_testing
31+
firestore_objc_testing
32+
firestore_remote_testing
33+
)
34+
35+
# Force this to run in the project-wide binary directory so that relative
36+
# paths used during compilation are usable.
37+
set_property(
38+
TEST firestore_objc_spec_test PROPERTY
39+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
40+
)

Firestore/Example/Tests/Util/CMakeLists.txt

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,15 @@ if(NOT FIREBASE_IOS_BUILD_TESTS OR NOT APPLE)
1616
return()
1717
endif()
1818

19-
firebase_ios_cc_library(
20-
firebase_firestore_objc_test_util
21-
SOURCES
22-
FIRFirestore+Testing.h
23-
FSTEventAccumulator.h
24-
FSTEventAccumulator.mm
25-
FSTHelpers.h
26-
FSTHelpers.mm
27-
FSTIntegrationTestCase.h
28-
FSTIntegrationTestCase.mm
29-
XCTestCase+Await.h
30-
XCTestCase+Await.mm
31-
DEPENDS
32-
${XCTest_LIBRARIES}
33-
FirebaseFirestore
34-
GTest::GTest
35-
absl_any
36-
absl_strings
37-
firebase_firestore_auth
38-
firebase_firestore_core
39-
firebase_firestore_local
40-
firebase_firestore_model
41-
firebase_firestore_nanopb
42-
firebase_firestore_remote
43-
firebase_firestore_nanopb
44-
firestore_protos_nanopb
45-
firestore_remote_testing
46-
firestore_testutil
19+
file(GLOB sources *.h *.mm)
20+
firebase_ios_add_library(firestore_objc_testing ${sources})
21+
22+
target_link_libraries(
23+
firestore_objc_testing PUBLIC
24+
${XCTest_LIBRARIES}
25+
FirebaseFirestore
26+
GTest::GTest
27+
absl_strings
28+
firestore_remote_testing
29+
firestore_testutil
4730
)

Firestore/fuzzing/CMakeLists.txt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,60 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Builds all fuzzing targets using firebase_ios_cc_fuzz_test build rule, which
15+
# Builds all fuzzing targets using firebase_ios_add_fuzz_test build rule, which
1616
# copies the provided dictionary and corpus to the destination directory. A
17-
# fuzzing target that tests xyz must be called 'xyz_fuzzer'. The copied
18-
# dictionary will be called 'xyz_fuzzer.dict' and its corpus
19-
# 'xyz_fuzzer_seed_corpus'. See cc_rules.cmake for more information.
17+
# fuzzing target that tests xyz must be called 'firestore_xyz_fuzzer'. The copied
18+
# dictionary will be called 'firestore_xyz_fuzzer.dict' and its corpus
19+
# 'firestore_xyz_fuzzer_seed_corpus'. See cc_rules.cmake for more information.
2020

2121
if(NOT FUZZING)
2222
return()
2323
endif()
2424

25+
# Finds the fuzzer library that is either provided by OSS Fuzz or libFuzzer that
26+
# is manually built from sources.
27+
find_package(Fuzzer REQUIRED)
28+
2529
# Use the fuzzing resources directory from the iOS fuzz tests.
26-
set(fuzzing_resources ${FIREBASE_SOURCE_DIR}/Firestore/Example/FuzzTests/FuzzingResources)
30+
set(
31+
fuzzing_resources
32+
${FIREBASE_SOURCE_DIR}/Firestore/Example/FuzzTests/FuzzingResources
33+
)
34+
35+
link_libraries(firestore_core)
36+
2737

2838
# Serializer fuzzing target.
2939
# TODO(minafarid): Do not define a CORPUS in this target, but rather generate
3040
# the serializer corpus by converting the text protos from the serializer
3141
# corpus in the iOS FuzzingResources to binary protos. This conversion requires
3242
# the protoc binary that is not currently available.
33-
firebase_ios_cc_fuzz_test(
34-
serializer_fuzzer
43+
firebase_ios_add_fuzz_test(
44+
firestore_serializer_fuzzer
3545
DICTIONARY ${fuzzing_resources}/Serializer/serializer.dictionary
3646
CORPUS ${fuzzing_resources}/Serializer/Corpus/BinaryProtos
37-
SOURCES serializer_fuzzer.cc
38-
DEPENDS firebase_firestore_remote
47+
serializer_fuzzer.cc
3948
)
4049

41-
4250
# FieldPath fuzzing target.
43-
firebase_ios_cc_fuzz_test(
44-
fieldpath_fuzzer
51+
firebase_ios_add_fuzz_test(
52+
firestore_fieldpath_fuzzer
4553
DICTIONARY ${fuzzing_resources}/FieldPath/fieldpath.dictionary
4654
CORPUS ${fuzzing_resources}/FieldPath/Corpus
47-
SOURCES fieldpath_fuzzer.cc
48-
DEPENDS firebase_firestore_model
55+
fieldpath_fuzzer.cc
4956
)
5057

5158
# ResourcePath fuzzing target. Use the same corpus and dict as FieldPath.
52-
firebase_ios_cc_fuzz_test(
53-
resourcepath_fuzzer
59+
firebase_ios_add_fuzz_test(
60+
firestore_resourcepath_fuzzer
5461
DICTIONARY ${fuzzing_resources}/FieldPath/fieldpath.dictionary
5562
CORPUS ${fuzzing_resources}/FieldPath/Corpus
56-
SOURCES resourcepath_fuzzer.cc
57-
DEPENDS firebase_firestore_model
63+
resourcepath_fuzzer.cc
5864
)
5965

6066
# LevelDB fuzzer.
61-
firebase_ios_cc_fuzz_test(
62-
leveldb_fuzzer
67+
firebase_ios_add_fuzz_test(
68+
firestore_leveldb_fuzzer
6369
DICTIONARY ${fuzzing_resources}/LevelDb/leveldb.dictionary
64-
SOURCES leveldb_fuzzer.cc
65-
DEPENDS firebase_firestore_local_persistence_leveldb
70+
leveldb_fuzzer.cc
6671
)

0 commit comments

Comments
 (0)