Deps: copy WebView2Loader.dll into the binary folder

This commit is contained in:
Lukas Matena 2024-04-10 18:17:21 +02:00
parent a65a70903e
commit a8f573d1d9
4 changed files with 25 additions and 68 deletions

View File

@ -613,14 +613,6 @@ function(prusaslicer_copy_dlls target)
COMMAND ${CMAKE_COMMAND} -E copy ${TOP_LEVEL_PROJECT_DIR}/deps/+MPFR/mpfr/lib/win${_bits}/libmpfr-4.dll ${_out_dir}
COMMENT "Copy mpfr runtime to build tree"
VERBATIM)
if(DEFINED DESTDIR)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${DESTDIR}/usr/local/bin/WebView2Loader.dll ${_out_dir}
COMMENT "Copy WebView2Loader runtime to build tree"
VERBATIM)
endif ()
endfunction()

View File

@ -1,60 +0,0 @@
if (MSVC)
# Update the following variables if updating WebView2 SDK
set(WEBVIEW2_VERSION "1.0.705.50")
set(WEBVIEW2_URL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}")
set(WEBVIEW2_SHA256 "6a34bb553e18cfac7297b4031f3eac2558e439f8d16a45945c22945ac404105d")
set(WEBVIEW2_DEFAULT_PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/dep_WebView2-prefix/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")
set(WEBVIEW2_DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/dep_WebView2-prefix/download")
#message(STATUS "WEBVIEW2_DEFAULT_PACKAGE_DIR = ${WEBVIEW2_DEFAULT_PACKAGE_DIR}")
if(NOT EXISTS ${WEBVIEW2_PACKAGE_DIR})
unset(WEBVIEW2_PACKAGE_DIR CACHE)
endif()
set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_DEFAULT_PACKAGE_DIR} CACHE PATH "WebView2 SDK PATH" FORCE)
#file(MAKE_DIRECTORY ${DEP_DOWNLOAD_DIR}/WebView2)
message(STATUS "WEBVIEW2_URL = ${WEBVIEW2_URL}")
message(STATUS "WEBVIEW2_DOWNLOAD_DIR = ${WEBVIEW2_DOWNLOAD_DIR}")
file(DOWNLOAD
${WEBVIEW2_URL}
${WEBVIEW2_DOWNLOAD_DIR}/WebView2.nuget
EXPECTED_HASH SHA256=${WEBVIEW2_SHA256})
file(MAKE_DIRECTORY ${WEBVIEW2_PACKAGE_DIR})
execute_process(COMMAND
${CMAKE_COMMAND} -E tar x ${WEBVIEW2_DOWNLOAD_DIR}/WebView2.nuget
WORKING_DIRECTORY ${WEBVIEW2_PACKAGE_DIR}
)
set(_srcdir ${WEBVIEW2_PACKAGE_DIR}/build/native)
set(_dstdir ${${PROJECT_NAME}_DEP_INSTALL_PREFIX})
set(_output ${_dstdir}/include/WebView2.h
${_dstdir}/bin/WebView2Loader.dll)
if(NOT EXISTS ${_dstdir}/include)
file(MAKE_DIRECTORY ${_dstdir}/include)
endif()
if(NOT EXISTS ${_dstdir}/bin)
file(MAKE_DIRECTORY ${_dstdir}/bin)
endif()
add_custom_command(
OUTPUT ${_output}
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/WebView2.h ${_dstdir}/include/
COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/x${DEPS_BITS}/WebView2Loader.dll ${_dstdir}/bin/
)
add_custom_target(dep_WebView2 SOURCES ${_output})
set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_PACKAGE_DIR} CACHE INTERNAL "" FORCE)
endif ()

View File

@ -16,6 +16,7 @@ endif()
if (MSVC)
set(_wx_webview "-DwxUSE_WEBVIEW_EDGE=ON")
else ()
set(_wx_webview "-DwxUSE_WEBVIEW=ON")
endif ()
@ -56,3 +57,14 @@ add_cmake_project(wxWidgets
)
set(DEP_wxWidgets_DEPENDS ZLIB PNG EXPAT JPEG NanoSVG)
if (MSVC)
# After the build, copy the WebView2Loader.dll into the installation directory.
# This should probably be done better.
add_custom_command(TARGET dep_wxWidgets POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_BINARY_DIR}/builds/wxWidgets/lib/vc_x64_lib/WebView2Loader.dll"
"${${PROJECT_NAME}_DEP_INSTALL_PREFIX}/bin/WebView2Loader.dll")
endif()

View File

@ -212,6 +212,13 @@ if (WIN32)
COMMENT "Symlinking the resources directory into the build tree"
VERBATIM
)
if (SLIC3R_GUI)
add_custom_command(TARGET PrusaSlicer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${wxWidgets_ROOT_DIR}/bin/WebView2Loader.dll"
"${CMAKE_CURRENT_BINARY_DIR}/${CONF}/WebView2Loader.dll")
endif()
endforeach ()
else ()
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/resources" WIN_RESOURCES_SYMLINK)
@ -220,6 +227,12 @@ if (WIN32)
COMMENT "Symlinking the resources directory into the build tree"
VERBATIM
)
if (SLIC3R_GUI)
add_custom_command(TARGET PrusaSlicer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${wxWidgets_ROOT_DIR}/bin/WebView2Loader.dll"
"${CMAKE_CURRENT_BINARY_DIR}/${CONF}/WebView2Loader.dll")
endif()
endif ()
# This has to be a separate target due to the windows command line lenght limits