Merge branch 'msw_webview_edge3' of https://github.com/TcT2k/wxWidgets

Make using wxWebViewEdge even simpler in CMake builds.

See https://github.com/wxWidgets/wxWidgets/pull/2223
This commit is contained in:
Vadim Zeitlin 2021-02-09 15:22:56 +01:00
commit 7a74c0872c
4 changed files with 41 additions and 13 deletions

View File

@ -453,10 +453,6 @@ if(wxUSE_GUI)
wx_option_force_value(wxUSE_WEBVIEW OFF)
endif()
elseif(WXMSW)
if(wxUSE_WEBVIEW_EDGE AND NOT EXISTS "${wxSOURCE_DIR}/3rdparty/webview2")
message("WebView2 SDK not found, WebviewEdge won't be available")
wx_option_force_value(wxUSE_WEBVIEW_EDGE OFF)
endif()
if(NOT wxUSE_WEBVIEW_IE AND NOT wxUSE_WEBVIEW_EDGE)
message(WARNING "WebviewIE and WebviewEdge not found or enabled, wxWebview won't be available")
wx_option_force_value(wxUSE_WEBVIEW OFF)

View File

@ -37,7 +37,36 @@ if(APPLE)
wx_lib_link_libraries(wxwebview PUBLIC "-framework WebKit")
elseif(WXMSW)
if(wxUSE_WEBVIEW_EDGE)
wx_lib_include_directories(wxwebview PRIVATE "${PROJECT_SOURCE_DIR}/3rdparty/webview2/build/native/include")
# 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_BINARY_DIR}/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")
find_path(WEBVIEW2_PACKAGE_DIR
NAMES build/native/include/WebView2.h
PATHS
"${PROJECT_SOURCE_DIR}/3rdparty/webview2"
${WEBVIEW2_DEFAULT_PACKAGE_DIR}
)
mark_as_advanced(WEBVIEW2_PACKAGE_DIR)
if (NOT WEBVIEW2_PACKAGE_DIR)
message(STATUS "WebView2 SDK not found locally, downloading...")
set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_DEFAULT_PACKAGE_DIR} CACHE PATH "WebView2 SDK PATH" FORCE)
file(DOWNLOAD
${WEBVIEW2_URL}
${CMAKE_BINARY_DIR}/webview2.nuget
EXPECTED_HASH SHA256=${WEBVIEW2_SHA256})
file(MAKE_DIRECTORY ${WEBVIEW2_PACKAGE_DIR})
execute_process(COMMAND
${CMAKE_COMMAND} -E tar x ${CMAKE_BINARY_DIR}/webview2.nuget
WORKING_DIRECTORY ${WEBVIEW2_PACKAGE_DIR}
)
endif()
wx_lib_include_directories(wxwebview PRIVATE "${WEBVIEW2_PACKAGE_DIR}/build/native/include")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WEBVIEW2_ARCH x86)
@ -47,7 +76,7 @@ elseif(WXMSW)
add_custom_command(TARGET wxwebview POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${PROJECT_SOURCE_DIR}/3rdparty/webview2/build/native/${WEBVIEW2_ARCH}/WebView2Loader.dll"
"${WEBVIEW2_PACKAGE_DIR}/build/native/${WEBVIEW2_ARCH}/WebView2Loader.dll"
"$<TARGET_FILE_DIR:wxwebview>/WebView2Loader.dll")
endif()
elseif(WXGTK)

View File

@ -445,7 +445,8 @@ if(WIN32)
else()
set(wxUSE_WINRT_DEFAULT OFF)
endif()
if(MSVC_VERSION GREATER 1800 AND NOT CMAKE_VS_PLATFORM_TOOLSET MATCHES "_xp$")
if(MSVC_VERSION GREATER 1800 AND NOT CMAKE_VS_PLATFORM_TOOLSET MATCHES "_xp$" AND
EXISTS "${wxSOURCE_DIR}/3rdparty/webview2")
set(wxUSE_WEBVIEW_EDGE_DEFAULT ON)
else()
set(wxUSE_WEBVIEW_EDGE_DEFAULT OFF)

View File

@ -321,12 +321,14 @@ public:
This backend is not enabled by default, to build it follow these steps:
- Visual Studio 2015, or newer, is required
- Download the <a href="https://aka.ms/webviewnuget">WebView2 SDK</a>
nuget package (Version 1.0.622.22 or newer)
- Extract the package (it's a zip archive) to @c wxWidgets/3rdparty/webview2
(you should have @c 3rdparty/webview2/build/native/include/WebView2.h
file after unpacking it)
- Enable @c wxUSE_WEBVIEW_EDGE in CMake or @c setup.h
- With CMake just enable @c wxUSE_WEBVIEW_EDGE
- When not using CMake:
- Download the <a href="https://aka.ms/webviewnuget">WebView2 SDK</a>
nuget package (Version 1.0.622.22 or newer)
- Extract the package (it's a zip archive) to @c wxWidgets/3rdparty/webview2
(you should have @c 3rdparty/webview2/build/native/include/WebView2.h
file after unpacking it)
- Enable @c wxUSE_WEBVIEW_EDGE in @c setup.h
- Build wxWidgets webview library
- Copy @c WebView2Loader.dll from the subdirectory corresponding to the
architecture used (x86 or x64) of @c wxWidgets/3rdparty/webview2/build/