From 0bb9cd004d719806a097daa0c0dfee5053ea8d82 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Mon, 8 Mar 2021 00:26:24 +0100 Subject: [PATCH] CMake: copy webview2 loader for monolithic build --- build/cmake/lib/CMakeLists.txt | 1 + build/cmake/lib/webview/CMakeLists.txt | 31 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index cf40472c45..5c574c7723 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -99,6 +99,7 @@ if(wxBUILD_MONOLITHIC) foreach(file ${wxMONO_NONCOMPILED_CPP_FILES}) set_source_files_properties(${file} PROPERTIES HEADER_FILE_ONLY TRUE) endforeach() + wx_webview_copy_webview2_loader(wxmono) wx_finalize_lib(wxmono) endif() diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 1946c7ebcf..cc3298ff33 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -9,6 +9,24 @@ include(../../source_groups.cmake) +function(wx_webview_copy_webview2_loader target) + if(NOT WXMSW OR NOT wxUSE_WEBVIEW_EDGE OR NOT TARGET ${target}) + return() + endif() + + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(WEBVIEW2_ARCH x86) + else() + set(WEBVIEW2_ARCH x64) + endif() + + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + "${WEBVIEW2_PACKAGE_DIR}/build/native/${WEBVIEW2_ARCH}/WebView2Loader.dll" + "$/WebView2Loader.dll") +endfunction() + + wx_append_sources(WEBVIEW_FILES WEBVIEW_CMN) if(WXMSW) @@ -77,18 +95,7 @@ elseif(WXMSW) endif() endif() - if (NOT wxBUILD_MONOLITHIC) - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - set(WEBVIEW2_ARCH x86) - else() - set(WEBVIEW2_ARCH x64) - endif() - - add_custom_command(TARGET wxwebview POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${WEBVIEW2_PACKAGE_DIR}/build/native/${WEBVIEW2_ARCH}/WebView2Loader.dll" - "$/WebView2Loader.dll") - endif() + wx_webview_copy_webview2_loader(wxwebview) endif() elseif(WXGTK) if(LIBSOUP_FOUND)