### CMake Installation Rules for Windows Executable Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/CMakeLists.txt Configures the installation process for the Windows executable and its associated files. It sets the installation prefix, installs the executable, ICU data, Flutter library, bundled plugin libraries, native assets, and Flutter assets. ```cmake set(BUILD_BUNDLE_DIR "$") 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() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) 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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and executable name. It also defines build configuration types and handles multi-configuration generators. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(VERSION 3.14...3.25) 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() 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}") add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Install Flutter Application Bundle (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This CMake code block handles the installation of the Flutter application bundle. It ensures a clean build bundle directory, installs the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets. It also conditionally installs the AOT library for non-Debug builds. ```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) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # 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) # 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() ``` -------------------------------- ### Accessing Environment Variables in Flutter Source: https://context7.com/java-james/flutter_dotenv_remote/llms.txt Shows how to access loaded environment variables after calling `loadRemote`. Variables are available in the `dotenv.env` map, and this example demonstrates accessing individual variables, providing defaults, checking boolean values, and listing all loaded variables. ```dart import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv_remote/flutter_dotenv_remote.dart'; class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { // Access individual variables final apiKey = dotenv.env['API_KEY'] ?? 'default_key'; final apiUrl = dotenv.env['API_URL'] ?? 'https://api.example.com'; final debugMode = dotenv.env['DEBUG_MODE'] == 'true'; // List all loaded environment variables final envVars = dotenv.env.entries.toList(); return MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('Remote Env Example')), body: ListView.builder( itemCount: envVars.length, itemBuilder: (context, index) { final entry = envVars[index]; return ListTile( title: Text(entry.key), subtitle: Text(entry.value), ); }, ), ), ); } } ``` -------------------------------- ### SupabaseConfig Type Definition and Usage in Dart Source: https://context7.com/java-james/flutter_dotenv_remote/llms.txt Defines the `SupabaseConfig` type alias, which is a record structure for providing custom Supabase connection details (URL and anon key). An example demonstrates how to create and use this configuration with the `loadRemote` method. ```dart // Type definition typedef SupabaseConfig = ({String url, String anonKey}); // Usage example final config = ( url: 'https://your-project.supabase.co', anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', ); await dotenv.loadRemote( configId: 'your-config-id', supabaseConfig: config, ); ``` -------------------------------- ### Configure Flutter library and headers in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This CMake code defines the path to the Flutter Linux GTK shared library and its associated header files. It also sets environment variables for the Flutter engine's ICU data file and project build directories, making them available in the parent scope for installation and other build steps. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # 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/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### CMake Build Configuration for Flutter Application Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/runner/CMakeLists.txt Configures the CMake build system for a Flutter application. It defines the executable target, includes generated plugin registration files, applies standard build settings, and links essential libraries such as flutter and GTK. This setup is crucial for building native Flutter applications that interact with C++ code. ```cmake cmake_minimum_required(VERSION 3.13) 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} "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}) # Add preprocessor definitions for the application ID. add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Advanced Remote Configuration Loading with Supabase Details Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/README.md This Dart snippet illustrates how to load remote environment configurations when self-hosting Supabase. It allows specifying Supabase URL and Anon Key, or providing a pre-configured SupabaseClient instance for advanced use cases like testing. ```dart await dotenv.loadRemote( configId: 'your-id', supabaseUrl: 'https://your-project.supabase.co', supabaseAnonKey: 'your-anon-key', // or // supabaseClient: SupabaseClient(...), ); ``` -------------------------------- ### Load Remote Environment Configuration in Flutter App Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/README.md This Dart code demonstrates how to load a remote environment configuration at app startup using flutter_dotenv_remote. It specifies the config ID, enables caching on failure, and provides an optional callback for handling load failures. ```dart import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv_remote/flutter_dotenv_remote.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await dotenv.loadRemote( // UUID from your environment entry on flutterdotenv.com configId: '699fb309-6c5c-44fb-8612-b6a8dda08296', useCacheOnFailure: true, onLoadFailure: () { // optional: UI fallback or logging debugPrint('Failed to load config from remote and cache'); }, ); runApp(const MyApp()); } ``` -------------------------------- ### Find and check GTK, GLIB, GIO modules using PkgConfig in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This section uses PkgConfig to find and check for the presence of GTK, GLIB, and GIO development libraries. It ensures these system-level dependencies are available before proceeding with the build. The `REQUIRED` keyword ensures the build fails if any module is not found. ```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 (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This command applies a standard set of build settings to the runner application. This is a convenient way to ensure consistent build configurations across different targets. It can be removed if the application requires custom build settings. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This snippet configures the linker settings for the runner application. It adds necessary libraries such as 'flutter', 'flutter_wrapper_app', and 'dwmapi.lib'. It also specifies the include directory for project headers, ensuring that all necessary components are available during the build. ```cmake 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}") ``` -------------------------------- ### Project-Level Configuration (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This snippet sets up the basic project configuration using CMake. It specifies the minimum required CMake version, defines the project name and languages, and sets the executable and application ID. ```cmake cmake_minimum_required(VERSION 3.13) 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.example.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") ``` -------------------------------- ### Load Remote Config with Self-Hosted Supabase in Dart Source: https://context7.com/java-james/flutter_dotenv_remote/llms.txt Illustrates how to configure `loadRemote` to use a self-hosted Supabase instance. Two options are provided: using a `supabaseConfig` record with URL and anon key, or providing a pre-configured `SupabaseClient` instance. ```dart import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv_remote/flutter_dotenv_remote.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Option 1: Using supabaseConfig record await dotenv.loadRemote( configId: 'your-config-id', supabaseConfig: ( url: 'https://your-project.supabase.co', anonKey: 'your-supabase-anon-key', ), ); // Option 2: Using custom SupabaseClient (useful for testing) final customClient = SupabaseClient( 'https://your-project.supabase.co', 'your-supabase-anon-key', ); await dotenv.loadRemote( configId: 'your-config-id', supabaseClient: customClient, ); runApp(const MyApp()); } ``` -------------------------------- ### Define custom command to build Flutter library using tool_backend.sh in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This CMake custom command invokes the Flutter tool backend script to build the Flutter library and headers. It uses a phony target `_phony_` to ensure the command runs on every build, as direct input/output tracking for the Flutter tool is not yet supported. The command is executed with environment variables set by `FLUTTER_TOOL_ENVIRONMENT`. ```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 ) ``` -------------------------------- ### Define Executable and Source Files (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This snippet defines the main executable for the runner application and lists all the source files required for compilation. It includes C++ source files, Flutter-generated files, and resource files. The executable name is controlled by BINARY_NAME in the top-level CMakeLists.txt. ```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" ) ``` -------------------------------- ### Load Remote Environment Configuration in Dart Source: https://context7.com/java-james/flutter_dotenv_remote/llms.txt Demonstrates how to load remote environment variables using the `loadRemote` method. It shows basic usage with a config ID and advanced usage with options like `useCacheOnFailure` and `onLoadFailure` callbacks. Environment variables are accessed via `dotenv.env`. ```dart import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv_remote/flutter_dotenv_remote.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Basic usage with hosted portal (recommended) await dotenv.loadRemote( configId: '699fb309-6c5c-44fb-8612-b6a8dda08296', ); // Full usage with all options await dotenv.loadRemote( configId: '699fb309-6c5c-44fb-8612-b6a8dda08296', useCacheOnFailure: true, // Default: true - use cached config if remote fails onLoadFailure: () async { // Called when both remote fetch and cache loading fail debugPrint('Failed to load config from remote and cache'); // Optionally load from local .env file as ultimate fallback }, ); // Access loaded environment variables final apiKey = dotenv.env['API_KEY']; final baseUrl = dotenv.env['BASE_URL']; runApp(const MyApp()); } ``` -------------------------------- ### Add Preprocessor Definitions for Versioning (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This snippet adds preprocessor definitions to the build process, embedding Flutter version information directly into the compiled code. This allows the application to access version details at runtime. It defines major, minor, patch, and build numbers. ```cmake 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}") ``` -------------------------------- ### Apply Standard Compilation Settings (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This CMake function, APPLY_STANDARD_SETTINGS, applies common compilation features and options to a target. It enforces C++14 standard, enables all warnings, sets optimization to -O3 for non-Debug builds, and defines NDEBUG for non-Debug builds. ```cmake 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() ``` -------------------------------- ### Define list_prepend function in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This CMake function mimics the behavior of `list(TRANSFORM ... PREPEND ...)` for older CMake versions (3.10). It prepends a given prefix to each element of a list and updates the list in the parent scope. ```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() ``` -------------------------------- ### Flutter Build Rules and Dependencies (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This CMake snippet includes the Flutter managed directory and adds the Flutter build as a dependency for the main binary. It also includes generated plugin build rules. ```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) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # 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" ) # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Flutter Build Rules and Subdirectories Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/CMakeLists.txt Includes build rules for Flutter libraries, tools, and the application runner. It adds subdirectories for managed Flutter code and the runner. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Add flutter_dotenv_remote and flutter_dotenv to pubspec.yaml Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/README.md This snippet shows how to add the necessary dependencies to your Flutter project's pubspec.yaml file. It includes the main package and its core dependency, flutter_dotenv. ```yaml dependencies: flutter_dotenv_remote: ^0.0.1 flutter_dotenv: ^6.0.0 ``` -------------------------------- ### Add Flutter Tool Build Dependency (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This command ensures that the Flutter tool's assembly process is executed as part of the runner application's build. This is a critical step that must not be removed, as it integrates Flutter-specific build artifacts into the final executable. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Create flutter_assemble custom target in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This CMake code defines a custom target named `flutter_assemble`. This target depends on the generated Flutter library and its header files. It serves as a dependency for other build steps that require the Flutter library to be ready. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Cross-Building Configuration (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This CMake code block configures cross-building by setting the sysroot and find root paths. It ensures that the build process correctly locates necessary tools and libraries when targeting a different platform. ```cmake # 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 Flutter Project Build Configuration (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/CMakeLists.txt This snippet defines the build configuration options for a Flutter project using CMake. It sets the default build type to 'Debug' if not already specified and restricts the allowed values to 'Debug', 'Profile', and 'Release'. ```cmake 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() ``` -------------------------------- ### Add Flutter library interface target in CMake Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/linux/flutter/CMakeLists.txt This CMake code creates an INTERFACE library target named 'flutter'. It specifies include directories for the Flutter headers and links against the Flutter shared library and the required GTK, GLIB, and GIO libraries. This target simplifies dependency management for other parts of the build. ```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) ``` -------------------------------- ### Disable Colliding Windows Macros (CMake) Source: https://github.com/java-james/flutter_dotenv_remote/blob/master/example/windows/runner/CMakeLists.txt This command adds a preprocessor definition to disable Windows-specific macros like NOMINMAX that can conflict with standard C++ library functions. This helps prevent compilation errors and ensures compatibility with the C++ standard library. ```cmake 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.