### Basic CMake Project Setup Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Initializes CMake version and project name. Sets the executable name and GTK application ID. Opts into modern CMake behaviors and sets the installation rpath. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.iodesignteam.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install Application Executable Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs the application's executable to the specified runtime destination. This component is marked as 'Runtime'. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Application Bundle Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Configures the installation process to create a relocatable bundle. Cleans the build bundle directory, installs the executable, ICU data, Flutter library, and bundled plugin libraries. ```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() 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) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs the Flutter library file to the bundle library directory. Ensure FLUTTER_LIBRARY is defined. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Define Installation Directories Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Sets variables for the installation directories of bundle data and libraries. These paths are relative to the CMAKE_INSTALL_PREFIX. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Flutter Assets Directory Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Installs the Flutter assets directory to the application's data directory. It first removes any existing directory to ensure a clean installation. ```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 Bundled Plugin Libraries Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the bundle library directory. This is conditional on PLUGIN_BUNDLED_LIBRARIES being defined. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install AOT Library Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the bundle data directory. This is only done for Profile and Release configurations. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Basic Hive Box Usage Source: https://github.com/io-design-team/hive_ce/blob/main/README.md Demonstrates basic operations of putting and getting data from a Hive box. Ensure Hive is initialized before use. ```dart import 'package:hive_ce/hive_ce.dart'; void example() { final box = Hive.box('myBox'); box.put('name', 'David'); final name = box.get('name'); print('Name: $name'); } ``` -------------------------------- ### Set Installation Prefix for Bundled App Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable, supporting in-place running. This is crucial for Visual Studio builds. ```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() ``` -------------------------------- ### Install Native Assets Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs native assets provided by build.dart to the bundle library directory. The source directory is defined by NATIVE_ASSETS_DIR. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Installs the ICU data file to the bundle data directory. Ensure FLUTTER_ICU_DATA_FILE is defined. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Installs the AOT (Ahead-of-Time) library only for non-Debug build types. This ensures that performance-critical libraries are included in release builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set Flutter Library Path Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Sets the path to the Flutter library DLL. This is published to the parent scope for use in the install step. ```cmake 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) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be removed if custom build settings are required. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Find GTK, GLIB, and GIO Modules Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system-level dependencies: GTK, GLIB, and GIO. These are essential for the Flutter Linux GTK backend. ```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) ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Loads Flutter managed directories and finds system-level GTK dependencies using PkgConfig. Defines the application ID as a preprocessor macro. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Configure Flutter Library and Headers Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/flutter/CMakeLists.txt Sets variables for the Flutter library path and headers, and then configures an interface library named 'flutter' to include these and link against system dependencies. ```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) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 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) ``` -------------------------------- ### Define Application Target and Source Files Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows application and lists all source files, including generated ones. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` compatibility. ```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" ) ``` -------------------------------- ### Application Executable Definition Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files including generated plugin registration. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. This is important for handling international characters correctly. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Configure Flutter Library Interface Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Configures include directories and links the Flutter library. It also adds a dependency on the flutter_assemble target. ```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}/\") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Generated Plugin Rules Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Includes CMake rules for building generated plugins and adding them to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend. It uses a phony output file to ensure the command runs every time and sets necessary environment variables. ```cmake # _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" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) ``` -------------------------------- ### Runtime Output Directory Setting Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory to prevent users from running the unbundled copy. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Include Flutter Subdirectory Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Includes the Flutter managed directory as a subdirectory for building. Ensure the FLUTTER_MANAGED_DIR path is correct. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to avoid warnings with recent CMake versions. Use a version range that suits your project's needs. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Links necessary libraries, including Flutter's core libraries and Windows-specific ones like dwmapi.lib. It also adds the source directory to include paths for easier access to headers. ```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}") ``` -------------------------------- ### Custom Command for Flutter Tool Backend Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script. This command generates the Flutter library and headers, using environment variables and build configurations. A phony target is used to ensure the command runs on every build. ```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 ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Configure Build Configuration Types Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Sets the available build configuration types (Debug, Profile, Release). This differs based on whether the generator supports multi-configuration builds. ```cmake set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) ``` ```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() ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Specifies the minimum required CMake version and the project name. Ensure your CMake version meets this requirement. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Sets linker flags and compiler flags for the Profile build mode, typically inheriting from Release settings. Ensure Release flags are correctly defined elsewhere. ```cmake 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}") ``` -------------------------------- ### Include Runner Subdirectory Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Includes the runner subdirectory for the application's build. Refer to runner/CMakeLists.txt for specific configurations. ```cmake add_subdirectory("runner") ``` -------------------------------- ### Build Type Configuration Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined, and enforces a list of allowed build types. ```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() ``` -------------------------------- ### Cross-Building Configuration Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Configures CMake for cross-building by setting the sysroot and find root path modes when a Flutter target platform sysroot is defined. ```cmake 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() ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/CMakeLists.txt Defines a function to apply standard compilation settings like C++ standard, warning options, optimization levels, and preprocessor definitions. ```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 Flutter Wrapper App Library Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Defines a static library for the Flutter wrapper application, including core and app-specific sources. It applies standard settings and links against the Flutter library. ```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) ``` -------------------------------- ### List Prepend Function for CMake < 3.10 Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/linux/flutter/CMakeLists.txt Defines a custom function 'list_prepend' to prepend an element to a list, as the standard 'list(TRANSFORM ... PREPEND ...)' command is not available in CMake version 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() ``` -------------------------------- ### Define Flutter Wrapper Plugin Library Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Defines a static library for the Flutter wrapper plugin, including core and plugin-specific sources. It applies standard settings, sets position-independent code, and links against the Flutter library. ```cmake 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) ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build, including detailed version information extracted from Flutter build variables. These are useful for conditional compilation based on the application's version. ```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}") ``` -------------------------------- ### Define Standard Compilation Settings Function Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt A function to apply common compilation features, options, and definitions to a target. Use with caution, as it affects multiple targets. Consider applying options to specific targets if needed. ```cmake 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() ``` -------------------------------- ### Set Executable Binary Name Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/CMakeLists.txt Defines the name of the executable file for the application. This can be changed to alter the on-disk name. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Add Flutter Assemble Dependency Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Ensures that the Flutter assembly process is completed before the main application target is built. This is a mandatory step for Flutter Windows applications. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Assemble Custom Target Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the Flutter library, headers, and wrapper sources. This target ensures that the Flutter build artifacts are generated. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/io-design-team/hive_ce/blob/main/hive_flutter/example/windows/runner/CMakeLists.txt Disables Windows-specific macros like NOMINMAX that can conflict with standard C++ 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.