### Basic CMake Project Setup Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Initializes the CMake version and project name. Sets the binary and application ID. Configures installation paths and build type. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) 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() # Configure build 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() ``` -------------------------------- ### Installation Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Configures installation paths and components for the application and its assets. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) 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() # 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. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Application Bundle Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. This includes cleaning the bundle directory, installing the executable, data files, libraries, and assets. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # 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() ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Initializes the CMake version and project name. Sets the binary name for the executable. ```cmake cmake_minimum_required(VERSION 3.14) project(launch_at_startup_example LANGUAGES CXX) set(BINARY_NAME "launch_at_startup_example") ``` -------------------------------- ### Basic CMake Setup and Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Initializes CMake version, sets up an ephemeral directory, and includes generated configuration. It also defines fallback configurations for Flutter target platform if not already set. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### macOS Platform Channel Setup for launch_at_startup Source: https://github.com/leanflutter/launch_at_startup/blob/main/README.md Integrate the LaunchAtLogin module into your Flutter window's Swift file to handle platform channel calls for checking and setting launch at login status. ```swift import Cocoa import FlutterMacOS // Add the LaunchAtLogin module import LaunchAtLogin // class MainFlutterWindow: NSWindow { override func awakeFromNib() { let flutterViewController = FlutterViewController.init() let windowFrame = self.frame self.contentViewController = flutterViewController self.setFrame(windowFrame, display: true) // Add FlutterMethodChannel platform code FlutterMethodChannel( name: "launch_at_startup", binaryMessenger: flutterViewController.engine.binaryMessenger ) .setMethodCallHandler { (_ call: FlutterMethodCall, result: @escaping FlutterResult) in switch call.method { case "launchAtStartupIsEnabled": result(LaunchAtLogin.isEnabled) case "launchAtStartupSetEnabled": if let arguments = call.arguments as? [String: Any] { LaunchAtLogin.isEnabled = arguments["setEnabledValue"] as! Bool } result(nil) default: result(FlutterMethodNotImplemented) } } // RegisterGeneratedPlugins(registry: flutterViewController) super.awakeFromNib() } } ``` -------------------------------- ### Flutter Library and Dependencies Setup Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/flutter/CMakeLists.txt Configures the Flutter library by finding system-level dependencies using PkgConfig (GTK, GLIB, GIO), setting the path to the Flutter library and ICU data file, and defining include directories and interface libraries for the 'flutter' target. It also adds a dependency on 'flutter_assemble'. ```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) ``` -------------------------------- ### Flutter Library Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Defines the Flutter library path, ICU data file, project build directory, and AOT library path. These are published to the parent scope for use in the install step. ```cmake # === 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) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom command to build the Flutter library and headers using the Flutter tool backend script. The `_phony_` target is used as a workaround to ensure the command runs on every build, as there's no direct way to get a full input/output list from the Flutter tool. This command is part of the `flutter_assemble` custom target. ```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. 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} ) ``` -------------------------------- ### macOS Build Phase Script for launch_at_startup Source: https://github.com/leanflutter/launch_at_startup/blob/main/README.md Add a 'Run Script Phase' in Xcode's Build Phases to copy the LaunchAtLogin helper bundle. Ensure it's placed correctly and 'Based on dependency analysis' is unchecked. ```sh "${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh" ``` -------------------------------- ### Basic Flutter Usage of launch_at_startup Source: https://github.com/leanflutter/launch_at_startup/blob/main/README.md Initialize the plugin with app details and then enable, disable, or check the status of auto-launch functionality. Ensure Flutter bindings are initialized before use. ```dart import 'dart:io'; import 'package:launch_at_startup/launch_at_startup.dart'; import 'package:package_info_plus/package_info_plus.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); PackageInfo packageInfo = await PackageInfo.fromPlatform(); launchAtStartup.setup( appName: packageInfo.appName, appPath: Platform.resolvedExecutable, // Set packageName parameter to support MSIX. packageName: 'dev.leanflutter.examples.launchatstartupexample', ); await launchAtStartup.enable(); await launchAtStartup.disable(); bool isEnabled = await launchAtStartup.isEnabled(); runApp(const MyApp()); } // ... ``` -------------------------------- ### Add launch_at_startup from Git to pubspec.yaml Source: https://github.com/leanflutter/launch_at_startup/blob/main/README.md Alternatively, add the launch_at_startup package directly from its Git repository to your Flutter project's pubspec.yaml file. ```yaml dependencies: launch_at_startup: git: url: https://github.com/leanflutter/launch_at_startup.git ref: main ``` -------------------------------- ### Add launch_at_startup to pubspec.yaml Source: https://github.com/leanflutter/launch_at_startup/blob/main/README.md Include the launch_at_startup package as a dependency in your Flutter project's pubspec.yaml file. ```yaml dependencies: launch_at_startup: ^0.5.1 ``` -------------------------------- ### Flutter Tool Backend Integration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command to run the Flutter tool backend. This command is designed to run every time by using a phony output file, ensuring up-to-date build artifacts. ```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" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/runner/CMakeLists.txt Defines the minimum required CMake version, project name, and language. It then lists the source files for the executable, applies standard settings, sets compile definitions, links necessary libraries, and adds include directories and dependencies. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) apply_standard_settings(${BINARY_NAME}) target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Profile Build Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Copies release linker and compiler flags to the profile configuration for consistent performance testing. ```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}") ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Includes Flutter build rules and finds PkgConfig modules for GTK. Defines the application ID as a preprocessor macro. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") # Flutter library and tool build rules. add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Configuring Build Types (Multi-Config Generators) Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) for multi-configuration CMake generators. ```cmake 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() ``` -------------------------------- ### Flutter Library Headers and Interface Library Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Lists Flutter library headers, transforms their paths, and creates an INTERFACE library for Flutter. It also sets include directories and links against the Flutter library. ```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) ``` -------------------------------- ### Unicode Support Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support in the project. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Flutter Integration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory and generated plugin CMake rules. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") # Flutter library and tool build rules. add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Generated Plugin Integration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Includes the CMake script for integrating generated plugins into the build. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### C++ Wrapper Library for Plugins Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Configures the C++ wrapper library for plugins, including core and plugin-specific sources. It applies standard settings, sets visibility to hidden, and links against the Flutter library. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # 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) ``` -------------------------------- ### Application Executable Target Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Defines the main executable target, listing its source files. Applies standard settings, links Flutter and GTK libraries, and adds a dependency on the Flutter assembly. ```cmake # Application build 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) # 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" ) ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/CMakeLists.txt Defines a function to apply common compilation features, options, and definitions to a target. This includes C++ standard, warning levels, optimization, and NDEBUG definition. ```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() ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt A function to apply common compilation features, options, and definitions to a target. ```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() ``` -------------------------------- ### C++ Wrapper Library for Application Runner Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/flutter/CMakeLists.txt Configures the C++ wrapper library for the application runner, including core and application-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) ``` -------------------------------- ### CMake Policy and RPATH Configuration Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/windows/CMakeLists.txt Sets a specific CMake policy and configures the RPATH for runtime libraries. ```cmake cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Custom List Prepend Function Source: https://github.com/leanflutter/launch_at_startup/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom function `list_prepend` to add a prefix to each element of a list. This is a workaround for older CMake versions (pre-3.10) that do not support `list(TRANSFORM ... PREPEND ...)`. It iterates through the list, prepends the prefix to each element, 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() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.