Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The SDK uses CMake for C++ compilation and Gradle for Android-specific parts.
2. Run CMake to configure: `cmake ..`
* For Desktop: Run as is. You can use BORINGSSL instead of OpenSSL (for fewer
system dependencies with the `-DFIREBASE_USE_BORINGSSL=YES` parameter.
* For iOS, include the `-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/ios.cmake`
* For iOS, include the `-DCMAKE_SYSTEM_NAME=iOS`
parameter. This requires running on a Mac build machine.
3. Build specific targets: `cmake --build . --target firebase_analytics`
(replace `firebase_analytics` with the desired library).
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@ if(FIREBASE_CPP_BUILD_TESTS OR FIREBASE_CPP_BUILD_STUB_TESTS)
${CMAKE_BINARY_DIR})
endif()

if (PLATFORM STREQUAL TVOS OR PLATFORM STREQUAL SIMULATOR_TVOS)
if(PLATFORM STREQUAL TVOS OR PLATFORM STREQUAL SIMULATOR_TVOS OR CMAKE_SYSTEM_NAME STREQUAL "tvOS")
# UMP is not supported on tvOS.
set(FIREBASE_INCLUDE_UMP OFF)
endif()

# CMake 3.14+ native iOS support sets CMAKE_SYSTEM_NAME to iOS, 3.21+ for tvOS
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS")
set(IOS ON CACHE BOOL "")
set(FIREBASE_IOS_BUILD ON CACHE BOOL "")
endif()

# Occasionally ANDROID is not being set correctly when invoked by gradle, so
# set it manually if ANDROID_NDK has been defined.
if(DEFINED ANDROID_NDK)
Expand Down
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,22 @@ Currently, the third party libraries that can be provided this way are:
| ZLIB |

#### Building with CMake for iOS
The Firebase C++ SDK comes with a CMake config file to build the library for
iOS platforms, [cmake/toolchains/ios.cmake](/cmake/toolchains/ios.cmake). In
order to build with it, when running the CMake configuration pass it in with
the CMAKE_TOOLCHAIN_FILE definition. For example, to build the Auth
library for iOS, you could run the following commands:
Starting with CMake 3.14, iOS is supported natively by CMake. To build for iOS, set the `CMAKE_SYSTEM_NAME` to `iOS`.
For example, to build the Auth library for iOS, you could run the following commands:

``` bash
mkdir ios_build && cd ios_build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/ios.cmake ..
cmake -DCMAKE_SYSTEM_NAME=iOS ..
cmake --build . --target firebase_auth
```

#### Building with CMake for tvOS
The Firebase C++ SDK comes with a CMake config file to build the library for
tvOS platforms, [cmake/toolchains/apple.toolchain.cmake](/cmake/toolchains/apple.toolchain.cmake). In
order to build with it, when running the CMake configuration pass it in with
the CMAKE_TOOLCHAIN_FILE definition. For example, to build the Auth
library for tvOS, you could run the following commands:
Starting with CMake 3.14, tvOS is supported natively by CMake. To build for tvOS, set the `CMAKE_SYSTEM_NAME` to `tvOS`.
For example, to build the Auth library for tvOS, you could run the following commands:

``` bash
mkdir tvos_build && cd tvos_build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/apple.toolchain.cmake -DPLATFORM=TVOS ..
cmake -DCMAKE_SYSTEM_NAME=tvOS ..
cmake --build . --target firebase_auth
```

Expand Down
12 changes: 7 additions & 5 deletions build_scripts/ios/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cmakeBuild=true

# check options
IFS=',' # split options on ',' characters
while getopts ":b:s:a:t:g:ch" opt; do
while getopts ":b:s:p:a:t:g:ch" opt; do
case $opt in
h)
usage
Expand Down Expand Up @@ -121,17 +121,19 @@ frameworkspath="frameworks/ios"
if ${generateMakefiles}; then
for platform in ${platforms[@]}; do
for arch in ${architectures[@]}; do
sysroot_arg=""
if [[ "${platform}" == "device" && " ${DEVICE_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
toolchain="cmake/toolchains/ios.cmake"
sysroot_arg="" # Default iphoneos sysroot is correct for iOS devices
elif [[ "${platform}" == "simulator" && " ${SIMULATOR_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
toolchain="cmake/toolchains/ios_simulator.cmake"
sysroot_arg="-DCMAKE_OSX_SYSROOT=iphonesimulator" # Must specify sysroot for simulator, especially for x86_64
else
continue
continue # Skip invalid platform/OS combinations
fi

echo "generate Makefiles start"
mkdir -p ${buildpath}/ios_build_file/${platform}-${arch} && cd ${buildpath}/ios_build_file/${platform}-${arch}
cmake -DCMAKE_TOOLCHAIN_FILE=${sourcepath}/${toolchain} \
cmake -DCMAKE_SYSTEM_NAME=iOS \
${sysroot_arg} \
-DCMAKE_OSX_ARCHITECTURES=${arch} \
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${buildpath}/${frameworkspath}/${platform}-${arch} \
${sourcepath}
Expand Down
12 changes: 7 additions & 5 deletions build_scripts/tvos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cmakeBuild=true

# check options
IFS=',' # split options on ',' characters
while getopts ":b:s:a:t:g:ch" opt; do
while getopts ":b:s:p:a:t:g:ch" opt; do
case $opt in
h)
usage
Expand Down Expand Up @@ -123,18 +123,20 @@ if ${generateMakefiles}; then
for platform in ${platforms[@]}; do
for arch in ${architectures[@]}; do
if [[ "${platform}" == "device" && " ${DEVICE_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
toolchain="cmake/toolchains/apple.toolchain.cmake"
# Device build
:
elif [[ "${platform}" == "simulator" && " ${SIMULATOR_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
toolchain="cmake/toolchains/apple.toolchain.cmake"
tvos_toolchain_platform="SIMULATOR_TVOS"
sysroot_arg="-DCMAKE_OSX_SYSROOT=appletvsimulator"
else
continue
fi

echo "generate Makefiles start"
mkdir -p ${buildpath}/tvos_build_file/${platform}-${arch} && cd ${buildpath}/tvos_build_file/${platform}-${arch}
cmake -DCMAKE_TOOLCHAIN_FILE=${sourcepath}/${toolchain} \
-DPLATFORM=${tvos_toolchain_platform} \
cmake -DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES=${arch} \
${sysroot_arg} \
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${buildpath}/${frameworkspath}/${platform}-${arch} \
${sourcepath}
echo "generate Makefiles end"
Expand Down
Loading
Loading