CMake: Add support for webkit2

This commit is contained in:
Maarten Bent
2018-12-01 13:38:43 +01:00
parent e9fb190ed7
commit 1c5cbe0a61
7 changed files with 93 additions and 22 deletions

View File

@@ -2869,6 +2869,10 @@ set(WEBVIEW_GTK_SRC
src/gtk/webview_webkit.cpp
)
set(WEBVIEW2_GTK_SRC
src/gtk/webview_webkit2.cpp
)
set(XRC_SRC
src/xrc/xh_activityindicator.cpp
src/xrc/xh_animatctrl.cpp

View File

@@ -225,8 +225,19 @@ if(wxUSE_GUI)
if(wxUSE_WEBVIEW AND WXGTK)
find_package(LibSoup)
find_package(Webkit)
if(NOT WEBKIT_FOUND OR NOT LIBSOUP_FOUND)
if(WXGTK2)
find_package(Webkit 1.0)
elseif(WXGTK3)
find_package(Webkit 3.0)
find_package(Webkit2)
if(NOT WEBKIT2_FOUND)
wx_option_force_value(wxUSE_WEBVIEW_WEBKIT2 OFF)
endif()
endif()
if(NOT WEBKIT_FOUND)
wx_option_force_value(wxUSE_WEBVIEW_WEBKIT OFF)
endif()
if((NOT WEBKIT_FOUND AND NOT WEBKIT2_FOUND) OR NOT LIBSOUP_FOUND)
message(WARNING "webkit not found, wxWebview won't be available")
wx_option_force_value(wxUSE_WEBVIEW OFF)
endif()

View File

@@ -14,25 +14,39 @@ wx_append_sources(WEBVIEW_FILES WEBVIEW_CMN)
if(WXMSW)
wx_append_sources(WEBVIEW_FILES WEBVIEW_MSW)
elseif(WXGTK)
wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK)
if(wxUSE_WEBVIEW_WEBKIT2)
wx_append_sources(WEBVIEW_FILES WEBVIEW2_GTK)
elseif(wxUSE_WEBVIEW_WEBKIT)
wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK)
endif()
elseif(APPLE)
wx_append_sources(WEBVIEW_FILES WEBVIEW_OSX_SHARED)
endif()
wx_add_library(webview ${WEBVIEW_FILES})
if(wxUSE_WEBVIEW_WEBKIT2)
wx_lib_compile_definitions(webview PRIVATE
-DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/web-extensions"
)
endif()
if(APPLE)
wx_lib_link_libraries(webview PUBLIC
"-framework WebKit"
)
elseif(WXGTK)
wx_lib_include_directories(webview PUBLIC
${WEBKIT_INCLUDE_DIR}
${LIBSOUP_INCLUDE_DIRS}
)
wx_lib_link_libraries(webview PUBLIC
${WEBKIT_LIBRARIES}
${LIBSOUP_LIBRARIES}
)
if(LIBSOUP_FOUND)
wx_lib_include_directories(webview PUBLIC ${LIBSOUP_INCLUDE_DIRS})
wx_lib_link_libraries(webview PUBLIC ${LIBSOUP_LIBRARIES})
endif()
if(wxUSE_WEBVIEW_WEBKIT2)
wx_lib_include_directories(webview PUBLIC ${WEBKIT2_INCLUDE_DIR})
wx_lib_link_libraries(webview PUBLIC ${WEBKIT2_LIBRARIES})
elseif(wxUSE_WEBVIEW_WEBKIT)
wx_lib_include_directories(webview PUBLIC ${WEBKIT_INCLUDE_DIR})
wx_lib_link_libraries(webview PUBLIC ${WEBKIT_LIBRARIES})
endif()
endif()
wx_finalize_lib(webview)

View File

@@ -1,16 +1,18 @@
# - Find Webkit-3.0
# Find the Webkit-3.0 includes and library
# - Find Webkit
# Find the Webkit includes and library
#
# WEBKIT_INCLUDE_DIR - Where to find webkit include sub-directory.
# WEBKIT_LIBRARIES - List of libraries when using Webkit-3.0.
# WEBKIT_FOUND - True if Webkit-3.0 found.
# WEBKIT_LIBRARIES - List of libraries when using Webkit.
# WEBKIT_FOUND - True if Webkit found.
SET( WEBKIT_VERSION "1.0")
SET(WEBKIT_VERSION 1.0)
if(DEFINED Webkit_FIND_VERSION)
SET(WEBKIT_VERSION ${Webkit_FIND_VERSION})
endif()
IF (WEBKIT_INCLUDE_DIR)
# Already in cache, be silent.
SET(WEBKIT_FIND_QUIETLY TRUE)
ENDIF (WEBKIT_INCLUDE_DIR)
SET(WEBKIT_INCLUDE_DIR WEBKIT_INCLUDE_DIR-NOTFOUND)
SET(WEBKIT_LIBRARY WEBKIT_LIBRARY-NOTFOUND)
SET(WEBKIT_LIBRARIES WEBKIT_LIBRARIES-NOTFOUND)
FIND_PATH(WEBKIT_INCLUDE_DIR webkit/webkit.h
PATH_SUFFIXES "webkitgtk-${WEBKIT_VERSION}"
@@ -35,4 +37,4 @@ ELSE(WEBKIT_FOUND)
SET( WEBKIT_LIBRARIES )
ENDIF(WEBKIT_FOUND)
MARK_AS_ADVANCED( WEBKIT_LIBRARY WEBKIT_INCLUDE_DIR )
MARK_AS_ADVANCED(WEBKIT_LIBRARY WEBKIT_LIBRARIES WEBKIT_INCLUDE_DIR)

View File

@@ -0,0 +1,37 @@
# - Find Webkit2
# Find the Webkit2 includes and library
#
# WEBKIT2_INCLUDE_DIR - Where to find Webkit2 include sub-directory.
# WEBKIT2_LIBRARIES - List of libraries when using Webkit2.
# WEBKIT2_FOUND - True if Webkit2 found.
SET( WEBKIT2_VERSION 4.0)
set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND)
set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND)
set(WEBKIT2_LIBRARIES WEBKIT2_LIBRARIES-NOTFOUND)
FIND_PATH(WEBKIT2_INCLUDE_DIR webkit2/webkit2.h
PATH_SUFFIXES "webkitgtk-${WEBKIT2_VERSION}"
)
SET(WEBKIT2_NAMES "webkit2gtk-${WEBKIT2_VERSION}")
FIND_LIBRARY(WEBKIT2_LIBRARY
NAMES ${WEBKIT2_NAMES}
)
# Handle the QUIETLY and REQUIRED arguments and set WEBKIT2_FOUND to
# TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
WEBKIT2 DEFAULT_MSG
WEBKIT2_LIBRARY WEBKIT2_INCLUDE_DIR
)
IF(WEBKIT2_FOUND)
SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} )
ELSE(WEBKIT2_FOUND)
SET( WEBKIT2_LIBRARIES )
ENDIF(WEBKIT2_FOUND)
MARK_AS_ADVANCED(WEBKIT2_LIBRARY WEBKIT2_LIBRARIES WEBKIT2_INCLUDE_DIR)

View File

@@ -356,7 +356,7 @@ wx_option(wxUSE_DRAGIMAGE "use wxDragImage")
wx_option(wxUSE_UIACTIONSIMULATOR "use wxUIActionSimulator (experimental)")
wx_option(wxUSE_DC_TRANSFORM_MATRIX "use wxDC::SetTransformMatrix and related")
wx_option(wxUSE_WEBVIEW_WEBKIT "use wxWebView WebKit backend")
# TODO: wxUSE_WEBVIEW_WEBKIT2
wx_option(wxUSE_WEBVIEW_WEBKIT2 "use wxWebView WebKit2 backend")
if(WIN32 OR APPLE)
set(wxUSE_PRIVATE_FONTS_DEFAULT ON)
else()

View File

@@ -2812,6 +2812,9 @@ WEBVIEW_GTK_HDR =
WEBVIEW_GTK_SRC =
src/gtk/webview_webkit.cpp
WEBVIEW2_GTK_SRC =
src/gtk/webview_webkit2.cpp
# wxXRC
XRC_SRC =