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"
)

# flutter_rust_bridge with Corrosion
find_package(Corrosion REQUIRED)

corrosion_import_crate(MANIFEST_PATH ../../../Cargo.toml
        # Equivalent to --all-features passed to cargo build
#        [ALL_FEATURES]
        # Equivalent to --no-default-features passed to cargo build
#        [NO_DEFAULT_FEATURES]
        # Disable linking of standard libraries (required for no_std crates).
#        [NO_STD]
        # Specify  cargo build profile (e.g. release or a custom profile)
#        [PROFILE <cargo-profile>]
        # Only import the specified crates from a workspace
#        [CRATES <crate1> ... <crateN>]
        # Enable the specified features
#        [FEATURES <feature1> ... <featureN>]
)
target_link_libraries(${BINARY_NAME} PRIVATE librustdesk)

# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})

# 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_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)
