### Installation Rules for Executable Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs the main executable to the runtime destination, typically next to support files. ```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}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installation Configuration Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Configures the installation process, including cleaning the build bundle directory, installing the executable, ICU data, Flutter library, bundled plugins, and assets. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 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) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # 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) ``` -------------------------------- ### Installation Rules for Flutter Library Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs the Flutter library file to the library directory within the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Bundled Plugin Libraries Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the library directory within the application bundle. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installation Rules for AOT Library Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the data directory, but only for Profile and Release build configurations. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Native Assets Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages to the library directory within the application bundle. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for ICU Data Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs the ICU data file to the data directory within the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Flutter Assets Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Installs the Flutter assets directory to the data directory within the application bundle, ensuring a clean copy on each build. ```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) ``` -------------------------------- ### Project and Build Configuration Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, executable name, and application ID. It also explicitly opts into modern CMake behaviors and sets the installation path for bundled libraries. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.baseflow.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() # Define build configuration options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Installs the AOT library to the specified destination only when the build type is not 'Debug'. This ensures the library is included in release builds. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Get Image File with Resizing Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/README.md Retrieves an image file from a URL, resizing it according to specified dimensions while maintaining aspect ratio. The original image is also cached for future resizing operations with different parameters. ```dart Stream getImageFile(String url, { String key, Map headers, bool withProgress, int maxHeight, // This is extra int maxWidth, // This is extra as well }) ``` -------------------------------- ### Get Single File Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/README.md Use this method to easily retrieve a single file from the cache manager. It handles both cached and newly downloaded files. ```dart var file = await DefaultCacheManager().getSingleFile(url); ``` -------------------------------- ### Set Flutter library and ICU data path Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Publishes the Flutter library path and the ICU data file path to the parent scope for use in the install step. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Get Image File with Resizing Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/README.md This method, available when using ImageCacheManager, retrieves an image file, resizing it according to specified dimensions while maintaining aspect ratio. The original image is also cached for future resizing operations. ```dart Stream getImageFile(String url, { String key, Map headers, bool withProgress, int maxHeight, // This is extra int maxWidth, // This is extra as well }) ``` -------------------------------- ### Fetch File from Firebase Storage Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager_firebase/README.md Use FirebaseCacheManager to get a single file from Firebase Storage using its URL. Ensure you have initialized Firebase. ```dart var file = await FirebaseCacheManager().getSingleFile(url); ``` -------------------------------- ### Application Build Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Includes the runner subdirectory, which contains the build rules for the application itself. ```cmake # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Includes the Flutter build rules and finds necessary system libraries like GTK using PkgConfig. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Define C++ wrapper plugin sources Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Lists the C++ source files specific to plugin registration for the client wrapper and prepends the wrapper root path. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Find System Libraries Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries: GTK, GLIB, and GIO. These are essential for Flutter's Linux integration. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be customized for applications with unique build requirements. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Format Code Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Format your code according to the project's standards. This command should be run before committing changes. ```flutter flutter format . ``` -------------------------------- ### Define C++ wrapper core sources Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Lists the core C++ source files for the client wrapper and prepends the wrapper root path. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Adds necessary libraries (like flutter, flutter_wrapper_app, and dwmapi.lib) and include directories to the target. Custom application dependencies should also be added here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Build Configuration Options Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Defines build configuration types (Debug, Profile, Release) and sets the default build type if not already specified. ```cmake # Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Project-level CMake Configuration Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Sets the minimum CMake version, project name, and executable name for the Windows build. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") ``` -------------------------------- ### Create Flutter interface library Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Creates an interface library target named 'flutter' and sets its include directories and link libraries. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Create static library for Flutter wrapper plugin Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Creates a static library target 'flutter_wrapper_plugin' using core and plugin-specific C++ sources. It applies standard settings, sets position-independent code, and links against the 'flutter' library. ```cmake 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) ``` -------------------------------- ### Runtime Output Directory Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory to ensure correct resource loading. ```cmake # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Set C++ client wrapper root Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Defines the root directory for the C++ client wrapper sources. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Create static library for Flutter wrapper application Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Creates a static library target 'flutter_wrapper_app' using core and application-specific C++ sources. It applies standard settings and links against the 'flutter' library. ```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) ``` -------------------------------- ### Application Target Definition Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files and applying standard build settings. ```cmake # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Define C++ wrapper application sources Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Lists the C++ source files for the Flutter application runner (engine and view controller) and prepends the wrapper root path. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt A function to apply standard compilation features, options, and definitions to a target, including C++17 standard, warning levels, and exception handling. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Defines linker and compiler flags for the Profile build mode, typically inheriting from Release settings. ```cmake # Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Flutter Library and Tool Build Rules Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Includes the Flutter managed directory, which contains build rules for Flutter libraries and tools. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Set project build directory and AOT library path Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Sets the project build directory and the path to the AOT (Ahead-Of-Time) compiled library, publishing them to the parent scope. ```cmake set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Unicode Support Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. ```cmake # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Generated Plugin Rules Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Includes the CMake script for managing the build rules of generated plugins. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Include generated configuration Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Includes the generated_config.cmake file from the ephemeral directory, which is provided by the flutter tool. ```cmake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Fetch Latest Code and Create Branch Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Fetch the latest code from the upstream master and create a new branch for your changes. ```git git fetch upstream git checkout upstream/develop -b ``` -------------------------------- ### Run Unit Tests Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Execute the unit tests to ensure your changes have not introduced regressions. ```flutter flutter test ``` -------------------------------- ### Define Flutter library headers Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Lists the header files for the Flutter library and transforms the list to prepend the ephemeral directory path. ```cmake 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}/") ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/flutter/CMakeLists.txt A custom command to execute the Flutter tool backend script. This command is triggered to generate the Flutter library and headers, using environment variables and build configurations. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) ``` -------------------------------- ### Modern CMake Policy Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Custom Cache Manager Configuration Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/README.md Create a custom CacheManager instance with specific configurations for stale period, maximum cache objects, and custom file system and service implementations. Ensure a unique key for each CacheManager instance to avoid conflicts. ```dart class CustomCacheManager { static const key = 'customCacheKey'; static CacheManager instance = CacheManager( Config( key, stalePeriod: const Duration(days: 7), maxNrOfCacheObjects: 20, repo: JsonCacheInfoRepository(databaseName: key), fileSystem: IOFileSystem(key), fileService: HttpFileService(), ), ); } ``` -------------------------------- ### Analyze Code Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Run static code analysis to check for potential warnings or errors in your code. ```flutter flutter analyze ``` -------------------------------- ### Set Flutter library path Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Defines the path to the Flutter Windows DLL. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") ``` -------------------------------- ### Commit Changes Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Commit your changes with an informative message. This should be done after verifying your changes. ```git git commit -am "" ``` -------------------------------- ### Import File Class Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/CHANGELOG.md To use the File class from the package, import it separately. This change was made to move the File to its own file. ```dart import 'package:flutter_cache_manager/file.dart' as cache_file; ``` -------------------------------- ### Push Changes to Fork Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Push your committed changes to your fork on GitHub. This prepares your changes for a pull request. ```git git push origin ``` -------------------------------- ### Configure Flutter Library Interface Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/flutter/CMakeLists.txt Configures an INTERFACE library target named 'flutter'. It sets include directories and links against the Flutter shared object and system libraries. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Linking Libraries and Dependencies Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Links the application target with the Flutter library and GTK, and adds a dependency on the Flutter assembly process. ```cmake # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Set fallback platform target Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Sets a fallback FLUTTER_TARGET_PLATFORM if it's not already defined, defaulting to 'windows-x64'. ```cmake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Define List Prepend Function Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/flutter/CMakeLists.txt Defines a custom CMake function 'list_prepend' to prepend a prefix to each element in a list, as 'list(TRANSFORM ... PREPEND ...)' is not available in CMake 3.10. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Clone Forked Repository Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Clone your forked repository to your local development machine. Ensure you have configured an SSH key with GitHub. ```git git clone git@github.com:/flutter_cache_manager.git ``` -------------------------------- ### Define Executable Target Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Defines the main executable for the Windows runner application. Source files and resources are listed here. It's recommended to change the binary name in the top-level CMakeLists.txt. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. 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" ) ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the target for various components of the Flutter build version. This allows the application to access version information during compilation. ```cmake # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Initialize FirebaseCacheManager with Custom Bucket Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager_firebase/README.md Instantiate FirebaseCacheManager with a specific Firebase Storage bucket name when needed. ```dart FirebaseCacheManager(bucket: "my-bucket"); ``` -------------------------------- ### Set Cache Manager Log Level Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/CHANGELOG.md Allows managing the log level for the CacheManager. By default, failed downloads are not printed. Set to verbose for detailed logging. ```dart CacheManager.logLevel = CacheManagerLogLevel.verbose; ``` -------------------------------- ### Add Flutter Build Dependency Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This is a mandatory step for Flutter applications. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/CMakeLists.txt Defines a function to apply common compilation features and options to targets, including C++ standard, warning levels, optimization, and NDEBUG definition. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Set ephemeral directory variable Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Sets the CMAKE_CURRENT_SOURCE_DIR to the ephemeral directory for build configurations. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Add Upstream Remote Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/CONTRIBUTING.md Add an upstream remote to the original repository to fetch from the master repository, not just your clone. ```git git remote add upstream git@github.com:Baseflow/flutter_cache_manager.git ``` -------------------------------- ### Add Flutter assemble custom target Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/flutter/CMakeLists.txt Creates a custom target 'flutter_assemble' that depends on the Flutter library, headers, and wrapper source files. This target ensures these components are built before other dependent targets. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Define Flutter Assemble Custom Target Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/linux/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the Flutter library and its headers. This target ensures these components are built. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/example/windows/runner/CMakeLists.txt Disables Windows-specific macros like NOMINMAX that can conflict with C++ standard library functions, preventing potential compilation errors. ```cmake # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.