### Basic CMake Project Setup Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Initializes CMake version and project name. Sets the executable name and GTK application ID. Opts into modern CMake behaviors and sets the installation rpath. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Installation Rules for Application Bundle Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Configures the installation process to create a relocatable bundle in the build directory. Installs the executable, ICU data, Flutter library, bundled plugin libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Run Example Application Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Builds and runs the example application for manual testing. This command is run from the root of the repository. ```bash melos run launchdarkly_flutter_example ``` -------------------------------- ### Install Application Executable Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Installs the application executable to the runtime destination, typically next to other bundled files. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle's runtime directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Bootstrap Project Dependencies Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Installs project dependencies using Melos. This command should be run from the root of the repository. ```bash melos bootstrap ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Installs any bundled native libraries provided by plugins to the application bundle's runtime directory. ```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/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compilation 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 AOT Library (Non-Debug) Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Installs the AOT (Ahead-Of-Time) compiled library to the application's library directory. This installation is conditional and only occurs on non-Debug builds. ```cmake # 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 Assets Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Removes any existing Flutter assets directory and then copies the current build's Flutter assets to the application's data directory. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Run SSE Contract Test Server with Dart SDK Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/apps/sse_contract_test_service/README.md Navigate to the service directory, get dependencies, and run the server using the Dart SDK. The server will listen on port 8080. ```bash cd sse_contract_test_service dart pub get dart run bin/sse_contract_tests.dart Server listening on port 8080 ``` -------------------------------- ### Install Native Assets Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Copies native assets provided by build.dart from all packages to the application bundle's runtime directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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) ``` -------------------------------- ### Activate Coverde CLI Tool Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Installs the Coverde command-line tool globally. This tool is used for merging test reports to generate coverage reports. ```bash dart pub global activate coverde ``` -------------------------------- ### Activate Melos CLI Tool Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Installs the Melos command-line tool globally. This tool is used for managing the project and its dependencies. ```bash dart pub global activate melos ``` -------------------------------- ### Common Melos Commands for LaunchDarkly Flutter SDK Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CLAUDE.md Essential commands for managing dependencies, analyzing code, running tests, and building/running the example app within the monorepo. These commands are executed from the repository root using Melos. ```bash dart pub global activate melos # one-time melos bootstrap # install deps for every package melos run analyze # dart analyze --fatal-infos across all packages melos run fix # dart fix --apply melos run test # runs `flutter test --coverage` in common, common_client, flutter_client_sdk melos run sse-contract-tests # start SSE contract service and run the v2 harness melos run client-contract-tests # start Flutter client contract service and run the SDK harness melos run coverage-report # merge lcov files and show coverage value (requires `dart pub global activate coverde`) melos run coverage-report-html # same, but emits HTML to coverage/html/ melos run launchdarkly_flutter_example # build/run the example app for manual testing ``` -------------------------------- ### Export Flutter Library and ICU Data Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Exports Flutter library path, ICU data file, project build directory, and AOT library path to the parent scope for installation. ```cmake # 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) ``` -------------------------------- ### Run Contract Test Server Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/apps/flutter_client_contract_test_service/README.md Execute the contract test server using the Dart SDK. Ensure you are in the correct directory and have fetched dependencies. ```bash cd apps/flutter_client_contract_test_service/ dart pub get flutter test bin/contract_test_service.dart Server listening on port 8080 ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Sets the minimum CMake version and defines the ephemeral directory for generated files. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Running the Flutter Application with Environment Variables Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/README.md Shows how to run the Flutter application for web and other platforms using environment variables for LaunchDarkly credentials. ```shell # Web uses the client-side ID. $ flutter run --dart-define LAUNCHDARKLY_CLIENT_SIDE_ID= -d Chrome # All other platforms use the mobile key. $ flutter run --dart-define LAUNCHDARKLY_MOBILE_KEY= -d ios ``` -------------------------------- ### Run Client-Side Contract Tests Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Executes the client-side contract tests for the SDK. This command is run from the root of the SDK repository. ```bash melos run client-contract-tests ``` -------------------------------- ### Add Dependency Libraries and Include Directories Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/runner/CMakeLists.txt Specifies the libraries and include directories required for the application. Application-specific dependencies should also be added here. ```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}") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be removed if custom build settings are required. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Define C++ Wrapper App Sources Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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}/") ``` -------------------------------- ### Application Executable Definition Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Defines the main application executable, including source files and generated plugin registrant. Applies standard build settings and links necessary libraries. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Define Wrapper Root Directory Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Sets the root directory for the C++ client wrapper sources. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Flutter SDK and System Dependencies Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Includes the Flutter SDK subdirectory and finds PkgConfig modules for GTK+ 3.0. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Run SSE Contract Tests Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Executes the SSE contract tests for the SDK. This command is run from the root of the SDK repository. ```bash melos run sse-contract-tests ``` -------------------------------- ### Create Static Library for Application Wrapper Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Defines a static library for the application wrapper, applying standard settings, linking against the Flutter library, and setting 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" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Capturing Log Output with Mocktail Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CLAUDE.md Use mocktail's Mock to implement LDLogAdapter and capture log output using verify().captured. Ensure fallback values are registered for LDLogRecord in setUpAll. ```dart verify(() => adapter.log(captureAny())).captured ``` -------------------------------- ### Define C++ Wrapper Plugin Sources Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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}/") ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend script. This command is designed to run every time due to the use of a dummy output file, ensuring the build process is always up-to-date with Flutter tool outputs. ```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 ) ``` -------------------------------- ### Setting Binary Name Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Defines the on-disk name for the application executable. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Run Unit Tests Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Executes the unit tests for the SDK. These tests cover the pure Dart behavior of the SDK. ```bash melos run test ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Includes configuration files generated by the Flutter tool. ```cmake # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Create Static Library for Plugin Wrapper Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Defines a static library for the plugin wrapper, applying standard settings, setting position-independent code and hidden visibility, linking against the Flutter library, and setting include directories. ```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) ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt A function to apply common compilation features and options to a target, including C++17 standard, warning levels, and exception handling. ```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() ``` -------------------------------- ### Runtime Output Directory Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to prevent accidental execution of unbundled copies. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Define C++ Wrapper Core Sources Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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}/") ``` -------------------------------- ### Unicode Support Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Enables Unicode support for all projects by defining relevant preprocessor macros. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Defines 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}") ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend, ensuring it executes every time by using a phony output file. This command generates Flutter library files and wrapper sources. ```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 ) ``` -------------------------------- ### Cross-Building Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Configures CMake for cross-building by setting the system root and search paths when FLUTTER_TARGET_PLATFORM_SYSROOT is defined. ```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() ``` -------------------------------- ### Define Flutter Library Headers Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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}/") ``` -------------------------------- ### Build Type Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already configured, and restricts it to 'Debug', 'Profile', or 'Release'. ```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() ``` -------------------------------- ### CMake Policy Version Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/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) ``` -------------------------------- ### Define Flutter Library Path Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Specifies the path to the Flutter Windows DLL. ```cmake # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") ``` -------------------------------- ### Create Flutter Interface Library Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Defines an interface library for Flutter and sets its include directories and link libraries. ```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) ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build configuration to include Flutter version information. This allows the application to access version details at compile time. ```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}") ``` -------------------------------- ### Include Flutter Generated Plugins Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Includes the CMake script that manages building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define list_prepend function for CMake < 3.10 Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/flutter/CMakeLists.txt This function replicates the functionality of list(TRANSFORM ... PREPEND ...), which is not available in CMake version 3.10. It prepends a prefix to each element in a given 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 Configuration Management Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Manages build configuration types (Debug, Profile, Release) based on whether the generator is multi-config. ```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 Executable Target Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows runner. Source files for the application should be added here. The binary name is typically managed in the top-level CMakeLists.txt. ```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" ) ``` -------------------------------- ### Regenerate API Classes Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/apps/flutter_client_contract_test_service/README.md Rebuilds the API classes from OpenAPI yaml files. This command is necessary after modifying API definitions. ```bash dart run build_runner build -v ``` -------------------------------- ### Project-level CMake Configuration Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/CMakeLists.txt Sets the minimum CMake version and project name for the Flutter Windows application. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Configure Flutter Library Interface Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library for Flutter, setting include directories and linking system-level dependencies like GTK, GLIB, and GIO. This is crucial for integrating Flutter's native components. ```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 Flutter Assemble Dependency Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/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 Flutter builds. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Generate Coverage Report Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CONTRIBUTING.md Generates a code coverage report after running tests. Ensure `melos run test` has been executed prior to running this command. ```bash melos run coverage-report ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/CMakeLists.txt Defines a function to apply common compilation features and options, 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() ``` -------------------------------- ### Set Fallback Target Platform Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Provides a fallback for FLUTTER_TARGET_PLATFORM if not defined by the Flutter tool. ```cmake # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Flutter Assemble Custom Target Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the outputs generated by the Flutter tool backend command. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Override Commit Message with Conventional Commits Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/RELEASING.md Use this format to override a commit message and its conventional commit tag before or after merging. If merging post-merge, the release-please workflow must be re-run. ```markdown BEGIN_COMMIT_OVERRIDE fix: This is my new message and conventional commit tag! END_COMMIT_OVERRIDE ``` -------------------------------- ### Define flutter_assemble Custom Target Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/linux/flutter/CMakeLists.txt Creates a custom target named 'flutter_assemble' that depends on the Flutter library and its headers. This target ensures that the Flutter library is built before other components that might depend on it. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Dart 3 Null Narrowing with Case Patterns Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/CLAUDE.md Prefer Dart 3 case-patterns for null narrowing to avoid runtime assertions. This pattern introduces a non-null local variable within its scope. ```dart if (x case final v?) { // ... v ... } ``` ```dart if (s.state case final state? when state.isNotEmpty) ``` -------------------------------- ### Disable Windows Macros Source: https://github.com/launchdarkly/flutter-client-sdk/blob/main/packages/flutter_client_sdk/example/windows/runner/CMakeLists.txt Disables Windows-specific macros (NOMINMAX) that might conflict with C++ standard library functions, preventing potential naming collisions. ```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.