if (HAVE_UNFOLD_AUTO_UPDATE)

  if (PLATFORM_OS_WINDOWS)
    FetchContent_Declare_Logged(
      unfold
      "Auto-update framework"
      "MIT"
      GIT_REPOSITORY https://github.com/rcaelers/unfold.git
      GIT_TAG f6290e4d89386de287b9a761f02b77d07a1923fb
    )
    if(NOT unfold_POPULATED)
      FetchContent_MakeAvailable(unfold)
      install(TARGETS unfold RUNTIME DESTINATION bin)
    endif()

    FetchContent_Declare_Logged(
      cmark
      "CommonMark parsing and rendering library"
      "BSD-2-Clause/MIT"
      GIT_REPOSITORY https://github.com/commonmark/cmark.git
      GIT_TAG        0.31.1
      GIT_SHALLOW    TRUE
      CMAKE_ARGS "BUILD_TESTING=OFF BUILD_STATIC_LIBS=OFF BUILD_SHARED_LIBS=ON"
    )
    set(BUILD_TESTING OFF CACHE INTERNAL "Disable tests")
    if(NOT cmark_POPULATED)
      FetchContent_MakeAvailable(cmark)
      install(TARGETS unfold RUNTIME DESTINATION bin)
    endif()

    FetchContent_Declare_Logged(
      webview2
      "Microsoft Edge WebView2 embedded web browser control"
      "Microsoft-Web-WebView2"
      URL https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/1.0.3405.78
      URL_HASH SHA256=d035807b2aaba871e8c014759626f566e96934e6ce6f0587056ee81d5228c373
    )
    FetchContent_MakeAvailable(webview2)

    add_library(webview2 INTERFACE)
    target_include_directories(webview2 INTERFACE "${webview2_SOURCE_DIR}/build/native/include/")
    if (NOT MSVC)
      target_compile_options(webview2 INTERFACE -Wno-unknown-pragmas)
    endif()

    if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|AMD64")
      target_link_directories(webview2 INTERFACE ${webview2_SOURCE_DIR}/build/native/x64)
      install(FILES ${webview2_SOURCE_DIR}/runtimes/win-x64/native/WebView2Loader.dll DESTINATION bin)
    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|X86")
      target_link_directories(webview2 INTERFACE ${webview2_SOURCE_DIR}/build/native/x86)
      install(FILES ${webview2_SOURCE_DIR}/runtimes/win-x86/native/WebView2Loader.dll DESTINATION bin)
    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|ARM64")
      target_link_directories(webview2 INTERFACE ${webview2_SOURCE_DIR}/build/native/arm64)
      install(FILES ${webview2_SOURCE_DIR}/runtimes/win-arm64/native/WebView2Loader.dll DESTINATION bin)
    else()
      message(FATAL_ERROR "Unsupported processor: ${CMAKE_SYSTEM_PROCESSOR}")
    endif()
    if (MSVC)
      target_link_libraries(webview2 INTERFACE WebView2LoaderStatic)
    else()
      target_link_libraries(webview2 INTERFACE WebView2Loader)
    endif()

  endif()

  add_subdirectory(src)
endif()
