Merge pull request #10251 from akallabeth/windows-webview2
Windows webview2
This commit is contained in:
commit
2582c0cc87
@ -49,17 +49,12 @@ if (WITH_WEBVIEW)
|
||||
wrapper/webview_impl.cpp
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
find_package(unofficial-webview2 CONFIG REQUIRED)
|
||||
list(APPEND LIBS
|
||||
unofficial::webview2::webview2
|
||||
)
|
||||
elseif(APPLE)
|
||||
if(APPLE)
|
||||
find_library(WEBKIT Webkit REQUIRED)
|
||||
list(APPEND LIBS
|
||||
${WEBKIT}
|
||||
)
|
||||
else()
|
||||
elseif(NOT WIN32)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(WEBVIEW_GTK webkit2gtk-4.1)
|
||||
if (NOT WEBVIEW_GTK_FOUND)
|
||||
@ -93,4 +88,8 @@ target_compile_definitions(
|
||||
PUBLIC
|
||||
${DEFINITIONS}
|
||||
)
|
||||
if (WITH_WEBVIEW AND NOT WITH_WEBVIEW_QT)
|
||||
include (WebView2)
|
||||
target_link_webview2("sdl-common-aad-view")
|
||||
endif()
|
||||
|
||||
|
51
cmake/WebView2.cmake
Normal file
51
cmake/WebView2.cmake
Normal file
@ -0,0 +1,51 @@
|
||||
if(WIN32)
|
||||
# WebView2 SDK
|
||||
set(WEBVIEW2_VERSION "1.0.2535.41")
|
||||
set(WEBVIEW2_URL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}")
|
||||
set(WEBVIEW2_SHA256 "c9c5518e4d7efa9079ad87bafb64f3c8e8edca0e95d34df878034b880a7af56b")
|
||||
set(WEBVIEW2_DEFAULT_PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")
|
||||
|
||||
if(NOT EXISTS ${WEBVIEW2_PACKAGE_DIR})
|
||||
unset(WEBVIEW2_PACKAGE_DIR CACHE)
|
||||
endif()
|
||||
find_path(WEBVIEW2_PACKAGE_DIR
|
||||
NAMES
|
||||
"build/native/include/WebView2.h"
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH # dont prepend CMAKE_PREFIX
|
||||
)
|
||||
if(NOT WEBVIEW2_PACKAGE_DIR)
|
||||
message(WARNING "WebView2 SDK not found locally, downloading ${WEBVIEW2_VERSION} ...")
|
||||
set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_DEFAULT_PACKAGE_DIR} CACHE PATH "WebView2 SDK PATH" FORCE)
|
||||
file(
|
||||
DOWNLOAD
|
||||
${WEBVIEW2_URL}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget
|
||||
EXPECTED_HASH
|
||||
SHA256=${WEBVIEW2_SHA256}
|
||||
)
|
||||
file(MAKE_DIRECTORY ${WEBVIEW2_PACKAGE_DIR})
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E tar x "${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget"
|
||||
WORKING_DIRECTORY
|
||||
"${WEBVIEW2_PACKAGE_DIR}"
|
||||
)
|
||||
endif()
|
||||
set(WEBVIEW2_PACKAGE_DIR ${WEBVIEW2_PACKAGE_DIR} CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
function(target_link_webview2 target)
|
||||
if(WIN32)
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
"${WEBVIEW2_PACKAGE_DIR}/build/native/include"
|
||||
)
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
shlwapi
|
||||
version
|
||||
"${WEBVIEW2_PACKAGE_DIR}/build/native/${CMAKE_VS_PLATFORM_NAME}/WebView2LoaderStatic.lib"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
@ -15,7 +15,7 @@ set (WITH_INTERNAL_MD5 ON CACHE BOOL "nightly default")
|
||||
set (WITH_INTERNAL_RC4 ON CACHE BOOL "nightly default")
|
||||
set (WITH_FFMPEG OFF CACHE BOOL "nightly default")
|
||||
set (WITH_SWSCALE OFF CACHE BOOL "nightly default")
|
||||
set (WITH_WEBVIEW OFF CACHE BOOL "nightly default")
|
||||
set (WITH_WEBVIEW ON CACHE BOOL "nightly default")
|
||||
set (ZLIB_USE_STATIC_LIBS ON CACHE BOOL "ci default")
|
||||
set (WITH_SDL_IMAGE_DIALOGS ON CACHE BOOL "nightly default")
|
||||
set (SDL_USE_COMPILED_RESOURCES ON CACHE BOOL "nightly default")
|
||||
|
Loading…
Reference in New Issue
Block a user