Skip to content

Commit ac41afc

Browse files
committed
Add a toolchain and logic for building 32-bit Linux libraries
Adds a toolchain file that defines what is needed to build the libraries on Linux for a 32-bit, i386, architecture, and move existing toolchain files, into a subfolder. Adds special logic for libsecret, which always tries to include glib for x86_64 if it is present, instead of i386. PiperOrigin-RevId: 291193156
1 parent 8f2716f commit ac41afc

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ Currently, the third party libraries that can be provided this way are:
190190

191191
#### Building with CMake for iOS
192192
The Firebase C++ SDK comes with a CMake config file to build the library for
193-
iOS platforms, [cmake/ios.cmake](/cmake/ios.cmake). In order to build with it,
194-
when running the CMake configuration pass it in with the CMAKE_TOOLCHAIN_FILE
195-
definition. For example, to build the Analytics library for iOS, you could run
196-
the following commands:
193+
iOS platforms, [cmake/toolchains/ios.cmake](/cmake/toolchains/ios.cmake). In
194+
order to build with it, when running the CMake configuration pass it in with
195+
the CMAKE_TOOLCHAIN_FILE definition. For example, to build the Analytics
196+
library for iOS, you could run the following commands:
197197

198198
``` bash
199199
mkdir ios_build && cd ios_build
200-
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.cmake ..
200+
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/ios.cmake ..
201201
cmake --build . --target firebase_analytics
202202
```
203203

app/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ else()
191191
systems via: \
192192
apt-get install libsecret-1-dev")
193193
endif()
194+
# If building for 32 bit, the include directories might need to be fixed.
195+
if("${CMAKE_CXX_FLAGS}" MATCHES "-m32")
196+
string(REGEX REPLACE "x86_64" "i386"
197+
LIBSECRET_INCLUDE_DIRS "${LIBSECRET_INCLUDE_DIRS}")
198+
endif()
194199
set(app_desktop_extra_SRCS
195200
src/secure/user_secure_linux_internal.cc
196201
src/locale.cc

cmake/cpp_pack.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ if(${FIREBASE_CPP_BUILD_PACKAGE})
4646
elseif(APPLE)
4747
set(FIREBASE_LIB_CONFIG_PATH "darwin")
4848
else()
49-
set(FIREBASE_LIB_CONFIG_PATH "linux")
49+
# Check if building for 32 bit
50+
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
51+
if("${CMAKE_CXX_FLAGS}" MATCHES "-m32")
52+
set(FIREBASE_LIB_CONFIG_PATH "linux/i386")
53+
else()
54+
set(FIREBASE_LIB_CONFIG_PATH "linux/x86_64")
55+
endif()
5056
endif()
5157
endif()
5258

File renamed without changes.
File renamed without changes.

cmake/toolchains/linux_32.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Toolchain file for building 32-bit Linux libraries
2+
3+
set(CMAKE_C_FLAGS -m32)
4+
set(CMAKE_CXX_FLAGS -m32)
5+
set(CMAKE_LIBRARY_PATH "/usr/lib/i386-linux-gnu")

test_mac_ios.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cd mac_ios_build
2727

2828
# Configure cmake with tests enabled
2929
# and disable use of libsecret due to not working on kokoro builders
30-
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.cmake .. -DFIREBASE_CPP_BUILD_TESTS=ON -DFIREBASE_FORCE_FAKE_SECURE_STORAGE=ON
30+
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/ios.cmake .. -DFIREBASE_CPP_BUILD_TESTS=ON -DFIREBASE_FORCE_FAKE_SECURE_STORAGE=ON
3131

3232
# Build the SDK and the tests
3333
cmake --build .

0 commit comments

Comments
 (0)