|
|
@@ -1,4 +1,4 @@
|
|
|
-# Copyright 2017 Google
|
|
|
+# Copyright 2017 Google LLC
|
|
|
#
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
@@ -15,7 +15,7 @@
|
|
|
include(CMakeParseArguments)
|
|
|
include(FindASANDylib)
|
|
|
|
|
|
-# cc_library(
|
|
|
+# firebase_ios_cc_library(
|
|
|
# target
|
|
|
# SOURCES sources...
|
|
|
# DEPENDS libraries...
|
|
|
@@ -24,18 +24,19 @@ include(FindASANDylib)
|
|
|
#
|
|
|
# Defines a new library target with the given target name, sources, and
|
|
|
# dependencies.
|
|
|
-function(cc_library name)
|
|
|
+function(firebase_ios_cc_library name)
|
|
|
set(flag EXCLUDE_FROM_ALL HEADER_ONLY)
|
|
|
set(multi DEPENDS SOURCES)
|
|
|
cmake_parse_arguments(ccl "${flag}" "" "${multi}" ${ARGN})
|
|
|
|
|
|
if(ccl_HEADER_ONLY)
|
|
|
- generate_dummy_source(${name} ccl_SOURCES)
|
|
|
+ firebase_ios_generate_dummy_source(${name} ccl_SOURCES)
|
|
|
endif()
|
|
|
|
|
|
- maybe_remove_objc_sources(sources ${ccl_SOURCES})
|
|
|
+ firebase_ios_maybe_remove_objc_sources(sources ${ccl_SOURCES})
|
|
|
add_library(${name} ${sources})
|
|
|
- add_objc_flags(${name} ${sources})
|
|
|
+ firebase_ios_add_objc_flags(${name} ${sources})
|
|
|
+
|
|
|
target_include_directories(
|
|
|
${name}
|
|
|
PUBLIC
|
|
|
@@ -45,7 +46,7 @@ function(cc_library name)
|
|
|
${FIREBASE_SOURCE_DIR}
|
|
|
)
|
|
|
|
|
|
- target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
+ target_compile_options(${name} PRIVATE ${FIREBASE_IOS_CXX_FLAGS})
|
|
|
target_link_libraries(${name} PUBLIC ${ccl_DEPENDS})
|
|
|
|
|
|
if(ccl_EXCLUDE_FROM_ALL)
|
|
|
@@ -56,7 +57,7 @@ function(cc_library name)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# cc_select(
|
|
|
+# firebase_ios_cc_select(
|
|
|
# interface_library
|
|
|
# CONDITION1 implementation_library1
|
|
|
# [CONDITION2 implementation_library2 ...]
|
|
|
@@ -73,7 +74,7 @@ endfunction()
|
|
|
#
|
|
|
# If no condition matches, fails the configuration cycle with an error message
|
|
|
# indicating that no suitable implementation was found.
|
|
|
-function(cc_select library_name)
|
|
|
+function(firebase_ios_cc_select library_name)
|
|
|
add_library(${library_name} INTERFACE)
|
|
|
|
|
|
list(LENGTH ARGN length)
|
|
|
@@ -97,7 +98,7 @@ function(cc_select library_name)
|
|
|
message(FATAL_ERROR "Could not find implementation for ${library_name}")
|
|
|
endfunction()
|
|
|
|
|
|
-# cc_binary(
|
|
|
+# firebase_ios_cc_binary(
|
|
|
# target
|
|
|
# SOURCES sources...
|
|
|
# DEPENDS libraries...
|
|
|
@@ -106,14 +107,14 @@ endfunction()
|
|
|
#
|
|
|
# Defines a new executable target with the given target name, sources, and
|
|
|
# dependencies.
|
|
|
-function(cc_binary name)
|
|
|
+function(firebase_ios_cc_binary name)
|
|
|
set(flag EXCLUDE_FROM_ALL)
|
|
|
set(multi DEPENDS SOURCES)
|
|
|
cmake_parse_arguments(ccb "${flag}" "" "${multi}" ${ARGN})
|
|
|
|
|
|
- maybe_remove_objc_sources(sources ${ccb_SOURCES})
|
|
|
+ firebase_ios_maybe_remove_objc_sources(sources ${ccb_SOURCES})
|
|
|
add_executable(${name} ${sources})
|
|
|
- add_objc_flags(${name} ${sources})
|
|
|
+ firebase_ios_add_objc_flags(${name} ${sources})
|
|
|
|
|
|
target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
|
|
|
@@ -127,7 +128,7 @@ function(cc_binary name)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# cc_test(
|
|
|
+# firebase_ios_cc_test(
|
|
|
# target
|
|
|
# SOURCES sources...
|
|
|
# DEPENDS libraries...
|
|
|
@@ -135,7 +136,7 @@ endfunction()
|
|
|
#
|
|
|
# Defines a new test executable target with the given target name, sources, and
|
|
|
# dependencies. Implicitly adds DEPENDS on GTest::GTest and GTest::Main.
|
|
|
-function(cc_test name)
|
|
|
+function(firebase_ios_cc_test name)
|
|
|
if(NOT FIREBASE_IOS_BUILD_TESTS)
|
|
|
return()
|
|
|
endif()
|
|
|
@@ -145,9 +146,9 @@ function(cc_test name)
|
|
|
|
|
|
list(APPEND cct_DEPENDS GTest::GTest GTest::Main)
|
|
|
|
|
|
- maybe_remove_objc_sources(sources ${cct_SOURCES})
|
|
|
+ firebase_ios_maybe_remove_objc_sources(sources ${cct_SOURCES})
|
|
|
add_executable(${name} ${sources})
|
|
|
- add_objc_flags(${name} ${sources})
|
|
|
+ firebase_ios_add_objc_flags(${name} ${sources})
|
|
|
add_test(${name} ${name})
|
|
|
|
|
|
target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
@@ -155,7 +156,7 @@ function(cc_test name)
|
|
|
target_link_libraries(${name} PRIVATE ${cct_DEPENDS})
|
|
|
endfunction()
|
|
|
|
|
|
-# cc_fuzz_test(
|
|
|
+# firebase_ios_cc_fuzz_test(
|
|
|
# target
|
|
|
# DICTIONARY dict_file
|
|
|
# CORPUS corpus_dir
|
|
|
@@ -171,19 +172,19 @@ endfunction()
|
|
|
# and copies the CORPUS directory as '${target}_seed_corpus' after building the
|
|
|
# target. This naming convention is critical for OSS Fuzz build script to
|
|
|
# capture new fuzzing targets.
|
|
|
-function(cc_fuzz_test name)
|
|
|
+function(firebase_ios_cc_fuzz_test name)
|
|
|
# Finds the fuzzer library that is either provided by OSS Fuzz or libFuzzer
|
|
|
# that is manually built from sources.
|
|
|
find_package(Fuzzer REQUIRED)
|
|
|
|
|
|
- # Parse arguments of the cc_fuzz_test macro.
|
|
|
+ # Parse arguments of the firebase_ios_cc_fuzz_test macro.
|
|
|
set(single DICTIONARY CORPUS)
|
|
|
set(multi DEPENDS SOURCES)
|
|
|
cmake_parse_arguments(ccf "" "${single}" "${multi}" ${ARGN})
|
|
|
|
|
|
list(APPEND ccf_DEPENDS Fuzzer)
|
|
|
|
|
|
- cc_binary(
|
|
|
+ firebase_ios_cc_binary(
|
|
|
${name}
|
|
|
SOURCES ${ccf_SOURCES}
|
|
|
DEPENDS ${ccf_DEPENDS}
|
|
|
@@ -212,7 +213,7 @@ endfunction()
|
|
|
#
|
|
|
# Removes Objective-C/C++ sources from the given sources if not on an Apple
|
|
|
# platform. Stores the resulting list in the variable named by `output_var`.
|
|
|
-function(maybe_remove_objc_sources output_var)
|
|
|
+function(firebase_ios_maybe_remove_objc_sources output_var)
|
|
|
unset(sources)
|
|
|
foreach(source ${ARGN})
|
|
|
get_filename_component(ext ${source} EXT)
|
|
|
@@ -224,11 +225,11 @@ function(maybe_remove_objc_sources output_var)
|
|
|
set(${output_var} ${sources} PARENT_SCOPE)
|
|
|
endfunction()
|
|
|
|
|
|
-# add_objc_flags(target sources...)
|
|
|
+# firebase_ios_add_objc_flags(target sources...)
|
|
|
#
|
|
|
-# Adds OBJC_FLAGS to the compile options of the given target if any of the
|
|
|
-# sources have filenames that indicate they are Objective-C.
|
|
|
-function(add_objc_flags target)
|
|
|
+# Adds FIREBASE_IOS_OBJC_FLAGS to the compile options of the given target if
|
|
|
+# any of the sources have filenames that indicate they are Objective-C.
|
|
|
+function(firebase_ios_add_objc_flags target)
|
|
|
set(_has_objc OFF)
|
|
|
|
|
|
foreach(source ${ARGN})
|
|
|
@@ -242,7 +243,7 @@ function(add_objc_flags target)
|
|
|
target_compile_options(
|
|
|
${target}
|
|
|
PRIVATE
|
|
|
- ${OBJC_FLAGS}
|
|
|
+ ${FIREBASE_IOS_OBJC_FLAGS}
|
|
|
)
|
|
|
|
|
|
target_link_libraries(
|
|
|
@@ -253,23 +254,23 @@ function(add_objc_flags target)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# add_alias(alias_target actual_target)
|
|
|
+# firebase_ios_add_alias(alias_target actual_target)
|
|
|
#
|
|
|
# Adds a library alias target `alias_target` if it does not already exist,
|
|
|
# aliasing to the given `actual_target` target. This allows library dependencies
|
|
|
# to be specified uniformly in terms of the targets found in various
|
|
|
# find_package modules even if the library is being built internally.
|
|
|
-function(add_alias ALIAS_TARGET ACTUAL_TARGET)
|
|
|
+function(firebase_ios_add_alias ALIAS_TARGET ACTUAL_TARGET)
|
|
|
if(NOT TARGET ${ALIAS_TARGET})
|
|
|
add_library(${ALIAS_TARGET} ALIAS ${ACTUAL_TARGET})
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# objc_framework(
|
|
|
+# firebase_ios_objc_framework(
|
|
|
# target
|
|
|
# HEADERS headers...
|
|
|
# SOURCES sources...
|
|
|
-# INCLUDES inlude_directories...
|
|
|
+# INCLUDES include_directories...
|
|
|
# DEFINES macros...
|
|
|
# DEPENDS libraries...
|
|
|
# [EXCLUDE_FROM_ALL]
|
|
|
@@ -278,7 +279,7 @@ endfunction()
|
|
|
# Defines a new framework target with the given target name and parameters.
|
|
|
#
|
|
|
# If SOURCES is not included, a dummy file will be generated.
|
|
|
-function(objc_framework target)
|
|
|
+function(firebase_ios_objc_framework target)
|
|
|
if(APPLE)
|
|
|
set(flag SHARED EXCLUDE_FROM_ALL)
|
|
|
set(single VERSION)
|
|
|
@@ -286,7 +287,7 @@ function(objc_framework target)
|
|
|
cmake_parse_arguments(of "${flag}" "${single}" "${multi}" ${ARGN})
|
|
|
|
|
|
if (NOT cf_SOURCES)
|
|
|
- generate_dummy_source(${target} of_SOURCES)
|
|
|
+ firebase_ios_generate_dummy_source(${target} of_SOURCES)
|
|
|
endif()
|
|
|
|
|
|
if(of_SHARED)
|
|
|
@@ -300,7 +301,7 @@ function(objc_framework target)
|
|
|
${of_SOURCES}
|
|
|
)
|
|
|
|
|
|
- add_objc_flags(${target} ${of_SOURCES})
|
|
|
+ firebase_ios_add_objc_flags(${target} ${of_SOURCES})
|
|
|
|
|
|
set_property(TARGET ${target} PROPERTY PUBLIC_HEADER ${of_HEADERS})
|
|
|
set_property(TARGET ${target} PROPERTY FRAMEWORK ON)
|
|
|
@@ -321,8 +322,8 @@ function(objc_framework target)
|
|
|
INTERFACE
|
|
|
-F${CMAKE_CURRENT_BINARY_DIR}
|
|
|
PRIVATE
|
|
|
- ${FIREBASE_CXX_FLAGS}
|
|
|
- ${OBJC_FLAGS}
|
|
|
+ ${FIREBASE_IOS_CXX_FLAGS}
|
|
|
+ ${FIREBASE_IOS_OBJC_FLAGS}
|
|
|
-fno-autolink
|
|
|
-Wno-unused-parameter
|
|
|
)
|
|
|
@@ -363,7 +364,7 @@ function(objc_framework target)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-function(objc_test target)
|
|
|
+function(firebase_ios_objc_test target)
|
|
|
if(NOT APPLE OR NOT FIREBASE_IOS_BUILD_TESTS)
|
|
|
return()
|
|
|
endif()
|
|
|
@@ -379,7 +380,7 @@ function(objc_test target)
|
|
|
${ot_SOURCES}
|
|
|
)
|
|
|
|
|
|
- add_objc_flags(
|
|
|
+ firebase_ios_add_objc_flags(
|
|
|
${target}
|
|
|
${ot_SOURCES}
|
|
|
)
|
|
|
@@ -416,13 +417,13 @@ function(objc_test target)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# generate_dummy_source(name, sources_list)
|
|
|
+# firebase_ios_generate_dummy_source(name, sources_list)
|
|
|
#
|
|
|
# Generates a dummy source file containing a single symbol, suitable for use as
|
|
|
# a source file in when defining a header-only library.
|
|
|
#
|
|
|
# Appends the generated source file name to the list named by sources_list.
|
|
|
-macro(generate_dummy_source name sources_list)
|
|
|
+macro(firebase_ios_generate_dummy_source name sources_list)
|
|
|
set(__empty_header_only_file "${CMAKE_CURRENT_BINARY_DIR}/${name}_header_only_empty.cc")
|
|
|
|
|
|
if(NOT EXISTS ${__empty_header_only_file})
|