### Installation Bundle Configuration Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Configures the installation process to create a relocatable bundle. It sets the install prefix and ensures a clean build bundle directory. ```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") ``` -------------------------------- ### Configure Installation Prefix and Directories Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Sets up installation paths, ensuring support files are placed next to the executable for in-place running, and makes the 'install' step default for Visual Studio builds. ```cmake 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 Application Executable Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs the main application executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Application and Data Files Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Installs the application executable, ICU data, Flutter library, bundled libraries, and native assets into the installation bundle. ```cmake 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) ``` -------------------------------- ### Install Flutter Assets and AOT Library Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Installs the Flutter assets directory and the AOT library (on non-Debug builds) into the installation bundle. ```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 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() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs the main Flutter library file to the application bundle's root directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/runner/CMakeLists.txt Sets the minimum CMake version and defines the project name and languages for the runner application. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) ``` -------------------------------- ### Install Native Assets Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages into the application bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the application bundle's root directory, if they exist. ```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/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the data directory, but only for Profile and Release build configurations. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Installs the ICU data file to the data directory within the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Project and Build Configuration Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, executable name, and application ID. It also configures build type and installation paths. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # 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() ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Removes existing Flutter assets and then copies the current build's assets into the application's data directory. This ensures assets are always up-to-date. ```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) ``` -------------------------------- ### Flutter Library Path Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Defines the path to the Flutter Windows DLL and exports it to the parent scope for 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) ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Sets the minimum CMake version required and defines the ephemeral directory for generated files. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be customized for applications requiring different build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and specifies include directories for the target. Application-specific dependencies should be added here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### C++ Wrapper App Sources Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Lists and prepends the wrapper root directory to C++ wrapper application source files. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Setting Include Directories Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/runner/CMakeLists.txt Configures the include directories for the runner executable, adding the source directory to the private include path. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### C++ Wrapper Plugin Sources Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Lists and prepends the wrapper root directory to C++ wrapper plugin source files. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Wrapper Root Directory Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Defines the root directory for the C++ client wrapper sources. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Includes the generated configuration file provided by the Flutter tool. ```cmake # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Includes Flutter's managed directory and checks for GTK+ 3.0 using PkgConfig. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Include Generated Plugin Build Rules Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Includes the CMake file that manages building and integrating generated plugins into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Create a Custom Card Style Source: https://github.com/jlogical-apps/card_game/blob/master/README.md Implement `CardGameStyle` to define a custom appearance for your cards and empty spaces. Provide `cardSize`, `cardBuilder`, and `emptyGroupBuilder` for full control. ```dart CardGameStyle( cardSize: Size(64, 89), cardBuilder: (card, isFlipped, state) => MyCustomCard( card: card, isFlipped: isFlipped, state: state, ), emptyGroupBuilder: (state) => MyCustomEmptySpace(state: state), ) ``` -------------------------------- ### Project and Minimum CMake Version Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Sets the minimum required CMake version and the project name with supported languages. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Flutter Library Headers Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Lists and prepends the ephemeral directory to Flutter library header files. ```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}/") ``` -------------------------------- ### Include Flutter and Runner Build Rules Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Adds the Flutter managed directory and the runner's CMakeLists.txt as subdirectories to the build. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Includes the CMake file that manages the build rules for generated plugins. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### C++ Wrapper Core Sources Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Lists and prepends the wrapper root directory to core C++ wrapper source files. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Linking Dependency Libraries Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/runner/CMakeLists.txt Links the necessary libraries for the runner application, including the flutter library and PkgConfig for GTK. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Executable Output Directory Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory to prevent accidental execution of 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" ) ``` -------------------------------- ### Define Build Configuration Types Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Configures the available build types (Debug, Profile, Release) based on whether the generator supports multi-configuration. ```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() ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to avoid warnings in recent CMake versions. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Adding Application ID Preprocessor Definitions Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/runner/CMakeLists.txt Adds preprocessor definitions for the application ID, making it available during compilation. ```cmake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Sets linker and compiler flags for the Profile build mode, typically mirroring Release settings. ```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}") ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt A function to apply common compilation features, options, and definitions to a target. Use with caution for project-wide 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() ``` -------------------------------- ### Flutter Wrapper Plugin Library Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Defines a static library for the Flutter wrapper plugin, applying standard settings and linking against the Flutter library. ```cmake # 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) ``` -------------------------------- ### Flutter Wrapper App Library Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Defines a static library for the Flutter wrapper application, applying standard settings and linking 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) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/flutter/CMakeLists.txt A custom CMake command to execute the Flutter tool backend script, generating the Flutter library and headers. It uses a phony target to ensure execution 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 Preprocessor Definitions for Build Version Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the target to include Flutter version information during compilation. This is useful for embedding version details into the executable. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Flutter Interface Library Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Defines an interface library for Flutter, setting include directories and linking the Flutter library. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Custom list_prepend Function Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/flutter/CMakeLists.txt A custom CMake function to prepend a prefix to each element in a list, as list(TRANSFORM ... PREPEND ...) is not available in CMake 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() ``` -------------------------------- ### Set Executable Name Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/CMakeLists.txt Defines the name of the application's executable file. This can be changed to alter the on-disk name. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/CMakeLists.txt Defines a function to apply common compilation settings like C++ standard, warning flags, optimization levels, and debug definitions to a target. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. 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() ``` -------------------------------- ### Tower of Hanoi Game Implementation Source: https://github.com/jlogical-apps/card_game/blob/master/example/README.md Implements the Tower of Hanoi puzzle using the CardGame widget. It manages the state of the cards across three columns and enforces the game's rules for moving cards. ```dart import 'package:card_game/card_game.dart'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; class TowerOfHanoi extends HookWidget { final int amount; const TowerOfHanoi({super.key, this.amount = 4}); List> get initialCards => [ List.generate(amount, (i) => amount - i), [], [], ]; @override Widget build(BuildContext context) { final cardsState = useState(initialCards); return CardGame( style: numericCardStyle(), children: [ SafeArea( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: cardsState.value .mapIndexed((i, states) => CardColumn( value: i, values: states, maxGrabStackSize: 1, canMoveCardHere: (move) { final movingCard = move.cardValues.last; final movingOnto = states.lastOrNull; return movingOnto == null || movingCard < movingOnto; }, onCardMovedHere: (move) { final newCards = [...cardsState.value]; newCards[move.fromGroupValue].removeLast(); newCards[i].add(move.cardValues.first); cardsState.value = newCards; }, )) .toList(), ), Spacer(), ElevatedButton( onPressed: () => cardsState.value = initialCards, style: ButtonStyle(shape: WidgetStatePropertyAll(CircleBorder())), child: Icon(Icons.restart_alt), ), ], ), ), ], ); } } ``` -------------------------------- ### Configure Card Movement Rules Source: https://github.com/jlogical-apps/card_game/blob/master/README.md Customize how cards can be grabbed and moved within a CardColumn. Use `canCardBeGrabbed` to determine if a card is grabbable and `canMoveCardHere` to define acceptance rules for dropped cards. ```dart CardColumn( // ... other params canCardBeGrabbed: (index, card) => true, // Control which cards can be grabbed maxGrabStackSize: 1, // Limit how many cards can be grabbed at once canMoveCardHere: (moveDetails) => true, // Define rules for accepting cards onCardMovedHere: (moveDetails) {}, // Handle successful moves ) ``` -------------------------------- ### Defining the Executable Target Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/runner/CMakeLists.txt Adds the executable target for the runner application, specifying source files including generated ones. The binary name should be managed in the top-level CMakeLists.txt to ensure `flutter run` compatibility. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Fallback Target Platform Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/flutter/CMakeLists.txt Sets a fallback configuration for FLUTTER_TARGET_PLATFORM if it's not defined, ensuring compatibility with older Flutter tool versions. ```cmake # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Define Executable Target Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows runner application. Any new source files should be added to this list. ```cmake 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" ) ``` -------------------------------- ### Configure Card Interaction and Appearance Source: https://github.com/jlogical-apps/card_game/blob/master/README.md Control card press events and visual states like flipping. Use `onCardPressed` for actions on tap and `isCardFlipped` to manage face-down display. ```dart CardColumn( // ... other params onCardPressed: (card) { // Handle card press events // Useful for flipping cards, selecting cards, or triggering game actions }, isCardFlipped: (index, card) { // Control whether specific cards are shown face-down // Return true to show the card's back, false to show its face return shouldCardBeFlipped(index, card); }, ) ``` -------------------------------- ### Add card_game to pubspec.yaml Source: https://github.com/jlogical-apps/card_game/blob/master/README.md Add the card_game package as a dependency in your Flutter project's pubspec.yaml file. ```yaml dependencies: card_game: ^1.0.0 ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the main target is built. This dependency is crucial for the Flutter build system integration. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Library Interface Target Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library target for Flutter, including system-level dependencies like GTK, GLIB, and GIO, and links the Flutter shared library and headers. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Flutter Assemble Custom Target Source: https://github.com/jlogical-apps/card_game/blob/master/example/linux/flutter/CMakeLists.txt A custom CMake target named 'flutter_assemble' that depends on the generated Flutter library and its headers, ensuring they are built before other targets that might use them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/jlogical-apps/card_game/blob/master/example/windows/runner/CMakeLists.txt Disables Windows-specific macros (NOMINMAX) that might conflict with standard C++ library functions, preventing potential naming collisions. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.