Add wxWebViewChromium to CMake

If wxUSE_WEBVIEW_CHROMIUM is enabled CEF is automatically
downloaded during the build process
This commit is contained in:
Tobias Taschner 2018-02-02 16:24:35 +01:00
parent 09bd796a76
commit f1bb68f3fc
No known key found for this signature in database
GPG key ID: AE6ECD71294F87FD
13 changed files with 259 additions and 1 deletions

View file

@ -2935,6 +2935,14 @@ set(WEBVIEW_GTK_SRC
src/gtk/webview_webkit.cpp
)
set(WEBVIEWCHROMIUM_HDR
wx/webview.h
wx/webview_chromium.h
)
set(WEBVIEWCHROMIUM_SRC
src/common/webview_chromium.cpp
)
set(XRC_SRC
src/xrc/xh_activityindicator.cpp
src/xrc/xh_animatctrl.cpp

View file

@ -60,6 +60,7 @@ if(wxUSE_GUI)
add_opt_lib(media wxUSE_MEDIACTRL)
add_opt_lib(gl wxUSE_OPENGL)
add_opt_lib(qa wxUSE_DEBUGREPORT)
add_opt_lib(webview_chromium wxUSE_WEBVIEW_CHROMIUM)
endif() # wxUSE_GUI
# Include cmake file for every library

View file

@ -0,0 +1,59 @@
#############################################################################
# Name: build/cmake/lib/webview_chromium/CMakeLists.txt
# Purpose: CMake file for webview_chromium library
# Author: Tobias Taschner
# Created: 2018-02-03
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
include(cef_version_info.cmake)
ExternalProject_Add(
cef
URL ${CEF_URL}
URL_HASH SHA1=${CEF_SHA1}
PATCH_COMMAND
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/fixup_cef.cmake
CMAKE_ARGS -DUSE_ATL=OFF -DUSE_SANDBOX=OFF
BUILD_COMMAND
${CMAKE_COMMAND} --build . --target libcef_dll_wrapper --config $<CONFIG>
INSTALL_COMMAND ""
)
ExternalProject_Get_property(cef SOURCE_DIR)
ExternalProject_Get_property(cef BINARY_DIR)
add_library(libcef_dll_wrapper STATIC IMPORTED)
get_property(HAVE_MULTI_CONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(HAVE_MULTI_CONFIG_GENERATOR)
set_target_properties(libcef_dll_wrapper PROPERTIES
IMPORTED_LOCATION_DEBUG ${BINARY_DIR}/libcef_dll_wrapper/Debug/libcef_dll_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}
IMPORTED_LOCATION_RELEASE ${BINARY_DIR}/libcef_dll_wrapper/Release/libcef_dll_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}
)
else()
set_target_properties(libcef_dll_wrapper PROPERTIES
IMPORTED_LOCATION ${BINARY_DIR}/libcef_dll_wrapper/libcef_dll_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}
)
endif()
add_library(libcef STATIC IMPORTED)
if(APPLE)
set_target_properties(libcef PROPERTIES
IMPORTED_LOCATION_DEBUG "${SOURCE_DIR}/Debug/Chromium Embedded Framework.framework/Chromium Embedded Framework"
IMPORTED_LOCATION_RELEASE "${SOURCE_DIR}/Release/Chromium Embedded Framework.framework/Chromium Embedded Framework"
)
else()
set_target_properties(libcef PROPERTIES
IMPORTED_LOCATION_DEBUG ${SOURCE_DIR}/Debug/libcef${CMAKE_LINK_LIBRARY_SUFFIX}
IMPORTED_LOCATION_RELEASE ${SOURCE_DIR}/Release/libcef${CMAKE_LINK_LIBRARY_SUFFIX}
)
endif()
wx_append_sources(WEBVIEW_CHROMIUM_FILES WEBVIEWCHROMIUM)
wx_add_library(webview_chromium ${WEBVIEW_CHROMIUM_FILES})
wx_lib_include_directories(webview_chromium PRIVATE ${SOURCE_DIR})
wx_lib_link_libraries(webview_chromium PUBLIC webview PRIVATE libcef libcef_dll_wrapper)
add_dependencies(webview_chromium cef)
wx_finalize_lib(webview)

View file

@ -0,0 +1,34 @@
#############################################################################
# Name: build/cmake/lib/webview_chromium/cef_update_version_info.cmake
# Purpose: Script to update
# Author: Tobias Taschner
# Created: 2018-02-03
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
# Use this script to automatically update cef_version_info.cmake
#
# Run this script with cmake script mode
# cmake -D CEF_VERSION=3.x.y.z.h -P cef_update_version_info.cmake
if(NOT DEFINED CEF_VERSION)
message(FATAL_ERROR "CEF_VERSION not defined")
endif()
set(CEF_BASE_URL "http://opensource.spotify.com/cefbuilds/cef_binary_")
set(CEF_FILE_EXT ".tar.bz2")
set(sha_file ${CMAKE_BINARY_DIR}/__info_sha.txt)
foreach(platform macosx64 linux32 linux64 windows32 windows64)
file(DOWNLOAD "${CEF_BASE_URL}${CEF_VERSION}_${platform}${CEF_FILE_EXT}.sha1" "${sha_file}")
file(READ "${sha_file}" CEF_SHA1_${platform})
endforeach()
file(REMOVE ${sha_file})
configure_file(
cef_version_info.cmake.in
cef_version_info.cmake
@ONLY
)

View file

@ -0,0 +1,37 @@
#############################################################################
# Name: build/cmake/lib/webview_chromium/cef_version_info.cmake
# Purpose: CMake file CEF version information
# Author: Tobias Taschner
# Created: 2018-02-03
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
#
# DO NOT MODIFY MANUALLY
#
# To update the include file see cef_update_version_info.cmake
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CEF_PLATFORM "macosx64")
set(CEF_SHA1 "ca26459c5ef344cac04b2ed121514db79e067cff")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SIZEOF_VOID_P LESS 8)
set(CEF_PLATFORM "linux32")
set(CEF_SHA1 "75bacba21804024a29ae2f0780d079b04f6b607f")
else()
set(CEF_PLATFORM "linux64")
set(CEF_SHA1 "3d1674170e9b79c4d7c0749a0879db7d6abef7fe")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_SIZEOF_VOID_P LESS 8)
set(CEF_PLATFORM "windows32")
set(CEF_SHA1 "bbdfbb1733c07edbcaab75f963f82694a94c8968")
else()
set(CEF_PLATFORM "windows64")
set(CEF_SHA1 "87fcdab9c20ae7494455460eb3f3e658abe95013")
endif()
else()
message(ERROR "Unsupported CEF system")
endif()
set(CEF_URL "http://opensource.spotify.com/cefbuilds/cef_binary_3.3239.1723.g071d1c1_${CEF_PLATFORM}.tar.bz2")

View file

@ -0,0 +1,37 @@
#############################################################################
# Name: build/cmake/lib/webview_chromium/cef_version_info.cmake
# Purpose: CMake file CEF version information
# Author: Tobias Taschner
# Created: 2018-02-03
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
#
# DO NOT MODIFY MANUALLY
#
# To update the include file see cef_update_version_info.cmake
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CEF_PLATFORM "macosx64")
set(CEF_SHA1 "@CEF_SHA1_macosx64@")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SIZEOF_VOID_P LESS 8)
set(CEF_PLATFORM "linux32")
set(CEF_SHA1 "@CEF_SHA1_linux32@")
else()
set(CEF_PLATFORM "linux64")
set(CEF_SHA1 "@CEF_SHA1_linux64@")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_SIZEOF_VOID_P LESS 8)
set(CEF_PLATFORM "windows32")
set(CEF_SHA1 "@CEF_SHA1_windows32@")
else()
set(CEF_PLATFORM "windows64")
set(CEF_SHA1 "@CEF_SHA1_windows64@")
endif()
else()
message(ERROR "Unsupported CEF system")
endif()
set(CEF_URL "@CEF_BASE_URL@@CEF_VERSION@_${CEF_PLATFORM}@CEF_FILE_EXT@")

View file

@ -0,0 +1,16 @@
#############################################################################
# Name: build/cmake/lib/webview/fixup_cef.cmake
# Purpose: CMake script to up patch CEF
# Author: Tobias Taschner
# Created: 2018-02-03
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
# This script modifies CEF cmake files to allow different VC runtime settings
set(var_file cmake/cef_variables.cmake)
file(READ ${var_file} var_file_contents)
string(REGEX REPLACE "/MTd?" "" new_file_contents ${var_file_contents})
file(WRITE "${var_file}" ${new_file_contents})

View file

@ -187,6 +187,7 @@ wx_option(wxUSE_AFM_FOR_POSTSCRIPT "in wxPostScriptDC class use AFM (adobe font
wx_option(wxUSE_PRINTING_ARCHITECTURE "use printing architecture")
wx_option(wxUSE_SVG "use wxSVGFileDC device context")
wx_option(wxUSE_WEBVIEW "use wxWebView library")
wx_option(wxUSE_WEBVIEW_CHROMIUM "Enable CEF based wxWebViewChromium" OFF)
if(APPLE)
wx_option(wxUSE_WEBKIT "use wxWebKitCtrl (Mac-only, use wxWebView instead)")
endif()

View file

@ -142,7 +142,9 @@ wx_add_sample(typetest typetest.cpp typetest.h)
wx_add_sample(uiaction DEPENDS wxUSE_UIACTIONSIMULATOR)
wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS)
wx_add_sample(vscroll vstest.cpp)
wx_add_sample(webview LIBRARIES webview stc adv NAME webviewsample DEPENDS wxUSE_WEBVIEW)
if(wxUSE_WEBVIEW)
include(webview.cmake)
endif()
# widgets Sample
set(SAMPLE_WIDGETS_SRC
activityindicator.cpp

View file

@ -0,0 +1,36 @@
#############################################################################
# Name: build/cmake/samples/webview.cmake
# Purpose: CMake script to build webview samples
# Author: Tobias Taschner
# Created: 2018-02-17
# Copyright: (c) 2018 wxWidgets development team
# Licence: wxWindows licence
#############################################################################
wx_add_sample(webview LIBRARIES webview stc adv NAME webviewsample)
if(wxUSE_WEBVIEW_CHROMIUM)
wx_add_sample(webview LIBRARIES webview_chromium stc adv NAME webviewsample_chromium)
target_compile_definitions(webviewsample_chromium PRIVATE -DwxWEBVIEW_SAMPLE_CHROMIUM)
ExternalProject_Get_property(cef SOURCE_DIR)
if(WIN32)
add_custom_command(
TARGET webviewsample_chromium
POST_BUILD
# Add compatiblity manifest
COMMAND
mt.exe /nologo -manifest ${wxSOURCE_DIR}/samples/webview/compatibility.manifest
"-inputresource:$<TARGET_FILE:webviewsample_chromium>;#1"
"-outputresource:$<TARGET_FILE:webviewsample_chromium>;#1"
# Copy CEF libraries
COMMAND
${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/$<CONFIG> $<TARGET_FILE_DIR:webviewsample_chromium>
# Copy CEF resources
COMMAND
${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/Resources $<TARGET_FILE_DIR:webviewsample_chromium>
COMMENT "Prepare executable for runtime..."
)
elseif(APPLE)
# TODO: define and build helper bundle
endif()
endif()

View file

@ -321,6 +321,8 @@
#cmakedefine01 wxUSE_WEBVIEW
#cmakedefine01 wxUSE_WEBVIEW_CHROMIUM
#ifdef __WXMSW__
#cmakedefine01 wxUSE_WEBVIEW_IE
#else

View file

@ -2844,6 +2844,14 @@ WEBVIEW_GTK_HDR =
WEBVIEW_GTK_SRC =
src/gtk/webview_webkit.cpp
# wxWEBVIEWCHORMIUM
WEBVIEWCHROMIUM_HDR =
wx/webview.h
wx/webview_chromium.h
WEBVIEWCHROMIUM_SRC =
src/common/webview_chromium.cpp
# wxXRC
XRC_SRC =

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application support for Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>