### Installation Bundle Directory Setup Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Configures the installation prefix to be the build bundle directory and ensures it starts clean. ```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) ``` -------------------------------- ### Install Application Executable Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Installs the application executable to the root of the installation prefix. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Installs the main Flutter library file to the bundle's library directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Paths for Bundle Data and Libraries Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Defines the destination directories for bundle data and libraries within the installation prefix. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Installs any bundled plugin libraries to the bundle's library directory. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Runtime Path Configuration Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Configures the installation runtime path to include the 'lib' directory relative to the binary. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Removes stale assets and installs the current Flutter assets directory to the bundle's data directory. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Installs the Flutter ICU data file to the bundle's data directory. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt This snippet installs the AOT library to the runtime component directory only when the build type is not 'Debug'. Ensure the AOT_LIBRARY variable is correctly defined. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### System Dependencies and GTK Check Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Finds and checks for the PkgConfig and GTK system libraries, requiring them for the build. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Find and check PkgConfig modules for GTK, GLIB, and GIO Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/flutter/CMakeLists.txt This snippet uses PkgConfig to find and check for the required GTK, GLIB, and GIO libraries, ensuring they are available for the build. It defines imported targets for each module. ```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) ``` -------------------------------- ### Cross-Building Sysroot Configuration Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Sets up the sysroot and find root path for cross-building based on the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```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() ``` -------------------------------- ### Apply Standard Settings to Executable Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Applies the standard compilation settings defined in APPLY_STANDARD_SETTINGS to the application executable. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries for Application Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Links the necessary libraries, including 'flutter' and GTK, to the application executable. ```cmake # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Runtime Output Directory Configuration Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory to prevent running unbundled copies. ```cmake # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Project and Executable Configuration Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Sets the minimum CMake version, project name, and the executable name for the application. It also defines the GTK application ID. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") ``` -------------------------------- ### Add moxxmpp Dependency Source: https://github.com/moxxy/moxxmpp/blob/master/packages/moxxmpp/README.md Include this dependency in your pubspec file to use the moxxmpp library. ```yaml moxxmpp: hosted: https://git.polynom.me/api/packages/Moxxy/pub version: 0.3.1 ``` -------------------------------- ### Generated Plugin CMake Rules Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Includes the CMake rules for managing and building generated plugins. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Custom command to assemble Flutter library and headers Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/flutter/CMakeLists.txt This custom command executes the Flutter tool backend script to generate the Flutter library and its associated headers. It uses environment variables and build type information. ```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 ) ``` -------------------------------- ### Configure Flutter Interface Library Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/flutter/CMakeLists.txt This section configures an INTERFACE library named 'flutter'. It sets include directories, links against the Flutter shared object, and includes system-level dependencies like GTK, GLIB, and GIO. ```cmake 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) ``` -------------------------------- ### Application ID Definition Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Adds a preprocessor definition for the application ID, using the value set earlier. ```cmake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Application Executable Target Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files. ```cmake # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Add moxxmpp_socket_tcp Dependency Source: https://github.com/moxxy/moxxmpp/blob/master/packages/moxxmpp_socket_tcp/README.md Include this package as a dependency in your project's pubspec file to use its features. ```yaml moxxmpp_socket_tcp: hosted: https://git.polynom.me/api/packages/Moxxy/pub version: 0.1.2+9 ``` -------------------------------- ### Flutter Managed Directory and Subdirectory Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Sets the path to the Flutter managed directory and adds it as a subdirectory for build rules. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Modern CMake Policy Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Define list_prepend function for CMake < 3.10 Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/flutter/CMakeLists.txt This function mimics the behavior of list(TRANSFORM ... PREPEND ...) for older CMake versions (pre-3.10). It prepends a prefix to each element in a list. ```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() ``` -------------------------------- ### Build Type Configuration Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined, and specifies 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() ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Defines a function to apply standard compilation features, options, and definitions to a target. ```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() ``` -------------------------------- ### Flutter Assemble Dependency Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/CMakeLists.txt Ensures that the 'flutter_assemble' target is built before the application executable. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Define flutter_assemble custom target Source: https://github.com/moxxy/moxxmpp/blob/master/example_flutter/linux/flutter/CMakeLists.txt This defines a custom target 'flutter_assemble' that depends on the generated Flutter library and its headers. This target ensures that the Flutter components are built before other dependent targets. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.