### CMake Installation Rules for Application Bundle Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/windows/CMakeLists.txt Configures the installation process for the application bundle. This includes setting the installation prefix, defining directories for data and libraries, and installing the main executable, ICU data, Flutter library, and bundled plugin libraries. ```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() ``` -------------------------------- ### Installation Configuration for Executable and Assets Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/windows/CMakeLists.txt Configures the installation process for the application. It sets the installation prefix to be adjacent to the executable for in-place running, installs the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets. It also ensures assets are copied correctly and the AOT library is installed on non-Debug 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() 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 Installation Rules for Windows Executable Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/localization/windows/CMakeLists.txt Configures the installation process for the Windows build, ensuring runtime files, data, libraries, and native assets are correctly placed next to the executable. It supports Visual Studio's in-place running. ```cmake # === Installation === 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 Build Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/localization/windows/CMakeLists.txt Initializes the CMake project, sets the executable name, and configures build types (Debug, Profile, Release). It ensures modern CMake practices are followed and handles multi-configuration generators. ```cmake cmake_minimum_required(VERSION 3.14) project(wiredash_localization LANGUAGES CXX) set(BINARY_NAME "wiredash_localization") 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) ``` -------------------------------- ### Installation Rules for Windows Executable and Assets (CMake) Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/windows/CMakeLists.txt Configures the installation process for the Windows build. It specifies where the executable, data files, libraries, and native assets should be copied. Ensures that the application can run in place from its installation directory, supporting 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() 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/wiredashio/wiredash-sdk/blob/stable/examples/theming/linux/CMakeLists.txt Initializes the CMake project, sets the project name, and specifies the minimum required CMake version. It also defines the application's executable name and its unique identifier. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "wiredash_theming") set(APPLICATION_ID "io.wiredash.example.wiredash_theming") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/localization/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It sets the install prefix, cleans the build bundle directory, and installs the executable, ICU data, Flutter library, bundled libraries, native assets, and Flutter assets. The AOT library is installed only on non-Debug builds. ```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) 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) if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/linux/CMakeLists.txt Configures the installation process for the application bundle. It ensures a clean bundle directory, installs the main executable, Flutter ICU data, Flutter library, bundled plugin libraries, and native assets. It also handles the installation of 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() ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theming/linux/CMakeLists.txt Defines installation rules for creating a relocatable application bundle. It cleans the build bundle directory, installs the main executable, Flutter 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) ``` -------------------------------- ### Plugin Registration and Installation Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Includes CMake scripts for generated plugin registration and sets up installation rules for creating a relocatable application bundle, including executable, data, libraries, and assets. ```cmake include(flutter/generated_plugins.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) ``` -------------------------------- ### CMake Project and Build Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/linux/CMakeLists.txt Sets up the minimum CMake version, project name, executable name, application ID, and modern CMake behaviors. It also defines installation paths for bundled libraries and handles cross-compilation using sysroot. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "wiredash_theme_editor") set(APPLICATION_ID "io.wiredash.example.wiredash_theme_editor") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 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() 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() ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/windows/CMakeLists.txt Initializes the CMake project, sets the binary name, and configures build modes. It handles multi-configuration generators and sets default build types for single-configuration generators. Dependencies include modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.14) project(wiredash_promoter_score LANGUAGES CXX) set(BINARY_NAME "wiredash_promoter_score") 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) ``` -------------------------------- ### CMake Project Configuration and Build Settings Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/linux/CMakeLists.txt Sets up the CMake project, defines the binary name and application ID, enforces modern CMake policies, and configures installation paths and build types (Debug, Profile, Release). It also loads bundled libraries and defines system-level dependencies like PkgConfig and GTK. ```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 "wiredash_promoter_score") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "io.wiredash.example.wiredash_promoter_score") # 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() # 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) ``` -------------------------------- ### CMake Installation of Native Assets and Flutter Assets Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theming/linux/CMakeLists.txt Installs native assets provided by build.dart and the Flutter assets directory. It ensures these resources are correctly placed within the application bundle during installation. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 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) ``` -------------------------------- ### CMake Installation Rule for AOT Library Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/windows/CMakeLists.txt Installs the Ahead-of-Time (AOT) compiled library. This installation is conditional and only occurs for 'Profile' and 'Release' build configurations, not for 'Debug' builds. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets with CMake Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Configures CMake to install Flutter assets by first removing any existing directory and then copying the new assets. This ensures a clean installation of assets required for the application runtime. It utilizes CMake's install command for directory management. ```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) ``` -------------------------------- ### CMake Installation Rule for Flutter Assets Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/windows/CMakeLists.txt Installs the Flutter assets directory. It first removes any existing assets directory to ensure a clean copy and then copies the assets from the build directory to the installation bundle's 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) ``` -------------------------------- ### CMake: Flutter Library Setup Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/flutter/CMakeLists.txt Configures the Flutter library target for the Wiredash SDK. It finds necessary PkgConfig modules (GTK, GLIB, GIO), sets paths for the Flutter library and ICU data, and defines include directories and link libraries for the Flutter interface target. ```cmake # === Flutter Library === # System-level dependencies. 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) 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) ``` -------------------------------- ### Generate Translations using Shell Script Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/CONTRIBUTION.md This command-line script is used to convert .arb localization files into Dart code. Ensure you are in the project's root directory before executing. ```bash ./tool/localize.sh ``` -------------------------------- ### Define Flutter Library and Headers (CMake) Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/windows/flutter/CMakeLists.txt This snippet defines the Flutter library path, its associated headers, and ICU data file. It also sets up include directories and links the Flutter library. The configuration is published to the parent scope for use in the install step. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) 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) ``` -------------------------------- ### Install AOT Library Conditionally with CMake Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-Debug builds using CMake. This ensures that performance-critical libraries are deployed only when necessary, reducing overhead in debug environments. It checks the CMAKE_BUILD_TYPE variable to determine whether to proceed with the installation. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Configure CMake and Define Project Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/windows/runner/CMakeLists.txt This code snippet sets the minimum required CMake version and defines the project named 'runner' with CXX language support. It's the starting point for configuring the build environment for the Flutter application. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) ``` -------------------------------- ### Initialize Wiredash in Flutter App Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/README.md This Dart code demonstrates how to wrap your application's root widget with the Wiredash widget. You need to provide your unique projectId and secret obtained from the Wiredash Console. This setup enables Wiredash's features throughout your app. ```dart import 'package:flutter/material.dart'; import 'package:wiredash/wiredash.dart'; class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return Wiredash( projectId: 'YOUR-PROJECT-ID', secret: 'YOUR-SECRET', child: MaterialApp( // Your Flutter app is basically Wiredash's direct child. // This can be a MaterialApp, WidgetsApp or whatever widget you like. ), ); } } ``` -------------------------------- ### Force Submit Wiredash Analytics Events Source: https://context7.com/wiredashio/wiredash-sdk/llms.txt This example shows how to manually trigger the submission of analytics events to the server, bypassing the automatic batching mechanism. It is useful for critical actions where immediate event logging is required. Dependencies include the 'wiredash' package. ```dart import 'package:wiredash/wiredash.dart'; import 'package:flutter/material.dart'; // Automatic submission happens every 30 seconds and on app background // Manual submission can be triggered when needed class CriticalActionHandler { Future performCriticalAction(BuildContext context) async { // Track the critical event await Wiredash.of(context).trackEvent('critical_transaction', data: { 'transactionId': 'txn-12345', 'amount': 999.99, 'timestamp': DateTime.now().toIso8601String(), }); // Immediately submit to server (don't wait for batch) await Wiredash.of(context).forceSubmitEvents(); print('Critical event submitted immediately'); } } // Also works with WiredashAnalytics instance class AnalyticsManager { final WiredashAnalytics analytics = WiredashAnalytics(); Future trackAndSubmit(String eventName, Map data) async { await analytics.trackEvent(eventName, data: data); // Force immediate submission for important events // Note: This requires a mounted Wiredash widget // Events are automatically submitted in batches otherwise } } ``` -------------------------------- ### Custom Theme Configuration for Wiredash in Flutter Source: https://context7.com/wiredashio/wiredash-sdk/llms.txt Customize the appearance of Wiredash UI components by providing a custom `WiredashThemeData`. This example demonstrates setting primary and secondary colors, brightness, background colors, text styles, and drawing pen colors for annotations. It requires the 'flutter/material.dart' and 'wiredash/wiredash.dart' packages. ```dart import 'package:flutter/material.dart'; import 'package:wiredash/wiredash.dart'; Wiredash buildCustomThemedWiredash(Widget child) { return Wiredash( projectId: 'your-project-id', secret: 'your-secret-key', theme: WiredashThemeData.fromColor( primaryColor: Colors.indigo, secondaryColor: Colors.purple, brightness: Brightness.dark, ).copyWith( // Container colors primaryContainerColor: Colors.indigo[800], textOnPrimaryContainerColor: Colors.white, secondaryContainerColor: Colors.indigo[400], textOnSecondaryContainerColor: Colors.white, // Background colors primaryBackgroundColor: Colors.black87, secondaryBackgroundColor: Colors.black54, appBackgroundColor: Colors.black, appHandleBackgroundColor: Colors.grey[900], // Text styling textTheme: WiredashTextTheme( headlineMedium: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, ), headlineSmall: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, ), ), // Drawing pen colors for screenshot annotation firstPenColor: Colors.yellow, secondPenColor: Colors.red, thirdPenColor: Colors.cyan, fourthPenColor: Colors.green, errorColor: Colors.redAccent, ), child: child, ); } ``` -------------------------------- ### CMake: Configure Flutter Library and Build Paths Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/promoter_score/linux/flutter/CMakeLists.txt Sets up essential variables for the Flutter build, including the path to the Flutter Linux GTK shared library (`libflutter_linux_gtk.so`) and the ICU data file (`icudtl.dat`). It also defines the project's build directory. These variables are exposed to the parent scope for use in installation steps. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 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 Project Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theming/windows/CMakeLists.txt Sets up the minimum CMake version, project name, and languages. It also defines the executable binary name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(wiredash_theming LANGUAGES CXX) set(BINARY_NAME "wiredash_theming") cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Display Promoter Score (NPS) Survey in Flutter with Wiredash Source: https://context7.com/wiredashio/wiredash-sdk/llms.txt Implement and trigger Promoter Score (NPS) surveys using the Wiredash SDK. This example shows automatic triggering after a delay, options for survey frequency, initial delay, and minimum app starts, as well as collecting metadata during the survey. It also includes a button to force-show the survey for testing. Dependencies include 'flutter/material.dart' and 'wiredash/wiredash.dart'. ```dart import 'package:flutter/material.dart'; import 'package:wiredash/wiredash.dart'; class PromoterScoreExample extends StatefulWidget { @override State createState() => _PromoterScoreExampleState(); } class _PromoterScoreExampleState extends State { @override void initState() { super.initState(); // Automatically show survey after key user action Future.delayed(Duration(seconds: 3), () { if (!mounted) return; _triggerPromoterSurvey(); }); } Future _triggerPromoterSurvey() async { final wasShown = await Wiredash.of(context).showPromoterSurvey( inheritMaterialTheme: true, options: PsOptions( frequency: Duration(days: 90), initialDelay: Duration(days: 7), minimumAppStarts: 3, collectMetaData: (metaData) => metaData ..userEmail = 'user@example.com' ..custom['surveyTrigger'] = 'post_purchase' ..custom['lifetimeValue'] = 299.99, ), ); if (wasShown) { print('Promoter score survey was shown to user'); } else { print('Survey skipped based on frequency/timing rules'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('NPS Survey Demo')), floatingActionButton: FloatingActionButton( onPressed: () { // Force show for testing (bypasses frequency rules) Wiredash.of(context).showPromoterSurvey(force: true); }, child: Icon(Icons.star_outlined), ), body: Center(child: Text('Complete key actions to trigger survey')), ); } } ``` -------------------------------- ### Launch Wiredash Feedback Flow Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/example/README.md Initiate the Wiredash feedback collection process from any part of your application by calling the `Wiredash.show()` method. This method can optionally inherit the Material theme of the current context. ```dart Wiredash.of(context).show(inheritMaterialTheme: true); ``` -------------------------------- ### Initialize Wiredash Widget in Flutter Source: https://context7.com/wiredashio/wiredash-sdk/llms.txt Sets up the Wiredash SDK by wrapping the root application widget. Requires project ID, secret, and environment. Allows customization of theme and metadata collection. ```dart import 'package:flutter/material.dart'; import 'package:wiredash/wiredash.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return Wiredash( projectId: 'your-project-id', secret: 'your-secret-key', environment: 'prod', // Optional: 'prod', 'dev', 'staging' theme: WiredashThemeData.fromColor( primaryColor: Colors.blue, brightness: Brightness.light, ), collectMetaData: (metaData) => metaData ..userId = 'user-123' ..userEmail = 'user@example.com' ..custom['subscription'] = 'premium' ..custom['accountType'] = 'business', child: MaterialApp( home: HomePage(), ), ); } } ``` -------------------------------- ### Application Executable Definition and Linking Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Defines the main application executable, lists its source files, applies standard build settings, and links necessary libraries including Flutter and GTK. ```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) ``` -------------------------------- ### CMake Project Initialization and Build Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/windows/CMakeLists.txt Initializes the CMake project, sets the binary name, and configures build types (Debug, Profile, Release) based on whether the generator is multi-configuration. It also sets specific linker and compiler flags for the Profile build mode. ```cmake cmake_minimum_required(VERSION 3.14) project(wiredash_theme_editor LANGUAGES CXX) set(BINARY_NAME "wiredash_theme_editor") 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}") ``` -------------------------------- ### CMake Build Configuration for Wiredash SDK Application Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/linux/runner/CMakeLists.txt This snippet configures the CMake build system for the Wiredash SDK application. It defines the executable target, lists source files, applies standard build settings, sets preprocessor definitions for the application ID, and links necessary libraries like Flutter and GTK. It also specifies include directories. ```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}") ``` -------------------------------- ### CMake Standard Compilation Settings Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theming/windows/CMakeLists.txt Applies standard compilation features, options, and definitions to a target, including C++17 support, warning levels, and exception handling settings. ```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() ``` -------------------------------- ### CMake Project Configuration and Settings Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Sets up the minimum CMake version, project name, executable name, and application ID. It also includes policies for modern CMake behavior and configures library loading paths. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "old_flutter_3_0") set(APPLICATION_ID "io.wiredash.example.old_flutter_3_0") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### CMake Project and Build Configuration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/localization/linux/CMakeLists.txt Sets up the minimum CMake version, project name, and executable name. It also defines the application ID and configures build type strings for Debug, Profile, and Release modes. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "wiredash_localization") set(APPLICATION_ID "io.wiredash.example.wiredash_localization") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 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() 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() ``` -------------------------------- ### CMake Function for Standard Build Settings Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/localization/windows/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, options, and definitions to specified targets. This promotes consistency across build targets. ```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() ``` -------------------------------- ### Define Application Target in CMake Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/windows/runner/CMakeLists.txt This snippet defines the main executable target for the application using CMake. It specifies the source files, including C++ files, generated plugin registrant, and resource files. Any new source files should be added to this list. The target name is derived from BINARY_NAME, which should be configured 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" ) ``` -------------------------------- ### Flutter and System Dependency Integration Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/linux/CMakeLists.txt Integrates the Flutter SDK by adding its directory as a subdirectory and finds necessary system libraries like GTK+ 3.0 using PkgConfig. ```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}") ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/theme_editor/windows/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features and options to specified targets. This includes setting the C++ standard to C++17, enabling detailed warning levels, and defining specific preprocessor macros. ```cmake add_definitions(-DUNICODE -D_UNICODE) 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() ``` -------------------------------- ### Configure Flutter Tool Backend Command (CMake) Source: https://github.com/wiredashio/wiredash-sdk/blob/stable/examples/old_flutter_3_0/windows/flutter/CMakeLists.txt This snippet configures a custom command to run the Flutter tool backend. It uses a phony output file to ensure the command executes on every build, as direct input/output tracking is not yet supported. The command sets up the environment and calls the tool backend script with platform and configuration arguments. ```cmake # === 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} ) ```