### Basic CMake Project Setup Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/runner/CMakeLists.txt Sets the minimum required CMake version and defines the project name and languages. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) ``` -------------------------------- ### Install Application Executable Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/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) ``` -------------------------------- ### Installation Directories Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Defines the destination directories for data and libraries within the installation bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Flutter Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Installs the main Flutter library file to the library directory of the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Installs all bundled libraries provided by plugins to the library directory within the installation bundle. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Installation Prefix Configuration Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Configures the installation prefix to be the build bundle directory by default, ensuring a relocatable application. ```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 Native Assets Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Installs native assets provided by packages to the library directory within the installation bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the library directory of the application bundle, if they exist. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Basic CMake Setup and Configuration Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Sets up the minimum CMake version and defines the ephemeral directory. It also includes generated configuration and sets fallback target platforms if not defined. ```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() ``` -------------------------------- ### Linking Dependencies and Include Directories Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/runner/CMakeLists.txt Links the application target with the 'flutter' and 'PkgConfig::GTK' libraries, and sets up include directories. Ensure these dependencies are correctly installed and configured. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Install AOT Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/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) ``` -------------------------------- ### Project and CMake Version Setup Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Sets the minimum required CMake version and the project name. It also defines the executable name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") ``` -------------------------------- ### Install Native Assets Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages into the library directory of 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) ``` -------------------------------- ### Set Installation Prefix for Bundle Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable for running in place, especially for Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install ICU Data File Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Installs the ICU data file to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library (Non-Debug) Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the library directory, but only for non-Debug build configurations. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Clean Build Bundle Directory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Installs a code that removes the build bundle directory before installation to ensure a clean state. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Installs the Flutter assets directory into the data directory of the application bundle. It ensures the directory is re-copied on each build to avoid stale files. ```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) ``` -------------------------------- ### Basic Cipher Unit Test with cryptography_test Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_test/README.md Demonstrates how to use `testCipher` to perform automatic sanity checks on a custom cipher implementation. Includes an example of adding custom test vectors. ```dart import 'package:cryptography_test/cryptography_test.dart'; import 'package:cryptography_test/cipher.dart'; void main() { testCipher( builder: () => MyCipher(someParameter: 123), // `testCipher` will do various automatic sanity checks such as: // decrypt(encrypt(input)) // ...with various interesting inputs. // // You can give it real test vectors too: otherTests: () { test('test vector', () async { await expectCipherExample( clearText: hexToBytes('01 23 45 67 89 ab cd ef'), secretKey: hexToBytes('01 23 45 67 89 ab cd ef'), nonce: hexToBytes('01 23 45 67 89 ab cd ef'), aad: hexToBytes('01 23 45 67 89 ab cd ef'), cipherText: hexToBytes('01 23 45 67 89 ab cd ef'), mac: hexToBytes('01 23 45 67 89 ab cd ef'), ); }); }, ); } ``` -------------------------------- ### Decode JWK to SecretKey Source: https://github.com/dint-dev/cryptography/blob/master/jwk/README.md Decodes a JWK JSON object into a SecretKey. This example specifically handles an Octet Sequence (OCT) key type intended for A128KW algorithm. ```dart import 'package:jwk/jwk.dart'; void main() { final jwk = Jwk.fromJson({ 'kty': 'OCT', 'alg': 'A128KW', 'k': 'GawgguFyGrWKav7AX4VKUg', }); final secretKey = jwk.toSecretKey(); } ``` -------------------------------- ### Export Flutter Library and ICU Data Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Makes the Flutter library path and the ICU data file available to the parent scope for use in installation steps. This ensures these critical files are accessible. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### System Dependencies (PkgConfig and GTK) Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Finds and checks for the PkgConfig tool and the GTK+ 3.0 library, making its imported target available. ```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/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/flutter/CMakeLists.txt This snippet uses PkgConfig to find and check for the required GTK, GLIB, and GIO modules. These are system-level dependencies for the Flutter Linux embedding. ```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/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Sets up the sysroot and search paths for cross-compiling Flutter applications. ```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 Build Settings Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Applies a predefined set of standard build settings to the specified target. This is a convenience function that can be removed if custom build settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Adding Executable Target and Source Files Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/runner/CMakeLists.txt Defines the main executable target for the application, listing all necessary source files including generated ones. Ensure all application source files are included here. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Flutter Wrapper Application Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Creates a static library for the Flutter wrapper application, applying standard settings, and linking the Flutter library with specified include directories. ```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" ) ``` -------------------------------- ### Link Dependencies and Include Directories Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and adds include directories for the application target. Custom application-specific dependencies can also 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}") ``` -------------------------------- ### Add Dependency Libraries and Include Directories Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Specifies the libraries and include directories required for the application's build. This includes Flutter-specific libraries, Windows system libraries, and project-specific include paths. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Includes the CMake script that manages building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Library Load Path Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Configures the runtime search path for bundled libraries to be relative to the executable. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Define C++ Wrapper Plugin Sources Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Lists the C++ source files specific to plugin registration within the Flutter client wrapper. These are used when building plugins. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Create Static Library for Flutter Wrapper Plugin Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter wrapper intended for plugins. It links against the core wrapper sources and the main Flutter library. ```cmake 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 Plugin Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Creates a static library for the Flutter wrapper plugin, applying standard settings, setting position-independent code and hidden visibility, and linking 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) ``` -------------------------------- ### Set Wrapper Root Directory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Defines the root directory for C++ client wrapper sources. This path is used to locate wrapper implementation files. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Build Configuration Types Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Defines the available build configuration types (Debug, Profile, Release) and sets the default build type if not already specified. ```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() ``` -------------------------------- ### Define C++ Wrapper Core Sources Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Lists the core C++ source files for the Flutter client wrapper. These files provide fundamental implementations for engine interaction. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Link Application Dependencies Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/runner/CMakeLists.txt Links the necessary libraries for the application. This includes the main Flutter library and PkgConfig for GTK, ensuring all required components are available at link time. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### X25519 Key Agreement Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Illustrates how to perform key agreement using the X25519 algorithm to establish a shared secret between two parties. ```dart import 'package:cryptography/cryptography.dart'; Future main() async { final algorithm = X25519(); // Alice chooses her key pair final aliceKeyPair = await algorithm.newKeyPair(); // Alice knows Bob's public key final bobKeyPair = await algorithm.newKeyPair(); final bobPublicKey = await bobKeyPair.extractPublicKey(); // Alice calculates the shared secret. final sharedSecret = await algorithm.sharedSecretKey( keyPair: aliceKeyPair, remotePublicKey: bobPublicKey, ); final sharedSecretBytes = await sharedSecret.extractBytes(); print('Shared secret: $sharedSecretBytes'); } ``` -------------------------------- ### Modern CMake Policy Opt-in Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Argon2id Password Hashing Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Shows how to hash a password using the Argon2id algorithm with specified memory, parallelism, iterations, and hash length. ```dart import 'package:cryptography/cryptography.dart'; Future main() async { final algorithm = Argon2id( memory: 10*1000, // 10 MB parallelism: 2, // Use maximum two CPU cores. iterations: 1, // For more security, you should usually raise memory parameter, not iterations. hashLength: 32, // Number of bytes in the returned hash ); final secretKey = await algorithm.deriveKeyFromPassword( password: 'qwerty', nonce: [1, 2, 3], ); final secretKeyBytes = await secretKey.extractBytes(); print('Hash: ${secretKeyBytes}'); } ``` -------------------------------- ### Create Static Library for Flutter Wrapper Application Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter wrapper used by the application runner. It includes core wrapper sources and application-specific components. ```cmake 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) ``` -------------------------------- ### Set Include Directories Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/runner/CMakeLists.txt Specifies the include directories for the target. This allows the compiler to find header files located in the source directory. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Unicode Support Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### C++ Wrapper Source Definitions Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Defines lists of C++ wrapper source files categorized for core, plugin, and application use, transforming paths to be relative to the wrapper root. ```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}/") ``` -------------------------------- ### Flutter Library Headers and Interface Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Appends Flutter library headers, transforms paths, and creates an INTERFACE library for Flutter, setting include directories and linking 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) ``` -------------------------------- ### Custom command to assemble Flutter library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/flutter/CMakeLists.txt Defines a custom command to assemble the Flutter library and headers. This command is executed by the `flutter_assemble` target and uses the `tool_backend.sh` script to perform the build. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Define C++ Wrapper Application Sources Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Lists the C++ source files required for the Flutter application runner. These include components for managing the Flutter engine and view. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Executable Output Directory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Sets the runtime output directory for the main executable to a specific subdirectory, preventing direct execution of unbundled copies. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/runner/CMakeLists.txt Adds preprocessor definitions to the target for build version information, including major, minor, patch, and build numbers. ```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}") ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Includes a CMake file that contains configuration generated by the Flutter tool. This file provides project-specific settings. ```cmake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Add Flutter Subdirectory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Includes the Flutter build rules from the specified Flutter managed directory. ```cmake add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Deterministic Key Generation in Tests Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Use `SecureRandom.forTesting` with a specific seed to generate predictable secret keys in tests. This ensures that cryptographic operations are repeatable. ```dart import 'package:cryptography/cryptography.dart'; void main() { setUp(() { Cryptography.instance = Cryptography.instance.withRandom(SecureRandom.forTesting(seed: 42)); }); test('example', () async { final algorithm = AesGcm.with256bits(); // This will will always return the same secret key. // because we use a deterministic random number generator. final secretKey = await algorithm.newSecretKey(); // ... }); } ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script, generating necessary output files like the Flutter library and headers. A phony output is used to ensure execution. ```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 ) ``` -------------------------------- ### Sha256 Hashing Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Demonstrates how to compute a SHA-256 hash by adding multiple byte chunks to a hash sink and then closing it. ```dart import 'package:cryptography/cryptography.dart'; Future main() async { final sink = Sha256().newHashSink(); // Add all parts of the authenticated message sink.add([1, 2, 3]); sink.add([4, 5]); sink.add([6]); // Calculate hash sink.close(); final hash = await sink.hash(); print('SHA-512 hash: ${hash.bytes}'); } ``` -------------------------------- ### Profile Build Mode Linker and Compiler Flags Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Sets linker and compiler flags for the Profile build mode, typically inheriting from 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}") ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build configuration to embed Flutter version information directly into the executable. This allows the application to access version details at runtime. ```cmake # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Custom Command for Flutter Tool Backend Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command is set up to run every time due to the use of a dummy output file '_phony_'. It passes environment variables and build configurations to the script. ```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 ) ``` -------------------------------- ### Executable and Application ID Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Defines the name of the executable and the unique GTK application identifier for the application. ```cmake set(BINARY_NAME "cryptography_flutter_integration_test") set(APPLICATION_ID "com.example.cryptography_flutter_integration_test") ``` -------------------------------- ### Add Runner Subdirectory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Includes the runner directory as a subdirectory for building the application. ```cmake add_subdirectory("runner") ``` -------------------------------- ### AES-GCM Authenticated Encryption and Decryption Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Demonstrates encrypting and decrypting a string using AES in Galois/Counter Mode (GCM) with a randomly generated secret key and nonce. ```dart import 'dart:convert'; import 'package:cryptography/cryptography.dart'; Future main() async { // Choose the cipher final algorithm = AesGcm.with256bits(); // Generate a random secret key. final secretKey = await algorithm.newSecretKey(); final secretKeyBytes = await secretKey.extractBytes(); print('Secret key: ${secretKeyBytes}'); // Encrypt final secretBox = await algorithm.encryptString( 'Hello!', secretKey: secretKey, ); print('Nonce: ${secretBox.nonce}'); // Randomly generated nonce print('Ciphertext: ${secretBox.cipherText}'); // Encrypted message print('MAC: ${secretBox.mac}'); // Message authentication code // If you are sending the secretBox somewhere, you can concatenate all parts of it: final concatenatedBytes = secretBox.concatenation(); print('All three parts concatenated: $concatenatedBytes'); // Decrypt final clearText = await algorithm.decryptString( secretBox, secretKey: secretKey, ); print('Cleartext: $clearText'); // Hello! } ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Defines a function to apply standard compilation features, options, and definitions to a target, including C++17 support and specific warning configurations. ```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 Flutter Library Path Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Sets the path to the main Flutter library DLL. This is a core component for running Flutter applications on Windows. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") ``` -------------------------------- ### Add Flutter Subdirectory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/CMakeLists.txt Includes the Flutter managed directory as a subdirectory for building. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Adding Application ID Preprocessor Definition Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/runner/CMakeLists.txt Adds a preprocessor definition for the application ID, making it available to the C++ code. The APPLICATION_ID variable must be defined elsewhere. ```cmake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Define list_prepend function for CMake < 3.10 Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/flutter/CMakeLists.txt This function prepends a prefix to each element in a list. It is used because the list(TRANSFORM ... PREPEND ...) command is not available in CMake version 3.10. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Add Flutter library interface target Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/flutter/CMakeLists.txt Creates an INTERFACE library target for Flutter, specifying include directories and linking against the Flutter library and PkgConfig modules (GTK, GLIB, GIO). This simplifies dependency management for other targets. ```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) ``` -------------------------------- ### Add cryptography_test to pubspec.yaml Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_test/README.md Add the cryptography_test package as a dev dependency in your pubspec.yaml file. ```yaml dev_dependencies: cryptography_test: any ``` -------------------------------- ### Flutter Managed Directory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Sets the path to the Flutter managed directory, typically containing Flutter's build artifacts. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") ``` -------------------------------- ### Export Project Build Directory and AOT Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Exports the project's build directory and the Ahead-Of-Time (AOT) compiled library path to the parent scope. These are essential for linking and deployment. ```cmake set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Create Flutter Interface Library Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Defines an INTERFACE library target named 'flutter'. This target is used to manage include directories and link against 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) ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Specifies the minimum required version of CMake for the project. This ensures compatibility with necessary features. ```cmake cmake_minimum_required(VERSION 3.14) ``` -------------------------------- ### Define Flutter library and header paths Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/linux/flutter/CMakeLists.txt Sets variables for the Flutter library path and ICU data file, as well as the project build directory and AOT library path. These are essential for linking and locating Flutter resources. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### Define Linux Runner Executable Target Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/runner/CMakeLists.txt Defines the main executable target for the Linux runner. Source files for the application, including generated plugin registrant code, are listed here. The binary name should be managed in the top-level CMakeLists.txt to ensure `flutter run` compatibility. ```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" ) ``` -------------------------------- ### Add Dependencies to pubspec.yaml Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/README.md Include the cryptography and cryptography_flutter packages in your Flutter project's pubspec.yaml file. ```yaml dependencies: cryptography: ^2.9.0 cryptography_flutter: ^2.3.4 ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Applies common compilation features and options to a target, including C++14 standard, warnings, optimization levels, 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() ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's build artifacts are available before the application target is built. This is a mandatory step for Flutter projects to function correctly. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Add Flutter Assemble Dependency Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This is a required step for the Flutter build process. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Ed25519 Digital Signature Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Demonstrates generating a key pair, signing a message, and verifying the signature using the Ed25519 algorithm. ```dart import 'package:cryptography/cryptography.dart'; Future main() async { // The message that we will sign final message = [1, 2, 3]; // Generate a keypair. final algorithm = Ed25519(); final keyPair = await algorithm.newKeyPair(); // Sign final signature = await algorithm.sign( message, keyPair: keyPair, ); print('Signature: ${signature.bytes}'); print('Public key: ${signature.publicKey.bytes}'); // Verify signature final isSignatureCorrect = await algorithm.verify( message, signature: signature, ); print('Correct signature: $isSignatureCorrect'); } ``` -------------------------------- ### Encode KeyPair to JWK Source: https://github.com/dint-dev/cryptography/blob/master/jwk/README.md Encodes a generated RSA-PSS KeyPair into a JWK object and then to JSON format. Ensure the cryptography package is available for key generation. ```dart import 'package:cryptography/cryptography.dart'; import 'package:jwk/jwk.dart'; Future main() async { final keyPair = await RsaPss().newKeyPair(); final jwk = Jwk.fromKeyPair(keyPair); final json = jwk.toJson(); } ``` -------------------------------- ### Create Flutter Assemble Custom Target Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the output of the Flutter tool backend command. This target ensures that all necessary Flutter assets and libraries are built before other targets that depend on them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Define Flutter Windows Executable Target Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows runner application. It lists all source files, including C++ files, generated files, and resource files, that constitute the application. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### Define Ephemeral Directory Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Sets a variable for the ephemeral build directory, which is used for generated build artifacts. This path is relative to the current source directory. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Add Cryptography to pubspec.yaml Source: https://github.com/dint-dev/cryptography/blob/master/cryptography/README.md Include the cryptography package in your project's dependencies. For Flutter projects, consider adding cryptography_flutter for OS-level API integration. ```yaml dependencies: cryptography: ^2.9.0 # If you are writing a Flutter app/package, also add this: cryptography_flutter: ^2.3.4 ``` -------------------------------- ### Define Flutter Library Headers Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Appends a list of Flutter library header files to a variable. These headers are necessary for C++ integration with the Flutter engine. ```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}/") ``` -------------------------------- ### Build Type Configuration Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined, and restricts it to valid Flutter build modes. ```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() ``` -------------------------------- ### Custom Target for Flutter Assembly Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/linux/flutter/CMakeLists.txt Creates a custom target 'flutter_assemble' that depends on the Flutter library and its headers. This target ensures that the Flutter library is built before other targets that depend on it. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Set Fallback Target Platform Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/flutter/CMakeLists.txt Sets a default value for FLUTTER_TARGET_PLATFORM if it's not already defined. This is useful for older versions of the Flutter tool. ```cmake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter_integration_test/windows/runner/CMakeLists.txt Disables Windows-specific macros (NOMINMAX) that might conflict with C++ standard library functions. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/dint-dev/cryptography/blob/master/cryptography_flutter/example/windows/runner/CMakeLists.txt Disables specific Windows macros (NOMINMAX) that can conflict with standard C++ library functions, preventing potential compilation errors or unexpected behavior. ```cmake # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.