Explicitly set curl to build statically - #1907
Conversation
There was a problem hiding this comment.
Code Review
This pull request configures curl to build as a static library by setting BUILD_SHARED_LIBS and BUILD_CURL_EXE to OFF in CMakeLists.txt. The reviewer suggested defining these as local variables instead of cache variables to prevent polluting the global cache and to ensure they take effect properly when the project is included as a subdirectory.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request modifies the CMake configuration for desktop builds to build curl as a static library and disable building the curl executable. The review feedback points out that setting BUILD_SHARED_LIBS globally to OFF can leak to other subdirectories and external libraries, and recommends saving and restoring its original value to prevent unintended side effects.
| set(BUILD_SHARED_LIBS OFF) | ||
| set(BUILD_CURL_EXE OFF) | ||
| set(CURL_STATICLIB ON) |
There was a problem hiding this comment.
Setting BUILD_SHARED_LIBS globally to OFF will leak to all subsequent subdirectories and external libraries (such as libuv, zlib, and the Firebase SDK components themselves like app, analytics, etc.). This overrides any user-specified BUILD_SHARED_LIBS setting for the rest of the build.\n\nTo prevent this side effect, you should save the original value of BUILD_SHARED_LIBS before modifying it, and restore it immediately after add_external_library(curl) (around line 450).\n\nSince add_external_library(curl) is outside of this diff hunk, please apply the following pattern:\n\n1. Save the variable state here (using the code suggestion below).\n2. Restore it after add_external_library(curl):\ncmake\nif(DEFINED OLD_BUILD_SHARED_LIBS)\n set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})\nelse()\n unset(BUILD_SHARED_LIBS)\nendif()\n
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})\n set(BUILD_SHARED_LIBS OFF)\n set(BUILD_CURL_EXE OFF)\n set(CURL_STATICLIB ON)
There was a problem hiding this comment.
Firebase C++ expects the dependencies to be static, so this should have no issue.
❌ Integration test FAILEDRequested by @a-maurice on commit 8715933
Add flaky tests to go/fpl-cpp-flake-tracker |
Description
Explicitly set CMake flags to make curl build as a static library. Note that this should effectively be a no-op, since these flags are set by the underlying iOS Firestore CMake logic, the problem only occurs when building without enabling Firestore.
Testing
Building locally, and checking the resulting bundle symbols.
Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.