### Setting up Firebase Analytics Quickstart Terminal Source: https://github.com/firebase/quickstart-flutter/blob/main/analytics/README.md These terminal commands guide the user through cloning the Flutter Firebase quickstart repository, navigating to the specific analytics example directory, installing project dependencies using `flutter pub get`, configuring the Firebase project, and finally running the Flutter application. ```terminal git clone https://github.com/firebase/quickstart-flutter.git cd analytics/ flutter pub get flutterfire configure flutter run ``` -------------------------------- ### Cloning Flutter Quickstart Repository (sh) Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/README.md This command clones the Firebase Flutter quickstart repository from GitHub. It downloads the entire project structure, including the Data Connect example, to your local machine. ```sh git clone https://github.com/firebase/quickstart-flutter.git ``` -------------------------------- ### Running Flutter Application Shell Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/README.md This command builds and runs the Flutter application on an attached device or emulator. Use this command after configuring Firebase and starting the emulators to launch the quickstart example and interact with the authentication features. ```shell flutter run ``` -------------------------------- ### Starting Firebase Emulators Shell Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/README.md This command starts the local Firebase Emulator Suite, which typically includes emulators for Authentication, Firestore, and other services needed for local development and testing without interacting with a live Firebase project. This step is required before running the application locally to ensure it connects to the emulators. ```shell firebase emulators:start ``` -------------------------------- ### Activating FlutterFire CLI (sh) Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/README.md This command uses the Dart package manager (`pub`) to activate the `flutterfire_cli` package globally. This command-line interface is essential for configuring Firebase services within a Flutter project. ```sh dart pub global activate flutterfire_cli ``` -------------------------------- ### Installing Application Executable Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Installs the main executable target (`${BINARY_NAME}`) to the specified installation prefix. It is assigned to the `Runtime` component. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Executable - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Installs the built application executable to the configured installation directory. Specifies the runtime component for the install process. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Paths and Default Install Target - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Defines variables for installation directories relative to the build output and sets the build step to include the install target by default. Configures the destination for runtime files and data. ```CMake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Installing Target Executable Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Installs the main project executable (specified by BINARY_NAME) to the defined installation prefix. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Firebase with FlutterFire CLI (sh) Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/README.md This command uses the activated `flutterfire_cli` to automatically configure Firebase for the Flutter project. The `-y` flag accepts default prompts, and `-a com.example.dataconnect` specifies the application ID for configuration. ```sh flutterfire configure -y -a com.example.dataconnect ``` -------------------------------- ### Configuring Installation Directories and Defaults Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Sets variables defining the installation directory for the build bundle and makes the 'install' step a default build action, particularly for Visual Studio. It also sets the installation prefix if it's still at its default value. ```CMake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Installing Application Target - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Defines an installation rule to copy the compiled application executable (specified by `BINARY_NAME`) to the installation prefix directory. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Firebase for Flutter Project - Shell Source: https://github.com/firebase/quickstart-flutter/blob/main/dynamic_links/README.md This command is used to configure your Flutter project to integrate with Firebase. It automatically generates necessary configuration files like `firebase_options.dart` based on your Firebase project setup, which is crucial for initializing Firebase in the Flutter application. ```Shell flutterfire configure ``` -------------------------------- ### Installing Flutter Assets Directory - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Defines the name for the installed assets directory. It then adds an installation code block to first remove any previously installed assets and subsequently installs the entire assets directory from the build output location to the application's data directory. ```CMake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Executable Target (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Configures the installation of the main application executable, identified by `${BINARY_NAME}`. It specifies that the executable should be installed to the directory defined by `${CMAKE_INSTALL_PREFIX}` as part of the 'Runtime' component. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Defining Installation Destination Directories Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Defines variables for the data and library subdirectories within the installation prefix, standardizing the structure for installed files. ```CMake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Flutter Engine Library - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Installs the main Flutter engine runtime library to the library installation directory. This library is essential for the application to run. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Installation Paths and Defaults - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Sets variables defining the target installation directories for the executable, data files, and libraries. It also configures CMake generators like Visual Studio to automatically run the 'install' step after building, with the install prefix set to the build output directory. ```CMake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Installing and Updating Flutter Assets Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Configures the installation of Flutter application assets. It first adds a code command to recursively remove the existing asset directory in the installation destination to ensure a clean update, then installs the assets from the build directory. ```CMake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE "\n file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")\n " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Executable Target Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This command specifies that the main application executable target (`BINARY_NAME`) should be installed. The `RUNTIME` keyword indicates it's an executable, and `DESTINATION` specifies the root of the installation prefix (`CMAKE_INSTALL_PREFIX`). ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Assets Directory (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Configures the installation of the application's assets directory. It first uses `install(CODE)` to add a step that recursively removes the existing assets from the destination, then uses `install(DIRECTORY)` to copy the built assets directory to the data directory (`${INSTALL_BUNDLE_DATA_DIR}`) as part of the 'Runtime' component. ```CMake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE "\n file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")\n " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install and Update Application Assets - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Defines the name for the assets directory, includes a custom install code snippet to remove previously installed assets, and then installs the current build's assets directory. Ensures assets are always up-to-date in the installation location. ```CMake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing and Managing Assets Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Sets the name for the assets directory. Includes an installation step using CMake code to first remove the existing installed assets directory recursively, followed by installing the built assets directory to the data installation directory. This ensures assets are always up-to-date during installation. ```CMake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Basic Project and Path Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Sets the minimum required CMake version, defines the project name and binary name, sets a CMake policy for path handling, and configures the runtime path for installed libraries. ```CMake cmake_minimum_required(VERSION 3.14) project(crashlytics LANGUAGES CXX) set(BINARY_NAME "crashlytics") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Installing Flutter Library File (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Configures the installation of the main Flutter library file. It installs the file located at `${FLUTTER_LIBRARY}` to the library directory (`${INSTALL_BUNDLE_LIB_DIR}`) as part of the 'Runtime' component. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing AOT Library for Release/Profile (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Configures the installation of the Ahead-of-Time (AOT) compiled library. It installs the file located at `${AOT_LIBRARY}` to the data directory (`${INSTALL_BUNDLE_DATA_DIR}`) specifically for the 'Profile' and 'Release' build configurations as part of the 'Runtime' component. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Configuring Installation Paths and Targets - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/windows/CMakeLists.txt Defines variables for the build and installation bundle directories. It sets the install prefix to the build directory for easy execution and defines install rules for the application executable, Flutter's ICU data, the main Flutter library, and any bundled plugin libraries. ```CMake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Defining Bundle Data and Library Install Paths Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Defines variables `INSTALL_BUNDLE_DATA_DIR` and `INSTALL_BUNDLE_LIB_DIR` representing the target directories for installing data files and libraries within the build bundle, relative to the installation prefix. ```CMake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This loop iterates over a list of bundled plugin libraries (`PLUGIN_BUNDLED_LIBRARIES`) and installs each one individually into the library directory within the installation bundle. ```CMake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Defining Install Subdirectories Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt These lines define the names of the data and library subdirectories within the installation bundle, relative to the install prefix (`CMAKE_INSTALL_PREFIX`). ```CMake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Installing Flutter Libraries and Data Files Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Installs the Flutter ICU data file and the main Flutter library file to their respective installation destination directories. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Step: Cleaning Bundle Directory Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This `install(CODE)` command adds a custom build step that executes during the installation phase. It uses CMake's `file(REMOVE_RECURSE)` command to ensure the build bundle directory is cleaned before installing new files. ```CMake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Engine Library - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Defines an installation rule to copy the main Flutter engine shared library from its source location to the application's library directory during installation. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Main Flutter Library Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This command installs the main Flutter library (`FLUTTER_LIBRARY`). This library is the Flutter engine's shared library needed by the native shell to run the Flutter content. It is placed in the library directory within the installation bundle. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Installation Directory Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Sets the build bundle directory to the location of the executable. Marks the 'install' step as default for Visual Studio builds. If the install prefix is default, forces it to be the build bundle directory. ```CMake # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Installing AOT Library Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Installs the Ahead-of-Time (AOT) compiled library to the data installation directory, but only for Profile and Release build configurations, excluding Debug. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installing AOT Library (Profile/Release) - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Defines an installation rule to copy the Ahead-Of-Time (AOT) compiled snapshot library to the application's data directory. This rule is conditional and only executes for 'Profile' and 'Release' build configurations. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installing Bundled Plugin Libraries (If Any) - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Conditionally defines an installation rule. If the `PLUGIN_BUNDLED_LIBRARIES` variable is set (indicating bundled plugin libraries exist), it installs these libraries to the application's library directory. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installing Flutter Library Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Installs the main Flutter library file (`${FLUTTER_LIBRARY}`) into the library directory within the build bundle. This library contains the core Flutter engine code. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Assets Directory via Code - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/windows/CMakeLists.txt Adds an installation step using CMake code that first removes the existing installed assets directory to avoid stale files. It then copies the entire built `flutter_assets` directory from the build location to the installation's data directory. ```CMake install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Bundled Plugin Libraries Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Conditionally installs any bundled plugin libraries if the `PLUGIN_BUNDLED_LIBRARIES` variable is set, placing them in the defined library installation directory. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Defining Installation Directory Variables (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Defines two CMake variables, `INSTALL_BUNDLE_DATA_DIR` and `INSTALL_BUNDLE_LIB_DIR`, relative to the installation prefix (`CMAKE_INSTALL_PREFIX`). These variables specify the target directories for data files and libraries during the installation process. ```CMake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Running Flutter Web App with HTML Renderer (Shell) Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/README.md This command runs the Flutter application targeting the web using the Chrome browser. The --web-renderer html flag specifically instructs Flutter to use the HTML renderer instead of the default CanvasKit renderer, which is often necessary to avoid Cross-Origin Resource Sharing (CORS) exceptions when displaying images from external sources. ```Shell flutter run -d chrome --web-renderer html ``` -------------------------------- ### Install Native Assets Directory - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Defines the path to the native assets directory generated by the build and installs its contents to the library installation directory. Copies platform-specific assets required by the application. ```CMake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing AOT Library for Release Builds Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Installs the Ahead-of-Time (AOT) compiled library (`${AOT_LIBRARY}`) into the data directory within the build bundle. This installation is configured only for Profile and Release build configurations, not Debug. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installing Plugin Libraries (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Conditionally configures the installation of bundled plugin libraries. If the CMake variable `PLUGIN_BUNDLED_LIBRARIES` is defined (indicating there are bundled plugins), it installs those files to the library directory (`${INSTALL_BUNDLE_LIB_DIR}`) as part of the 'Runtime' component. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Configuring CMake Install Directory and Default Step Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Sets the `BUILD_BUNDLE_DIR` variable to the directory where the executable will be built. It then sets the `CMAKE_INSTALL_PREFIX` to this directory and configures Visual Studio generators to make the 'install' step a default build step, ensuring the runtime files are copied. ```CMake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Install AOT Library for Profile and Release Builds - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Installs the Ahead-of-Time (AOT) compiled Flutter application library to the data installation directory. This step is only performed for Profile and Release build configurations, not Debug. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Configure Firebase Flutter Project with flutterfire sh Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/README.idx.md This command uses the `flutterfire` CLI tool to automatically configure Firebase for the Flutter project. It accepts defaults (`-y`) and specifies the application ID (`-a com.example.dataconnect`). This step is necessary to set up the Firebase SDK configuration files for the project. ```sh flutterfire configure -y -a com.example.dataconnect ``` -------------------------------- ### Install Assets Directory Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt These commands first add a custom install step to recursively remove the existing asset directory within the bundle data directory, and then install the current assets directory from the build output (`PROJECT_BUILD_DIR`) into the bundle data directory. ```CMake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Plugin Bundled Libraries - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Conditionally installs any libraries provided by Flutter plugins if the PLUGIN_BUNDLED_LIBRARIES variable is set. Ensures plugin dependencies are placed in the correct installation location. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installing Bundled Plugin Libraries Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Conditionally installs any bundled plugin libraries (`${PLUGIN_BUNDLED_LIBRARIES}`) into the library directory within the build bundle if the `PLUGIN_BUNDLED_LIBRARIES` variable is set. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Running Flutter App on iOS Device (Release) - Shell Source: https://github.com/firebase/quickstart-flutter/blob/main/dynamic_links/README.md Executes the Flutter application on a connected iOS device in release mode. Running in release mode is often required for features like Apple's Universal Links (used by Dynamic Links on iOS) to function correctly and provides performance closer to the final user experience. ```Shell flutter run --release ``` -------------------------------- ### Setting Installation Bundle Directory Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt These lines define the directory where the relocatable application bundle will be created (`BUILD_BUNDLE_DIR`) and conditionally sets the default installation prefix (`CMAKE_INSTALL_PREFIX`) to this bundle directory if it hasn't been initialized. ```CMake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Installing AOT Library for Profile and Release Builds - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/windows/CMakeLists.txt Installs the Ahead-of-Time (AOT) compiled library generated by Flutter, which is essential for performance in non-debug builds. This installation rule is specifically configured to run only for Profile and Release configurations. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Defining Minimum CMake Version and Project Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Sets the minimum required CMake version for the project (3.14) and defines the project name 'remote_config' with support for the CXX language. This is the standard starting point for a CMakeLists.txt file. ```CMake cmake_minimum_required(VERSION 3.14) project(remote_config LANGUAGES CXX) ``` -------------------------------- ### Open Flutter iOS Project in Xcode (Shell) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md This shell command navigates to the iOS project directory within your Flutter project and opens the Xcode workspace file. This is necessary to modify settings, manage dependencies, or customize assets like the launch screen via the Xcode interface. ```Shell open ios/Runner.xcworkspace ``` -------------------------------- ### Installing Flutter ICU Data File - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Defines an installation rule to copy the International Components for Unicode (ICU) data file, required by the Flutter engine, from its source location to the application's data directory during installation. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter ICU Data File Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Installs the Flutter ICU data file (`${FLUTTER_ICU_DATA_FILE}`) into the data directory within the build bundle. This file is required for internationalization support in Flutter. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Application Binary Name - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Defines the variable BINARY_NAME which specifies the output filename for the built executable. Used in later installation rules. ```CMake set(BINARY_NAME "dataconnect") ``` -------------------------------- ### Configuring Runtime Path for Libraries Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This line sets the `CMAKE_INSTALL_RPATH` to `$ORIGIN/lib`. This ensures that the executable, when installed, can find its bundled libraries located in a 'lib' directory relative to the executable itself. ```CMake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Configuring Flutter Windows Build with CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/flutter/CMakeLists.txt This CMake script sets up the build environment for a Flutter Windows application. It defines paths for ephemeral build files, Flutter libraries, and the C++ client wrapper. It configures INTERFACE libraries for the Flutter engine and STATIC libraries for the client wrapper (plugin and app versions), linking them and setting include directories. It also defines a custom command `flutter_assemble` to run the Flutter build tool backend, ensuring all generated artifacts and source files are included as dependencies. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This command installs the ICU data file (`FLUTTER_ICU_DATA_FILE`), which is required by the Flutter engine for internationalization. It is placed in the data directory within the installation bundle. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initializing CMake Project and Binary Name - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/storage/windows/CMakeLists.txt Sets the minimum required CMake version for the project, defines the project name and supported languages (C++), and specifies the desired name for the output executable binary. ```CMake cmake_minimum_required(VERSION 3.14) project(storage LANGUAGES CXX) set(BINARY_NAME "storage") ``` -------------------------------- ### Configuring Flutter Windows Build with CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/authentication/windows/flutter/CMakeLists.txt This CMakeLists.txt file defines the complete build configuration for a Flutter Windows application. It includes setting up paths, defining CMake libraries (INTERFACE for the Flutter engine and STATIC for the C++ wrapper), managing source files and headers, setting target properties, defining dependencies, and creating a custom command and target (`flutter_assemble`) to run the Flutter tool backend for asset assembly and build artifact generation. ```CMake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Including Flutter, Runner, and Plugin Subdirectories Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/CMakeLists.txt Sets a variable for the path to the Flutter-managed directory. Includes the Flutter build rules, the main application runner's build configuration, and the generated plugin build rules. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") # Flutter library and tool build rules. add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Install Flutter ICU Data File - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/data_connect/windows/CMakeLists.txt Installs the Flutter ICU (International Components for Unicode) data file to the data installation directory. Required for Flutter applications needing localization support. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Defining App Wrapper STATIC Library - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/flutter/CMakeLists.txt Creates a STATIC library target ('flutter_wrapper_app') containing the C++ client wrapper sources required for the main application runner. It applies standard settings, links against the 'flutter' interface library, and adds include directories. ```CMake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Install AOT Library (Conditional) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt This conditional block checks if the build type is *not* 'Debug'. If it's a release or profile build, it installs the Ahead-Of-Time (AOT) compiled Flutter library (`AOT_LIBRARY`) into the library directory within the installation bundle. ```CMake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Including Flutter and Runner Subdirectories Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/CMakeLists.txt Defines the path to the Flutter managed directory and includes CMake files for building the Flutter library and the application runner. This incorporates Flutter's build logic into the project. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") # Flutter library and tool build rules. add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build add_subdirectory("runner") ``` -------------------------------- ### Configuring Flutter Windows Runner Executable Build - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/runner/CMakeLists.txt This CMake script configures the build process for the Flutter Windows runner executable. It defines the executable target, lists the source files including C++, resource files, and the generated plugin registrant. It then applies standard settings, adds compile definitions (NOMINMAX), links necessary libraries (flutter, flutter_wrapper_app), specifies include directories for header files, and sets up a dependency on the flutter_assemble target to ensure assets are prepared. Required dependencies include CMake (>= 3.14) and the Flutter build environment. ```CMake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) apply_standard_settings(${BINARY_NAME}) target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Installing Flutter ICU Data File (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/CMakeLists.txt Configures the installation of the International Components for Unicode (ICU) data file required by Flutter. It installs the file located at `${FLUTTER_ICU_DATA_FILE}` to the data directory (`${INSTALL_BUNDLE_DATA_DIR}`) as part of the 'Runtime' component. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Flutter Wrapper App Library Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/flutter/CMakeLists.txt Defines a static library `flutter_wrapper_app` using the core and app C++ wrapper sources. It applies standard settings, links against the `flutter` interface library, includes wrapper headers, and adds a dependency on `flutter_assemble`. ```CMake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Finding System Dependencies (PkgConfig, GTK) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/linux/CMakeLists.txt These commands find the `PkgConfig` package, which is required, and then use `PkgConfig` to check for the required `gtk+-3.0` library, creating an imported target named `PkgConfig::GTK`. ```CMake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Defining C++ Wrapper Source File Lists Source: https://github.com/firebase/quickstart-flutter/blob/main/crashlytics/windows/flutter/CMakeLists.txt Creates lists of C++ source files for different components of the client wrapper: core functionalities, plugin registration, and application runner logic. It prepends the `WRAPPER_ROOT` path to all source files in each list. ```CMake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Defining Plugin Wrapper STATIC Library - CMake Source: https://github.com/firebase/quickstart-flutter/blob/main/firestore/windows/flutter/CMakeLists.txt Creates a STATIC library target ('flutter_wrapper_plugin') containing the C++ client wrapper sources necessary for implementing plugins. It applies standard settings, sets target properties, links against the 'flutter' interface library, and adds include directories. ```CMake # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Configuring Flutter App Wrapper Library (CMake) Source: https://github.com/firebase/quickstart-flutter/blob/main/remote_config/windows/flutter/CMakeLists.txt Defines a `STATIC` library target named `flutter_wrapper_app` using the core and app-specific C++ wrapper source files. It applies standard settings, links against the `flutter` interface library, adds necessary include directories, and sets a dependency on `flutter_assemble`. This target is typically used by the main application executable. ```CMake add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ```