### Project Setup and Configuration Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Initializes CMake, sets the project name and application ID, and configures installation paths. This is essential for defining the basic structure and identity of the application. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # 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") ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Iterates through a list of bundled plugin libraries and installs each one to the lib directory within the installation bundle. These are Runtime components. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Application Executable Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This makes the application available for execution. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the installation bundle. This is a core component required for the Flutter engine. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the installation bundle. This ensures that all necessary plugin code is available at runtime. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Define Installation Bundle Directory Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Sets the directory for the relocatable application bundle in the build directory. This is the base for all installation artifacts. ```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 AOT Library (Non-Debug Builds) Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the installation bundle's library directory. This installation is conditional and only occurs for non-Debug build types. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set Installation Prefix for Bundled Files Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable, facilitating in-place running and Visual Studio integration. It ensures support files are correctly located. ```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}") ``` -------------------------------- ### Clean Build Bundle Directory on Install Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Ensures the build bundle directory is clean before installation by recursively removing its contents. This is part of the Runtime component installation. ```cmake install( CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Copies native assets from the build directory to the installation bundle's library directory. This ensures all necessary native files are included in the final application package. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Copies native assets provided by build.dart from all packages into the installation bundle. This ensures that platform-specific assets are included. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library for Release Builds Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for 'Profile' and 'Release' configurations only. This optimizes performance for non-debug builds. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring that all application assets (like images and fonts) are copied to the correct location. It also removes stale files before copying. ```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) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Installs the ICU data file to the data directory within the application bundle. This is necessary for internationalization support. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Specifies the minimum required CMake version and the project name. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Define Flutter Library and Assets Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Sets the Flutter library path and publishes essential variables like FLUTTER_LIBRARY, FLUTTER_ICU_DATA_FILE, PROJECT_BUILD_DIR, and AOT_LIBRARY to the parent scope for use in installation and other build steps. ```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) ``` -------------------------------- ### Two-Way Scroll Controller Setup Source: https://github.com/reqable/re-editor/blob/main/README.md Configures the scroll controllers for Re-Editor, enabling two-way scrolling. Uses CodeScrollController with separate vertical and horizontal ScrollControllers. ```dart CodeEditor( scrollController: CodeScrollController( verticalScroller: ScrollController(), horizontalScroller: ScrollController(), ) ); ``` -------------------------------- ### Find and Check System Dependencies Source: https://github.com/reqable/re-editor/blob/main/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required GTK, GLIB, and GIO libraries, making them available as imported targets for linking. ```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) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Configures C++ standard to C++14, enables Wall and Werror, and applies optimization and NDEBUG definitions for non-debug builds. ```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() ``` -------------------------------- ### Find and Check PkgConfig Modules Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Finds and checks for the required GTK+ 3.0 library using PkgConfig. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Implement Context Menu Controller Source: https://github.com/reqable/re-editor/blob/main/README.md Implement the SelectionToolbarController interface and set it up via toolbarController to manage context menus. ```dart CodeEditor( toolbarController: _MyToolbarController(), ); ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be removed if the application requires custom build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Cross-Building Root Filesystem Configuration Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Configures the sysroot and find paths for cross-compiling. This is used when building for a different platform than the host system. ```cmake # 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() ``` -------------------------------- ### Flutter Web App Initialization Source: https://github.com/reqable/re-editor/blob/main/example/web/index.html This snippet demonstrates the standard initialization process for a Flutter web application. It configures the service worker and loads the main entry point to run the app. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Text Syntax Highlighting Configuration Source: https://github.com/reqable/re-editor/blob/main/README.md Specifies JSON syntax highlighting rules and applies the Atom One Light code coloring theme. Requires Re-Highlight integration. ```dart CodeEditor( style: CodeEditorStyle( codeTheme: CodeHighlightTheme( languages: { 'json': CodeHighlightThemeMode( mode: langJson ) }, theme: atomOneLightTheme ), ), ); ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and adds the source directory to the include path for the target. Add any other application-specific dependencies here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) ``` ```cmake target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") ``` ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Create Flutter Interface Library Source: https://github.com/reqable/re-editor/blob/main/example/linux/flutter/CMakeLists.txt Creates an interface library target named 'flutter' and configures its include directories and linked libraries, including system dependencies. ```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 ) ``` -------------------------------- ### Build Flutter Wrapper App Library Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Creates a static library named 'flutter_wrapper_app' using core and application C++ wrapper sources. It applies standard build settings, links against the 'flutter' library, and includes the wrapper header directory. ```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) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support in the project. This is crucial for handling international characters correctly. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Set Runtime Output Directory Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Configures the runtime output directory for the main binary. This ensures that resources are located correctly in the relative path. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Configures linker and compiler flags for the 'Profile' build mode, typically by copying settings from the 'Release' mode. This ensures consistent performance tuning. ```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}") ``` -------------------------------- ### Build Flutter Wrapper Plugin Library Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Creates a static library named 'flutter_wrapper_plugin' using core and plugin C++ wrapper sources. It applies standard build settings, sets properties for position-independent code and C++ visibility, links against the 'flutter' library, and includes the wrapper header directory. ```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) ``` -------------------------------- ### Define Application Target Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Set Flutter Build Directories Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Defines the ephemeral directory for generated configuration files and the wrapper root directory for C++ client wrapper sources. ```cmake 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") ``` -------------------------------- ### Define C++ Wrapper Sources Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Lists and transforms C++ wrapper source files for core implementations, plugin registration, and application-level components. These lists are used to build static libraries for plugins and the application runner. ```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}/") ``` -------------------------------- ### Implement Code Hints and Auto-Completion Source: https://github.com/reqable/re-editor/blob/main/README.md Use the CodeAutocomplete widget for code input prompts and auto-completion. Developers must define the prompt content, rules, and UI. ```dart CodeAutocomplete( viewBuilder: (context, notifier, onSelected) { // build the code prompts view }, promptsBuilder: DefaultCodeAutocompletePromptsBuilder( language: langDart, ), child: CodeEditor() ); ``` -------------------------------- ### Find and Replace UI Integration Source: https://github.com/reqable/re-editor/blob/main/README.md Integrates a custom search and replace UI using the findBuilder attribute. The developer must implement the UI, such as CodeFindPanelView. ```dart CodeEditor( findBuilder: (context, controller, readOnly) => CodeFindPanelView(controller: controller, readOnly: readOnly), ); ``` -------------------------------- ### Link Application Libraries Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Links the application executable against the Flutter library and the GTK+ library. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Define Flutter Library and Headers Source: https://github.com/reqable/re-editor/blob/main/example/linux/flutter/CMakeLists.txt Sets the path to the Flutter Linux GTK shared library and defines a list of Flutter library header files. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") ``` -------------------------------- ### Include Generated Plugin Build Rules Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Includes CMake rules for building generated plugins. This manages the compilation and linking of plugins used by the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Configure Flutter Library Headers Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Appends Flutter library header files to a list and then prepends the ephemeral directory path to each header. Finally, it defines an INTERFACE library named 'flutter' and sets its include directories and link libraries. ```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) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script. This command generates output files like the Flutter library and headers. It uses a phony target to ensure the command runs every time, as direct input/output tracking for the tool is not available. ```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 ) ``` -------------------------------- ### General Compilation Settings Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Placeholder for general compilation settings that apply to most targets. New options should typically be added to specific targets rather than here. ```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 ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/reqable/re-editor/blob/main/example/linux/flutter/CMakeLists.txt A custom command to execute the Flutter tool backend script, generating necessary build artifacts like the Flutter library and headers. It uses a phony output 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/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the target to embed build version information directly into the compiled code. This is useful for runtime version checks or display. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt A function to apply common compilation settings to a target, including C++ standard, warning levels, and specific definitions. Use with caution for plugins. ```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() ``` -------------------------------- ### Include Flutter Managed Directory Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory as a subdirectory. This is essential for integrating Flutter's build system into the project. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Include Runner Subdirectory Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Adds the 'runner' subdirectory, which typically contains the main application's build rules. This integrates the application's specific build logic. ```cmake add_subdirectory("runner") ``` -------------------------------- ### Configure Build Types for Multi-Configuration Generators Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) when using a multi-configuration CMake generator. This ensures consistent build types. ```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() ``` -------------------------------- ### Set Executable Binary Name Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Defines the name of the executable file that will be created. This can be changed to alter the on-disk name of the application. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Build Configuration Mode Source: https://github.com/reqable/re-editor/blob/main/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined. This ensures a consistent build mode for development. ```cmake # 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() ``` -------------------------------- ### Define Executable Target Source: https://github.com/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Defines the main executable target for the application and lists all source files. Ensure any new source files are added here. The binary name is controlled by the top-level CMakeLists.txt to ensure `flutter run` compatibility. ```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" ) ``` -------------------------------- ### Set Fallback Platform Configuration Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Sets a fallback for FLUTTER_TARGET_PLATFORM if it's not defined, ensuring a default configuration for older Flutter tool versions. ```cmake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Define List Prepend Function Source: https://github.com/reqable/re-editor/blob/main/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() ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/reqable/re-editor/blob/main/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to prevent warnings in newer CMake versions. It sets the policy for versions 3.14 through 3.25. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process (`flutter_assemble`) is completed before the application target is built. This dependency is crucial and must not be removed. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Basic Multi-line Input Area Source: https://github.com/reqable/re-editor/blob/main/README.md Creates the simplest multi-line input area, similar to TextField. Uses CodeLineEditingController. ```dart Widget build(BuildContext context) { return CodeEditor( controller: CodeLineEditingController.fromText('Hello Reqable'), ); } ``` -------------------------------- ### Custom Code Chunk Analyzer Interface Source: https://github.com/reqable/re-editor/blob/main/README.md Defines the interface for custom code chunk analyzers. Developers can implement this to write their own detection rules. ```dart abstract class CodeChunkAnalyzer { List run(CodeLines codeLines); } ``` -------------------------------- ### Flutter Assemble Custom Target Source: https://github.com/reqable/re-editor/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the output of the Flutter tool backend command, including the Flutter library, headers, and all C++ wrapper sources. This target ensures these components 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} ) ``` -------------------------------- ### Line Numbers and Fold/Unfold Markers Source: https://github.com/reqable/re-editor/blob/main/README.md Configures the display of code line numbers and code folding marks using default implementations. The indicatorBuilder allows custom display styles. ```dart CodeEditor( indicatorBuilder: (context, editingController, chunkController, notifier) { return Row( children: [ DefaultCodeLineNumber( controller: editingController, notifier: notifier, ), DefaultCodeChunkIndicator( width: 20, controller: chunkController, notifier: notifier ) ], ); }, ); ``` -------------------------------- ### Define Flutter Assemble Custom Target Source: https://github.com/reqable/re-editor/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the Flutter library and its headers, ensuring they are built. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Code Folding and Unfolding Detection Source: https://github.com/reqable/re-editor/blob/main/README.md Sets the code chunk analyzer. DefaultCodeChunkAnalyzer detects folding areas for '{}' and '[]'. NonCodeChunkAnalyzer can disable detection. ```dart CodeEditor( chunkAnalyzer: DefaultCodeChunkAnalyzer(), ); ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/reqable/re-editor/blob/main/example/windows/runner/CMakeLists.txt Disables Windows-specific macros like NOMINMAX that can conflict with standard C++ library functions, preventing potential compilation errors. ```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.