From a8f573d1d94eaa8ade586434d59704655687ab85 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 10 Apr 2024 18:17:21 +0200 Subject: [PATCH] Deps: copy WebView2Loader.dll into the binary folder --- CMakeLists.txt | 8 ----- deps/+WebView2/WebView2.cmake | 60 --------------------------------- deps/+wxWidgets/wxWidgets.cmake | 12 +++++++ src/CMakeLists.txt | 13 +++++++ 4 files changed, 25 insertions(+), 68 deletions(-) delete mode 100644 deps/+WebView2/WebView2.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 66cff19b4e..5445eb99b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/deps/+WebView2/WebView2.cmake b/deps/+WebView2/WebView2.cmake deleted file mode 100644 index dff90d5936..0000000000 --- a/deps/+WebView2/WebView2.cmake +++ /dev/null @@ -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 () \ No newline at end of file diff --git a/deps/+wxWidgets/wxWidgets.cmake b/deps/+wxWidgets/wxWidgets.cmake index cdb62e43e4..f34672e630 100644 --- a/deps/+wxWidgets/wxWidgets.cmake +++ b/deps/+wxWidgets/wxWidgets.cmake @@ -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() + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ff22378f8..ce9d5f7fc0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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