CMake: Download SDK when wxUSE_WEBVIEW_EDGE=ON
Automatically download the WebView2 SDK from nuget (official repo for the SDK) when enabling wxUSE_WEBVIEW_EDGE to simplify usage. Copying to 3rdparty/webview2 is still supported optionally.
This commit is contained in:
@@ -453,10 +453,6 @@ if(wxUSE_GUI)
|
|||||||
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
||||||
endif()
|
endif()
|
||||||
elseif(WXMSW)
|
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)
|
if(NOT wxUSE_WEBVIEW_IE AND NOT wxUSE_WEBVIEW_EDGE)
|
||||||
message(WARNING "WebviewIE and WebviewEdge not found or enabled, wxWebview won't be available")
|
message(WARNING "WebviewIE and WebviewEdge not found or enabled, wxWebview won't be available")
|
||||||
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
wx_option_force_value(wxUSE_WEBVIEW OFF)
|
||||||
|
@@ -37,7 +37,36 @@ if(APPLE)
|
|||||||
wx_lib_link_libraries(wxwebview PUBLIC "-framework WebKit")
|
wx_lib_link_libraries(wxwebview PUBLIC "-framework WebKit")
|
||||||
elseif(WXMSW)
|
elseif(WXMSW)
|
||||||
if(wxUSE_WEBVIEW_EDGE)
|
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)
|
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
set(WEBVIEW2_ARCH x86)
|
set(WEBVIEW2_ARCH x86)
|
||||||
@@ -47,7 +76,7 @@ elseif(WXMSW)
|
|||||||
|
|
||||||
add_custom_command(TARGET wxwebview POST_BUILD
|
add_custom_command(TARGET wxwebview POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
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")
|
"$<TARGET_FILE_DIR:wxwebview>/WebView2Loader.dll")
|
||||||
endif()
|
endif()
|
||||||
elseif(WXGTK)
|
elseif(WXGTK)
|
||||||
|
@@ -445,7 +445,8 @@ if(WIN32)
|
|||||||
else()
|
else()
|
||||||
set(wxUSE_WINRT_DEFAULT OFF)
|
set(wxUSE_WINRT_DEFAULT OFF)
|
||||||
endif()
|
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)
|
set(wxUSE_WEBVIEW_EDGE_DEFAULT ON)
|
||||||
else()
|
else()
|
||||||
set(wxUSE_WEBVIEW_EDGE_DEFAULT OFF)
|
set(wxUSE_WEBVIEW_EDGE_DEFAULT OFF)
|
||||||
|
@@ -321,12 +321,14 @@ public:
|
|||||||
|
|
||||||
This backend is not enabled by default, to build it follow these steps:
|
This backend is not enabled by default, to build it follow these steps:
|
||||||
- Visual Studio 2015, or newer, is required
|
- Visual Studio 2015, or newer, is required
|
||||||
- Download the <a href="https://aka.ms/webviewnuget">WebView2 SDK</a>
|
- With CMake just enable @c wxUSE_WEBVIEW_EDGE
|
||||||
nuget package (Version 1.0.622.22 or newer)
|
- When not using CMake:
|
||||||
- Extract the package (it's a zip archive) to @c wxWidgets/3rdparty/webview2
|
- Download the <a href="https://aka.ms/webviewnuget">WebView2 SDK</a>
|
||||||
(you should have @c 3rdparty/webview2/build/native/include/WebView2.h
|
nuget package (Version 1.0.622.22 or newer)
|
||||||
file after unpacking it)
|
- Extract the package (it's a zip archive) to @c wxWidgets/3rdparty/webview2
|
||||||
- Enable @c wxUSE_WEBVIEW_EDGE in CMake or @c setup.h
|
(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
|
- Build wxWidgets webview library
|
||||||
- Copy @c WebView2Loader.dll from the subdirectory corresponding to the
|
- Copy @c WebView2Loader.dll from the subdirectory corresponding to the
|
||||||
architecture used (x86 or x64) of @c wxWidgets/3rdparty/webview2/build/
|
architecture used (x86 or x64) of @c wxWidgets/3rdparty/webview2/build/
|
||||||
|
Reference in New Issue
Block a user