Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core, windows): building improvements #10972

Merged
merged 3 commits into from
May 17, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 34 additions & 17 deletions packages/firebase_core/firebase_core/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@ cmake_minimum_required(VERSION 3.14)

set(FIREBASE_SDK_VERSION "10.5.0")
set(FIREBASE_SDK_URL "https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${FIREBASE_SDK_VERSION}.zip")
set(FIREBASE_SDK_FILENAME "${CMAKE_BINARY_DIR}/firebase_cpp_sdk_${FIREBASE_SDK_VERSION}.zip")
set(EXTRACTED_PATH "${CMAKE_BINARY_DIR}/extracted")

if(NOT EXISTS ${FIREBASE_SDK_FILENAME})
file(DOWNLOAD ${FIREBASE_SDK_URL} ${FIREBASE_SDK_FILENAME}
SHOW_PROGRESS
STATUS download_status
LOG download_log)
list(GET download_status 0 status_code)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "Download failed: ${download_log}")
endif()
if (EXISTS $ENV{FIREBASE_CPP_SDK_DIR}/file_hashes.txt)
file(SHA256 $ENV{FIREBASE_CPP_SDK_DIR}/file_hashes.txt FIREBASE_SDK_FILE_HASH)
endif()

if(NOT EXISTS ${EXTRACTED_PATH})
file(MAKE_DIRECTORY ${EXTRACTED_PATH})
file(ARCHIVE_EXTRACT INPUT ${FIREBASE_SDK_FILENAME}
DESTINATION ${EXTRACTED_PATH})
endif()
set(FIREBASE_CPP_SDK_DIR "${EXTRACTED_PATH}/firebase_cpp_sdk")
if(FIREBASE_SDK_FILE_HASH STREQUAL "3163806e86ca534d417c0306fcf1068acb35dd7545f3ffdaa109f989b2fd411b")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse my ignorance, but is this hash based on the Firebase SDK version? i.e does this need to change every time we change the firebase version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@russellwheatley, yes. I agree, this is not the most convenient and reliable approach. Instead, I'll try to parse the version from the version header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@russellwheatley Done. Now the version is checked natively.

message(STATUS "Found Firebase SDK version ${FIREBASE_SDK_VERSION}")
set(FIREBASE_CPP_SDK_DIR $ENV{FIREBASE_CPP_SDK_DIR})
else()
set(FIREBASE_SDK_FILENAME "${CMAKE_BINARY_DIR}/firebase_cpp_sdk_${FIREBASE_SDK_VERSION}.zip")
set(EXTRACTED_PATH "${CMAKE_BINARY_DIR}/extracted")
if(NOT EXISTS ${FIREBASE_SDK_FILENAME})
file(DOWNLOAD ${FIREBASE_SDK_URL} ${FIREBASE_SDK_FILENAME}
SHOW_PROGRESS
STATUS download_status
LOG download_log)
list(GET download_status 0 status_code)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "Download failed: ${download_log}")
endif()
endif()

if(NOT EXISTS ${EXTRACTED_PATH})
file(MAKE_DIRECTORY ${EXTRACTED_PATH})
file(ARCHIVE_EXTRACT INPUT ${FIREBASE_SDK_FILENAME}
DESTINATION ${EXTRACTED_PATH})
endif()
set(FIREBASE_CPP_SDK_DIR "${EXTRACTED_PATH}/firebase_cpp_sdk")
endif()

# Project-level configuration.
set(PROJECT_NAME "firebase_core")
Expand Down Expand Up @@ -72,6 +80,15 @@ add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${FIREBASE_CPP_SDK_DIR}/include")
set(firebase_libs firebase_auth firebase_database firebase_app)
foreach(firebase_lib IN ITEMS ${firebase_libs})
get_target_property(firebase_lib_path ${firebase_lib} IMPORTED_LOCATION)
string(REPLACE "Debug" "Release" firebase_lib_release_path ${firebase_lib_path})
set_target_properties(${firebase_lib} PROPERTIES
IMPORTED_LOCATION_DEBUG "${firebase_lib_path}"
IMPORTED_LOCATION_RELEASE "${firebase_lib_release_path}"
)
endforeach()

target_link_libraries(${PLUGIN_NAME} PRIVATE "${firebase_libs}")

target_include_directories(${PLUGIN_NAME} INTERFACE
Expand Down