|
|
@@ -151,156 +151,6 @@ function(firebase_ios_add_objc_test target host)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-
|
|
|
-# firebase_ios_cc_library(
|
|
|
-# target
|
|
|
-# SOURCES sources...
|
|
|
-# DEPENDS libraries...
|
|
|
-# [EXCLUDE_FROM_ALL]
|
|
|
-# )
|
|
|
-#
|
|
|
-# Defines a new library target with the given target name, sources, and
|
|
|
-# dependencies.
|
|
|
-function(firebase_ios_cc_library name)
|
|
|
- set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL HEADER_ONLY)
|
|
|
- set(multi DEPENDS SOURCES)
|
|
|
- cmake_parse_arguments(ccl "${flag}" "" "${multi}" ${ARGN})
|
|
|
-
|
|
|
- if(ccl_HEADER_ONLY)
|
|
|
- firebase_ios_generate_dummy_source(${name} ccl_SOURCES)
|
|
|
- endif()
|
|
|
-
|
|
|
- firebase_ios_maybe_remove_objc_sources(sources ${ccl_SOURCES})
|
|
|
- add_library(${name} ${sources})
|
|
|
-
|
|
|
- set(warnings_flag "")
|
|
|
- if(ccl_DISABLE_STRICT_WARNINGS)
|
|
|
- set(warnings_flag DISABLE_STRICT_WARNINGS)
|
|
|
- endif()
|
|
|
- firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
|
|
|
-
|
|
|
- target_compile_options(${name} PRIVATE ${FIREBASE_IOS_CXX_FLAGS})
|
|
|
- target_link_libraries(${name} PUBLIC ${ccl_DEPENDS})
|
|
|
-
|
|
|
- if(ccl_EXCLUDE_FROM_ALL)
|
|
|
- set_property(
|
|
|
- TARGET ${name}
|
|
|
- PROPERTY EXCLUDE_FROM_ALL ON
|
|
|
- )
|
|
|
- endif()
|
|
|
-endfunction()
|
|
|
-
|
|
|
-# firebase_ios_cc_select(
|
|
|
-# interface_library
|
|
|
-# CONDITION1 implementation_library1
|
|
|
-# [CONDITION2 implementation_library2 ...]
|
|
|
-# [DEFAULT implementation_library_default]
|
|
|
-# )
|
|
|
-#
|
|
|
-# Creates an INTERFACE library named `interface_library`.
|
|
|
-#
|
|
|
-# For each pair of condition and implementation_library, evaluates the condition
|
|
|
-# and if true makes that library an INTERFACE link library of
|
|
|
-# `interface_library`.
|
|
|
-#
|
|
|
-# If supplied, uses the `DEFAULT` implementation if no other condition matches.
|
|
|
-#
|
|
|
-# If no condition matches, fails the configuration cycle with an error message
|
|
|
-# indicating that no suitable implementation was found.
|
|
|
-function(firebase_ios_cc_select library_name)
|
|
|
- add_library(${library_name} INTERFACE)
|
|
|
-
|
|
|
- list(LENGTH ARGN length)
|
|
|
- if(length GREATER 0)
|
|
|
- math(EXPR length "${length} - 1")
|
|
|
- foreach(key RANGE 0 ${length} 2)
|
|
|
- math(EXPR value "${key} + 1")
|
|
|
- list(GET ARGN ${key} condition)
|
|
|
- list(GET ARGN ${value} impl_library)
|
|
|
-
|
|
|
- if((${condition} STREQUAL "DEFAULT") OR (${${condition}}))
|
|
|
- message("Using ${library_name} = ${impl_library}")
|
|
|
- target_link_libraries(
|
|
|
- ${library_name} INTERFACE ${impl_library}
|
|
|
- )
|
|
|
- return()
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
- endif()
|
|
|
-
|
|
|
- message(FATAL_ERROR "Could not find implementation for ${library_name}")
|
|
|
-endfunction()
|
|
|
-
|
|
|
-# firebase_ios_cc_binary(
|
|
|
-# target
|
|
|
-# SOURCES sources...
|
|
|
-# DEPENDS libraries...
|
|
|
-# [EXCLUDE_FROM_ALL]
|
|
|
-# )
|
|
|
-#
|
|
|
-# Defines a new executable target with the given target name, sources, and
|
|
|
-# dependencies.
|
|
|
-function(firebase_ios_cc_binary name)
|
|
|
- set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL)
|
|
|
- set(multi DEPENDS SOURCES)
|
|
|
- cmake_parse_arguments(ccb "${flag}" "" "${multi}" ${ARGN})
|
|
|
-
|
|
|
- firebase_ios_maybe_remove_objc_sources(sources ${ccb_SOURCES})
|
|
|
- add_executable(${name} ${sources})
|
|
|
-
|
|
|
- set(warnings_flag "")
|
|
|
- if(ccb_DISABLE_STRICT_WARNINGS)
|
|
|
- set(warnings_flag DISABLE_STRICT_WARNINGS)
|
|
|
- endif()
|
|
|
- firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
|
|
|
-
|
|
|
- target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
- target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
|
|
|
- target_link_libraries(${name} PRIVATE ${ccb_DEPENDS})
|
|
|
-
|
|
|
- if(ccb_EXCLUDE_FROM_ALL)
|
|
|
- set_property(
|
|
|
- TARGET ${name}
|
|
|
- PROPERTY EXCLUDE_FROM_ALL ON
|
|
|
- )
|
|
|
- endif()
|
|
|
-endfunction()
|
|
|
-
|
|
|
-# firebase_ios_cc_test(
|
|
|
-# target
|
|
|
-# SOURCES sources...
|
|
|
-# DEPENDS libraries...
|
|
|
-# )
|
|
|
-#
|
|
|
-# Defines a new test executable target with the given target name, sources, and
|
|
|
-# dependencies. Implicitly adds DEPENDS on GTest::GTest and GTest::Main.
|
|
|
-function(firebase_ios_cc_test name)
|
|
|
- if(NOT FIREBASE_IOS_BUILD_TESTS)
|
|
|
- return()
|
|
|
- endif()
|
|
|
-
|
|
|
- set(flag DISABLE_STRICT_WARNINGS)
|
|
|
- set(multi DEPENDS SOURCES)
|
|
|
- cmake_parse_arguments(cct "${flag}" "" "${multi}" ${ARGN})
|
|
|
-
|
|
|
- list(APPEND cct_DEPENDS GTest::GTest GTest::Main)
|
|
|
-
|
|
|
- firebase_ios_maybe_remove_objc_sources(sources ${cct_SOURCES})
|
|
|
- add_executable(${name} ${sources})
|
|
|
-
|
|
|
- set(warnings_flag "")
|
|
|
- if(cct_DISABLE_STRICT_WARNINGS)
|
|
|
- set(warnings_flag DISABLE_STRICT_WARNINGS)
|
|
|
- endif()
|
|
|
- firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
|
|
|
-
|
|
|
- add_test(${name} ${name})
|
|
|
-
|
|
|
- target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
- target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
|
|
|
- target_link_libraries(${name} PRIVATE ${cct_DEPENDS})
|
|
|
-endfunction()
|
|
|
-
|
|
|
# firebase_ios_add_fuzz_test(
|
|
|
# target
|
|
|
# DICTIONARY dict_file
|
|
|
@@ -348,77 +198,6 @@ function(firebase_ios_add_fuzz_test target)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-# maybe_remove_objc_sources(output_var sources...)
|
|
|
-#
|
|
|
-# 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(firebase_ios_maybe_remove_objc_sources output_var)
|
|
|
- unset(sources)
|
|
|
- foreach(source ${ARGN})
|
|
|
- get_filename_component(ext ${source} EXT)
|
|
|
- if(NOT APPLE AND ((ext STREQUAL ".m") OR (ext STREQUAL ".mm")))
|
|
|
- continue()
|
|
|
- endif()
|
|
|
- list(APPEND sources ${source})
|
|
|
- endforeach()
|
|
|
- set(${output_var} ${sources} PARENT_SCOPE)
|
|
|
-endfunction()
|
|
|
-
|
|
|
-# firebase_ios_add_compile_options(target [DISABLE_STRICT_WARNINGS] sources...)
|
|
|
-#
|
|
|
-# Adds FIREBASE_IOS_CXX_FLAGS or FIREBASE_IOS_CXX_FLAGS_STRICT to the compile
|
|
|
-# options of the given target depending on whether or not
|
|
|
-# DISABLE_STRICT_WARNINGS was passed.
|
|
|
-#
|
|
|
-# If any of the sources have filenames that indicate they are Objective-C adds
|
|
|
-# Either FIREBASE_IOS_OBJC_FLAGS or FIREBASE_IOS_OBJC_FLAGS_STRICT depending on
|
|
|
-# whether or not DISABLE_STRICT_WARNINGS was passed.
|
|
|
-function(firebase_ios_add_compile_options target)
|
|
|
- set(flag DISABLE_STRICT_WARNINGS)
|
|
|
- cmake_parse_arguments(aco "${flag}" "" "" ${ARGN})
|
|
|
-
|
|
|
- # Only set Objective-C flags if there's at least once source file to which
|
|
|
- # that applies.
|
|
|
- set(has_objc OFF)
|
|
|
-
|
|
|
- # Default to applying the strict warnings to all targets, but targets can
|
|
|
- # opt out.
|
|
|
- set(suffix _STRICT)
|
|
|
- if(aco_DISABLE_STRICT_WARNINGS)
|
|
|
- set(suffix "")
|
|
|
- endif()
|
|
|
-
|
|
|
- foreach(source ${ARGN})
|
|
|
- get_filename_component(ext ${source} EXT)
|
|
|
- if((ext STREQUAL ".m") OR (ext STREQUAL ".mm"))
|
|
|
- set(has_objc ON)
|
|
|
- endif()
|
|
|
- endforeach()
|
|
|
-
|
|
|
- target_compile_options(
|
|
|
- ${target}
|
|
|
- PRIVATE
|
|
|
- ${FIREBASE_IOS_CXX_FLAGS${suffix}}
|
|
|
- )
|
|
|
-
|
|
|
- if(has_objc)
|
|
|
- target_compile_options(
|
|
|
- ${target}
|
|
|
- PRIVATE
|
|
|
- ${FIREBASE_IOS_OBJC_FLAGS${suffix}}
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- target_include_directories(
|
|
|
- ${target}
|
|
|
- PRIVATE
|
|
|
- # Put the binary dir first so that the generated config.h trumps any one
|
|
|
- # generated statically by a Cocoapods-based build in the same source tree.
|
|
|
- ${FIREBASE_BINARY_DIR}
|
|
|
- ${FIREBASE_SOURCE_DIR}
|
|
|
- )
|
|
|
-endfunction()
|
|
|
-
|
|
|
# firebase_ios_add_alias(alias_target actual_target)
|
|
|
#
|
|
|
# Adds a library alias target `alias_target` if it does not already exist,
|
|
|
@@ -431,60 +210,6 @@ function(firebase_ios_add_alias ALIAS_TARGET ACTUAL_TARGET)
|
|
|
endif()
|
|
|
endfunction()
|
|
|
|
|
|
-function(firebase_ios_objc_test target)
|
|
|
- if(NOT APPLE OR NOT FIREBASE_IOS_BUILD_TESTS)
|
|
|
- return()
|
|
|
- endif()
|
|
|
-
|
|
|
- set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL)
|
|
|
- set(single HOST VERSION WORKING_DIRECTORY)
|
|
|
- set(multi DEPENDS DEFINES HEADERS INCLUDES SOURCES)
|
|
|
- cmake_parse_arguments(ot "${flag}" "${single}" "${multi}" ${ARGN})
|
|
|
-
|
|
|
- xctest_add_bundle(
|
|
|
- ${target}
|
|
|
- ${ot_HOST}
|
|
|
- ${ot_SOURCES}
|
|
|
- )
|
|
|
-
|
|
|
- set(warnings_flag "")
|
|
|
- if(ot_DISABLE_STRICT_WARNINGS)
|
|
|
- set(warnings_flag DISABLE_STRICT_WARNINGS)
|
|
|
- endif()
|
|
|
- firebase_ios_add_compile_options(${target} ${warnings_flag} ${ot_SOURCES})
|
|
|
-
|
|
|
- target_compile_options(${target} PRIVATE ${FIREBASE_CXX_FLAGS})
|
|
|
- target_link_libraries(${target} PRIVATE ${ot_DEPENDS})
|
|
|
-
|
|
|
- xctest_add_test(
|
|
|
- ${target}
|
|
|
- ${target}
|
|
|
- )
|
|
|
-
|
|
|
- if(ot_WORKING_DIRECTORY)
|
|
|
- set_property(
|
|
|
- TEST ${target} PROPERTY
|
|
|
- WORKING_DIRECTORY ${ot_WORKING_DIRECTORY}
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- if(WITH_ASAN)
|
|
|
- set_property(
|
|
|
- TEST ${target} APPEND PROPERTY
|
|
|
- ENVIRONMENT
|
|
|
- DYLD_INSERT_LIBRARIES=${CLANG_ASAN_DYLIB}
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- if(WITH_TSAN)
|
|
|
- set_property(
|
|
|
- TEST ${target} APPEND PROPERTY
|
|
|
- ENVIRONMENT
|
|
|
- DYLD_INSERT_LIBRARIES=${CLANG_TSAN_DYLIB}
|
|
|
- )
|
|
|
- endif()
|
|
|
-endfunction()
|
|
|
-
|
|
|
# firebase_ios_generate_dummy_source(target, sources_list)
|
|
|
#
|
|
|
# Generates a dummy source file containing a single symbol, suitable for use as
|