### Configure CMake for Application Bundle Installation Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This section defines the installation process for the application, creating a relocatable bundle in the build directory. It sets the install prefix, ensures a clean build directory by removing previous contents, and installs the executable, ICU data, Flutter library, and bundled plugin libraries into the bundle structure. ```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) ``` -------------------------------- ### Configure Installation Paths and Bundle Directories Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This section defines installation directories for the application bundle and sets up CMake's install prefix. It ensures that support files are copied alongside the executable for easy running, especially within Visual Studio. ```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 Resources Templates Directory for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/linux/CMakeLists.txt Installs the 'resources/Templates' directory into the plugin's installation prefix. This typically includes assets or configuration files that the plugin needs at runtime. ```CMake install(DIRECTORY "${PROJECT_SOURCE_DIR}/../resources/Templates" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" ) ``` -------------------------------- ### Run Flutter Document Scan Example Project Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/README.md Navigate to the example directory and use `flutter run` commands to execute the project on various platforms. This demonstrates how to launch the application on Web, Linux, Windows, or a default connected device. ```Bash cd example flutter run -d chrome # Run on Web flutter run -d linux # Run on Linux flutter run -d windows # Run on Windows flutter run # Run on default connected device (e.g., Android) ``` -------------------------------- ### Implement Full Screen Camera Preview in Flutter Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/camera/README.md This Flutter example demonstrates how to set up a full-screen camera preview using the `camera` package. It initializes the camera, handles camera access errors, and displays the preview. The app ensures the camera controller is properly disposed of when the widget is unmounted. ```dart import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; late List _cameras; Future main() async { WidgetsFlutterBinding.ensureInitialized(); _cameras = await availableCameras(); runApp(const CameraApp()); } /// CameraApp is the Main Application. class CameraApp extends StatefulWidget { /// Default Constructor const CameraApp({super.key}); @override State createState() => _CameraAppState(); } class _CameraAppState extends State { late CameraController controller; @override void initState() { super.initState(); controller = CameraController(_cameras[0], ResolutionPreset.max); controller.initialize().then((_) { if (!mounted) { return; } setState(() {}); }).catchError((Object e) { if (e is CameraException) { switch (e.code) { case 'CameraAccessDenied': // Handle access errors here. break; default: // Handle other errors here. break; } } }); } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (!controller.value.isInitialized) { return Container(); } return MaterialApp( home: CameraPreview(controller), ); } } ``` -------------------------------- ### Install Application Executable, ICU Data, and Libraries Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This snippet defines installation rules for the main application executable, Flutter's ICU data file, and the Flutter library. It also conditionally installs bundled plugin libraries, ensuring all necessary runtime components are deployed. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Linux Library Directory for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/linux/CMakeLists.txt Installs the 'lib' directory from the Linux-specific part of the project into the plugin's installation prefix. This ensures that native libraries required for the Linux build are correctly placed for deployment. ```CMake install(DIRECTORY "${PROJECT_SOURCE_DIR}/../linux/lib/" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" ) ``` -------------------------------- ### Install Flutter Assets in CMake Build Process Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This CMake code snippet defines the directory name for Flutter assets and configures their installation. It ensures that any previously installed assets are removed before copying the current build's assets into the application's data bundle 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) ``` -------------------------------- ### Install and Manage Flutter Assets Directory Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This snippet handles the installation of Flutter assets. It includes a custom CMake code block to first remove any stale asset directories before copying the current build's assets, preventing issues with outdated files. It also installs the AOT library for Profile and Release builds. ```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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Conditionally Install Flutter AOT Library in CMake Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This CMake snippet manages the installation of the Ahead-Of-Time (AOT) compiled Flutter library. It includes a conditional check to ensure the AOT library is only installed for non-Debug builds, placing it in the application's library directory. ```CMake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set Minimum CMake Version for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Specifies the minimum required CMake version (3.14) for building the Flutter plugin. This ensures compatibility and prevents compilation failures due to outdated CMake installations, as required by Flutter tooling. ```CMake cmake_minimum_required(VERSION 3.14) ``` -------------------------------- ### Configure Flutter Windows Camera Plugin with CMake Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows_camera/windows/CMakeLists.txt This CMake script defines the build process for the `camera_windows` Flutter plugin. It sets the project name, lists all source files for the plugin, configures shared library creation, specifies include directories, and links necessary system and Flutter libraries. It also includes a section for setting up and running unit tests using Google Test, conditionally enabled. ```CMake cmake_minimum_required(VERSION 3.14) set(PROJECT_NAME "camera_windows") project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed set(PLUGIN_NAME "${PROJECT_NAME}_plugin") list(APPEND PLUGIN_SOURCES "camera_plugin.h" "camera_plugin.cpp" "camera.h" "camera.cpp" "capture_controller.h" "capture_controller.cpp" "capture_controller_listener.h" "capture_engine_listener.h" "capture_engine_listener.cpp" "string_utils.h" "string_utils.cpp" "capture_device_info.h" "capture_device_info.cpp" "preview_handler.h" "preview_handler.cpp" "record_handler.h" "record_handler.cpp" "photo_handler.h" "photo_handler.cpp" "texture_handler.h" "texture_handler.cpp" "com_heap_ptr.h" ) add_library(${PLUGIN_NAME} SHARED "camera_windows.cpp" "include/camera_windows/camera_windows.h" ${PLUGIN_SOURCES} ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) target_link_libraries(${PLUGIN_NAME} PRIVATE mf mfplat mfuuid d3d11) # List of absolute paths to libraries that should be bundled with the plugin set(camera_windows_bundled_libraries "" PARENT_SCOPE ) # === Tests === if (${include_${PROJECT_NAME}_tests}) set(TEST_RUNNER "${PROJECT_NAME}_test") enable_testing() # TODO(stuartmorgan): Consider using a single shared, pre-checked-in googletest # instance rather than downloading for each plugin. This approach makes sense # for a template, but not for a monorepo with many plugins. include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/release-1.11.0.zip ) # Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Disable install commands for gtest so it doesn't end up in the bundle. set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) FetchContent_MakeAvailable(googletest) # The plugin's C API is not very useful for unit testing, so build the sources # directly into the test binary rather than using the DLL. add_executable(${TEST_RUNNER} test/mocks.h test/camera_plugin_test.cpp test/camera_test.cpp test/capture_controller_test.cpp ${PLUGIN_SOURCES} ) apply_standard_settings(${TEST_RUNNER}) target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) target_link_libraries(${TEST_RUNNER} PRIVATE mf mfplat mfuuid d3d11) target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) # flutter_wrapper_plugin has link dependencies on the Flutter DLL. add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FLUTTER_LIBRARY}" $ ) include(GoogleTest) gtest_discover_tests(${TEST_RUNNER}) endif() ``` -------------------------------- ### Run Flutter Project on Various Platforms Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/README.md These shell commands demonstrate how to run the Flutter project on different target devices or platforms, including a generic run, Windows desktop, Edge browser, and Linux desktop. ```Shell flutter run # flutter run -d windows # flutter run -d edge # flutter run -d linux ``` -------------------------------- ### CMake Configuration for Flutter Desktop Runner Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/runner/CMakeLists.txt This CMake script defines the build process for the Flutter desktop runner application. It sets the minimum CMake version, defines the project, adds the executable with its source files, applies standard build settings, injects Flutter version definitions, disables the NOMINMAX macro to prevent conflicts, and links essential libraries like flutter, flutter_wrapper_app, and dwmapi.lib. It also ensures the Flutter tool's build steps are executed. ```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" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # 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}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # 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}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Initialize CMake Project and Define Application Variables Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This snippet sets up the minimum CMake version, defines the project name, and declares key variables like the binary name and application ID for a Flutter desktop application. It also includes a policy for modern CMake behaviors to avoid warnings with recent versions. ```CMake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "documentscanner") set(APPLICATION_ID "com.example.documentscanner") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Initialize Flutter Document Scan SDK with License Key Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/README.md Before using the SDK, set your Dynamsoft Capture Vision license key within the `example/lib/global.dart` file. This step is crucial for authenticating and enabling the SDK's features. ```Dart Future initDocumentSDK() async { int? ret = await docScanner.init( "LICENSE-KEY"); ... } ``` -------------------------------- ### Define Application Executable and Link Dependencies in CMake Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This snippet defines the main executable target for the application, including its source files and generated plugin registrant. It then applies standard build settings, links necessary libraries like Flutter and GTK, and adds a build dependency on flutter_assemble to ensure all Flutter assets are prepared. ```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}") 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) set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Initialize Flutter Web Application with Service Worker Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/web/index.html This JavaScript code snippet handles the loading and initialization of a Flutter web application. It listens for the 'load' event on the window, then uses `_flutter.loader.loadEntrypoint` to download `main.dart.js`, initialize the Flutter engine, and run the application. It also manages the service worker version. ```JavaScript documentscanner // The value below is injected by flutter build, do not touch. var 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(); }); } }); }); ``` -------------------------------- ### Initialize Dynamsoft Document SDK with License Key Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/README.md This Dart function initializes the Dynamsoft Document SDK with a provided license key. It returns 0 on successful initialization, setting a flag `isLicenseValid` to true. A non-zero return value indicates an error. ```Dart Future initDocumentSDK() async { int? ret = await docScanner.init( 'LICENSE-KEY'); if (ret == 0) isLicenseValid = true; return ret ?? -1; } ``` -------------------------------- ### Define C++ Wrapper Source Files for Core, Plugin, and App Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This snippet organizes the C++ wrapper source files into distinct lists for core functionalities, plugin-specific implementations, and application-level components. Each list is then transformed to include the full path to the wrapper root, preparing them for compilation into static libraries. ```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}/") ``` -------------------------------- ### Build Flutter Wrapper App Static Library Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This snippet defines the "flutter_wrapper_app" static library, combining core and application-specific C++ wrapper sources. Similar to the plugin wrapper, it applies standard settings, links to the 'flutter' interface library, and includes required header directories, providing the necessary C++ components for the main Flutter application runner. ```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) ``` -------------------------------- ### Define Flutter Library Headers and CMake Target Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/flutter/CMakeLists.txt This snippet appends a list of Flutter library header files to `FLUTTER_LIBRARY_HEADERS` and then prepends the ephemeral directory path to each. It defines an `INTERFACE` library named `flutter`, sets its include directories, links it against the Flutter library and PkgConfig dependencies (GTK, GLIB, GIO), and adds a dependency on the `flutter_assemble` target. ```CMake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Execute Flutter Tool Backend via Custom Command Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/flutter/CMakeLists.txt This section defines a custom CMake command that executes the Flutter tool backend script (`tool_backend.sh`). It specifies the outputs, including the Flutter library and headers, and uses a `_phony_` file to force the command to run every time. A `flutter_assemble` custom target is also defined, depending on the generated library and headers. ```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} ) ``` -------------------------------- ### Initialize CMake Project and Define Binary Name Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This snippet sets the minimum required CMake version, defines the project name and supported languages, and specifies the output binary name for the application. It also enables modern CMake policies. ```CMake cmake_minimum_required(VERSION 3.14) project(documentscanner LANGUAGES CXX) set(BINARY_NAME "documentscanner") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Locate System Dependencies and Define Flutter Library Paths Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/flutter/CMakeLists.txt This section locates required system-level dependencies like GTK, GLIB, and GIO using PkgConfig. It then defines several important file paths related to the Flutter library, ICU data, project build directory, and AOT library, making them available in the parent scope for subsequent build steps. ```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) 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) ``` -------------------------------- ### Specify Include Directories and Link Libraries for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/linux/CMakeLists.txt Defines the include directories required for compiling the plugin and links necessary external libraries. This includes Flutter's own library and several Dynamsoft SDK components, along with GTK for desktop integration. ```CMake target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter "DynamsoftCore" "DynamsoftLicense" "DynamsoftCaptureVisionRouter" "DynamsoftUtility") target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Build Flutter Wrapper Plugin Static Library Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This section defines and configures the "flutter_wrapper_plugin" static library, which encapsulates core and plugin-specific C++ wrapper sources. It applies standard settings, sets position-independent code and hidden visibility properties, links against the 'flutter' interface library, and includes necessary header directories, making it suitable for Flutter plugins. ```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) ``` -------------------------------- ### Configure Flutter Tool Backend Custom Command for Assembly Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This section sets up a custom command to invoke the Flutter tool backend script, "tool_backend.bat". It defines a phony output to force execution every time and specifies the outputs that this command generates, including the Flutter library and all C++ wrapper source files. This command is crucial for orchestrating the assembly process of Flutter components. ```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 ) ``` -------------------------------- ### Apply Standard Build Settings to Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/linux/CMakeLists.txt Applies a set of predefined standard build settings to the plugin's target. These settings are typically configured in the application-level CMakeLists.txt and ensure consistent build behavior across the Flutter project. ```CMake apply_standard_settings(${PLUGIN_NAME}) ``` -------------------------------- ### Define Bundled Libraries for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Specifies a list of absolute paths to libraries and resources that should be bundled with the plugin. This list can include prebuilt libraries or outputs from external builds, ensuring they are distributed with the plugin. ```CMake set(flutter_document_scan_sdk_bundled_libraries "${PROJECT_SOURCE_DIR}/bin/" "${PROJECT_SOURCE_DIR}/../resources/Templates" PARENT_SCOPE ) ``` -------------------------------- ### Add camera_windows Git dependency in Flutter pubspec.yaml Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows_camera/README.md This snippet shows how to include the camera_windows plugin in your Flutter project by referencing its Git repository in the pubspec.yaml file. This allows the project to use the custom camera plugin. ```YAML camera_windows: git: url: https://github.com/yushulx/flutter_camera_windows.git ``` -------------------------------- ### Define Flutter Library Paths and Headers Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This snippet defines the main Flutter library ("flutter_windows.dll") and its associated ICU data file and project build directories. It also appends a list of essential Flutter library header files, which are then transformed to include their full ephemeral directory paths, making them accessible for compilation. ```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) 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}/") ``` -------------------------------- ### Configure iOS Info.plist for Camera and Microphone Usage Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/camera/README.md This XML snippet adds privacy usage descriptions for camera and microphone access to your iOS application's Info.plist file. These descriptions are required by Apple to explain to users why your app needs these permissions. ```XML NSCameraUsageDescription your usage description here NSMicrophoneUsageDescription your usage description here ``` -------------------------------- ### Include Flutter Library and Application Build Rules Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This snippet includes external CMakeLists.txt files for managing Flutter library builds, application-specific build rules (from the 'runner' directory), and generated plugin build rules. It centralizes the inclusion of various build components. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Apply Standard Build Settings to Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Applies a standard set of build settings to the plugin library. These settings are typically configured in the application-level `CMakeLists.txt` and can be removed if the plugin requires full control over its build settings. ```CMake apply_standard_settings(${PLUGIN_NAME}) ``` -------------------------------- ### Include Dynamsoft Capture Vision Bundle in Web Index.html Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/README.md For web deployment, include the Dynamsoft Capture Vision bundle script in your `index.html` file. This script provides the necessary client-side libraries for document scanning functionalities. ```HTML ``` -------------------------------- ### Include Flutter Generated Configuration and Set Fallback Platform Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This section includes a generated configuration file from the Flutter tool and provides a fallback mechanism for "FLUTTER_TARGET_PLATFORM". If the platform is not defined, it defaults to 'windows-x64', ensuring compatibility with older Flutter tool versions and providing a default build target. ```CMake # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Configure Profile Build Flags in CMake Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This snippet sets the linker and compiler flags for the 'Profile' build configuration to mirror those of the 'Release' configuration. This ensures consistent optimization settings for profiling builds. ```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}") ``` -------------------------------- ### Define CMake Function for Standard Compilation Settings Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This CMake function, APPLY_STANDARD_SETTINGS, applies common compilation options to a specified target. It sets the C++14 standard, enables Wall and Werror for strict error checking, and optimizes for release builds while defining NDEBUG to disable assertions. ```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() ``` -------------------------------- ### Link External Libraries to Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Links the plugin with necessary Flutter libraries (`flutter`, `flutter_wrapper_plugin`) and specific Dynamsoft SDK libraries (`DynamsoftCorex64`, `DynamsoftLicensex64`, `DynamsoftCaptureVisionRouterx64`, `DynamsoftUtilityx64`) that are required for its functionality. ```CMake target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin "DynamsoftCorex64" "DynamsoftLicensex64" "DynamsoftCaptureVisionRouterx64" "DynamsoftUtilityx64") ``` -------------------------------- ### Specify Include Directories and Compile Options Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Adds interface include directories for the plugin, allowing other modules to find its headers. It also sets private compile options, including suppressing specific warnings and setting warning levels. ```CMake target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_options(${PLUGIN_NAME} PRIVATE /wd4121 /W3 /WX-) ``` -------------------------------- ### Configure CMake Minimum Version and Ephemeral Directory Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/flutter/CMakeLists.txt This snippet sets the minimum required CMake version to 3.10 and defines the `EPHEMERAL_DIR` variable, which points to a directory for generated build configurations. It then includes a configuration file provided by the Flutter tool. ```CMake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Flutter Document Scan SDK API Reference Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/README.md This section provides a comprehensive reference for the Flutter Document Scan SDK's public methods. It details the purpose, parameters, and return types for key functionalities like SDK initialization, document normalization from files or buffers, and document detection. ```APIDOC Method: Future init(String key) Description: Initializes the SDK with a license key. Parameters: key: License string Return Type: Future Method: Future normalizeFile(String file, List points, ColorMode color) Description: Normalizes a document image from a file. Parameters: file: Path to the image file points: Document corner points color: output image color Return Type: Future Method: Future normalizeBuffer(Uint8List bytes, int width, int height, int stride, int format, List points, int rotation, ColorMode color) Description: Normalizes a document image from a raw image buffer. Parameters: bytes: Image buffer width: Image dimensions height: Image dimensions stride: Row stride in bytes format: Image pixel format index points: Document corner points rotation: 0/90/180/270 color: output image color Return Type: Future Method: Future?> detectFile(String file) Description: Detects documents in an image file. Parameters: file: Path to the image file Return Type: Future?> Method: Future?> detectBuffer(Uint8List bytes, int width, int height, int stride, int format, int rotation) Description: Detects documents from a raw image buffer. Parameters: bytes: Image buffer width: Image dimensions height: Image dimensions stride: Row stride in bytes format: Image pixel format index rotation: 0/90/180/270 Return Type: Future?> ``` -------------------------------- ### Camera Plugin Permission Error Codes Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/camera/README.md This section documents the specific error codes thrown by the camera plugin when camera or audio access permissions are denied or restricted. Understanding these codes is crucial for implementing robust error handling in your application. ```APIDOC CameraAccessDenied: Thrown when user denies the camera access permission. CameraAccessDeniedWithoutPrompt: iOS only for now. Thrown when user has previously denied the permission. iOS does not allow prompting alert dialog a second time. Users will have to go to Settings > Privacy > Camera in order to enable camera access. CameraAccessRestricted: iOS only for now. Thrown when camera access is restricted and users cannot grant permission (parental control). AudioAccessDenied: Thrown when user denies the audio access permission. AudioAccessDeniedWithoutPrompt: iOS only for now. Thrown when user has previously denied the permission. iOS does not allow prompting alert dialog a second time. Users will have to go to Settings > Privacy > Microphone in order to enable audio access. AudioAccessRestricted: iOS only for now. Thrown when audio access is restricted and users cannot grant permission (parental control). ``` -------------------------------- ### Open Flutter Project's Xcode Workspace Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md This command opens the Xcode workspace for a Flutter project, which is necessary for managing iOS-specific assets like the launch screen. Once opened, developers can navigate to `Runner/Assets.xcassets` to add or replace images. ```Shell open ios/Runner.xcworkspace ``` -------------------------------- ### Set CMake Minimum Version and Define Build Paths Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This snippet sets the minimum required CMake version to 3.14 and defines key directory variables like "EPHEMERAL_DIR" and "WRAPPER_ROOT". These paths are crucial for locating generated configuration files and C++ wrapper sources, ensuring the build system can find necessary components. ```CMake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # 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 Standard Compilation Settings Function in CMake Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This CMake function, `APPLY_STANDARD_SETTINGS`, defines common compilation options for targets. It enforces C++17 standard, sets warning levels, enables exception handling, and defines debug-specific macros. This function is designed to be applied to most targets. ```CMake add_definitions(-DUNICODE -D_UNICODE) 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() ``` -------------------------------- ### Subscribe to camera frame events for image processing in Dart Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows_camera/README.md This Dart code demonstrates how to subscribe to FrameAvailabledEvent from the camera to receive raw image data. It shows how to extract Uint8List bytes for processing and emphasizes the need for offloading heavy computation to worker threads like Dart isolates or native threads to prevent UI blocking. ```Dart void _onFrameAvailable(FrameAvailabledEvent event) { if (mounted) { Map map = event.toJson(); final Uint8List? data = map['bytes'] as Uint8List?; // image processing } } StreamSubscription? _frameAvailableStreamSubscription; _frameAvailableStreamSubscription?.cancel(); _frameAvailableStreamSubscription = (CameraPlatform.instance as CameraWindows) .onFrameAvailable(cameraId) .listen(_onFrameAvailable); ``` -------------------------------- ### Append Source Files to Plugin Build Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Adds the core C++ source and header files of the plugin to the `PLUGIN_SOURCES` list. Any new source files for the plugin should be appended to this list to be included in the build. ```CMake list(APPEND PLUGIN_SOURCES "flutter_document_scan_sdk_plugin.cpp" "flutter_document_scan_sdk_plugin.h" ) ``` -------------------------------- ### Set RPATH Properties for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/linux/CMakeLists.txt Configures the runtime search path (RPATH) for the plugin's shared library. Setting both `INSTALL_RPATH` and `BUILD_RPATH` to `$ORIGIN` ensures that the library can find its dependencies relative to its own location. ```CMake set_target_properties(${PLUGIN_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN" ) ``` -------------------------------- ### Define Shared Library Target for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Creates the shared library target for the plugin using the defined `PLUGIN_NAME`. It includes the public C API header, its implementation, and all other source files listed in `PLUGIN_SOURCES`. ```CMake add_library(${PLUGIN_NAME} SHARED "include/flutter_document_scan_sdk/flutter_document_scan_sdk_plugin_c_api.h" "flutter_document_scan_sdk_plugin_c_api.cpp" ${PLUGIN_SOURCES} ) ``` -------------------------------- ### Set Minimum Android SDK Version in build.gradle Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/camera/README.md This Groovy snippet sets the `minSdkVersion` to 21 or higher in your Android application's `build.gradle` file. This is a prerequisite for using the camera plugin on Android. ```Groovy minSdkVersion 21 ``` -------------------------------- ### Configure CMake for Cross-Building with SYSROOT Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/linux/CMakeLists.txt This section configures CMake for cross-building by setting the CMAKE_SYSROOT and CMAKE_FIND_ROOT_PATH variables based on FLUTTER_TARGET_PLATFORM_SYSROOT. It ensures that CMake searches for programs, packages, libraries, and includes within the specified sysroot, optimizing the search path for cross-compilation. ```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() ``` -------------------------------- ### Configure Flutter Interface Library for Dependencies Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/flutter/CMakeLists.txt This section defines an "INTERFACE" library named 'flutter', which serves as a dependency for other targets. It specifies the include directories and links against the Flutter library, ensuring that any target depending on 'flutter' can correctly find its headers and link against the necessary DLL. ```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) ``` -------------------------------- ### Manage CMake Build Configuration Types Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/example/windows/CMakeLists.txt This section configures build types (Debug, Profile, Release) based on whether the generator supports multiple configurations. It ensures a default build type is set if none is 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() ``` -------------------------------- ### Add Link Directories for Flutter Plugin Source: https://github.com/yushulx/flutter_document_scan_sdk/blob/main/windows/CMakeLists.txt Specifies additional directories where the linker should search for libraries required by the plugin. This particular entry adds the 'lib' subdirectory within the project's source directory. ```CMake link_directories("${PROJECT_SOURCE_DIR}/lib/") ```