Assume release CEF build by default under Unix

This prevents wxWebViewChromium from referencing debug-only functions
that are not defined in the release build of libcef_dll_wrapper.

Unfortunately, CEF build doesn't provide any way to detect if the
wrappers were built in debug or in release mode, so just assume the
latter and add --enable-cef-debug configure option to build with a debug
build of CEF wrapper if necessary.
This commit is contained in:
Vadim Zeitlin 2023-09-19 00:36:07 +02:00
parent b5e278c0eb
commit 4816448cff
5 changed files with 71 additions and 1 deletions

37
configure vendored
View file

@ -1240,6 +1240,7 @@ enable_printarch
enable_svg
enable_webview
enable_webviewchromium
enable_cef_debug
enable_graphics_ctx
enable_graphics_d2d
enable_clipboard
@ -2210,6 +2211,7 @@ Optional Features:
--enable-svg use wxSVGFileDC device context
--enable-webview use wxWebView library
--enable-webviewchromium use wxWebView Chromium backend
--enable-cef_debug use debug build of CEF wrapper
--enable-graphics_ctx use graphics context 2D drawing API
--enable-graphics-d2d use Direct2D-based graphics context
--enable-clipboard use wxClipboard class
@ -8857,6 +8859,36 @@ fi
eval "$wx_cv_use_webviewchromium"
enablestring=
defaultval=
if test -z "$defaultval"; then
if test x"$enablestring" = xdisable; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --enable-cef_debug was given.
if test "${enable_cef_debug+set}" = set; then :
enableval=$enable_cef_debug;
if test "$enableval" = yes; then
wx_cv_use_cef_debug='wxUSE_CEF_DEBUG=yes'
else
wx_cv_use_cef_debug='wxUSE_CEF_DEBUG=no'
fi
else
wx_cv_use_cef_debug='wxUSE_CEF_DEBUG=${'DEFAULT_wxUSE_CEF_DEBUG":-$defaultval}"
fi
eval "$wx_cv_use_cef_debug"
if test "$wxUSE_MAC" != 1; then
enablestring=
@ -39810,6 +39842,11 @@ $as_echo "$wx_cv_lib_cef" >&6; }
USE_WEBVIEW_CHROMIUM=1
$as_echo "#define wxUSE_WEBVIEW_CHROMIUM 1" >>confdefs.h
if test "$wxUSE_CEF_DEBUG" = "yes"; then
$as_echo "#define wxHAVE_CEF_DEBUG 1" >>confdefs.h
fi
else
as_fn_error $? "CEF not detected: $cef_error

View file

@ -789,6 +789,11 @@ dnl This one is not enabled by default as it requires CEF to be available under
dnl 3rdparty/cef.
WX_ARG_ENABLE(webviewchromium, [ --enable-webviewchromium use wxWebView Chromium backend], wxUSE_WEBVIEW_CHROMIUM)
dnl When using wxWebViewChromium, we assume that CEF wrapper DLL was built in
dnl release mode, use this option if it was built in debug one, i.e. with
dnl -DCMAKE_BUILD_TYPE=Debug
WX_ARG_ENABLE(cef_debug, [ --enable-cef_debug use debug build of CEF wrapper], wxUSE_CEF_DEBUG)
dnl wxDC is implemented in terms of wxGraphicsContext in wxOSX so the latter
dnl can't be disabled, don't even provide an option to do it
if test "$wxUSE_MAC" != 1; then
@ -6971,6 +6976,12 @@ if test "$wxUSE_WEBVIEW" = "yes"; then
wxUSE_WEBVIEW="yes"
USE_WEBVIEW_CHROMIUM=1
AC_DEFINE(wxUSE_WEBVIEW_CHROMIUM)
dnl Just trust the option value, we don't really have any simple
dnl way to check the CEF wrapper DLL build type.
if test "$wxUSE_CEF_DEBUG" = "yes"; then
AC_DEFINE(wxHAVE_CEF_DEBUG)
fi
else
AC_MSG_ERROR([CEF not detected: $cef_error

View file

@ -47,7 +47,11 @@
2. Unpack the archive into `3rdparty/cef` directory under wxWidgets source
directory.
3. Build `libcef_dll_wrapper` using the instructions provided in the CEF
distribution, but, in short, just by using `cmake` to do it.
distribution, but, in short, just by using `cmake` to do it. Please note
that if you use `-DCMAKE_BUILD_TYPE=Debug` under Unix when building it, you
need to pass `--enable-cef_debug` option to wxWidgets configure to avoid
mismatches between various definitions in the wrapper itself and in
wxWidgets.
4. Copy the static library binary in the platform-dependent location:
- Under MSW, copy `libcefl_dll_wrapper.lib` file to either
`3rdparty/cef/Release` or `3rdparty/cef/Debug` depending on the build

View file

@ -601,6 +601,11 @@
#define wxUSE_SELECT_DISPATCHER 0
#define wxUSE_EPOLL_DISPATCHER 0
/*
Use debug version of CEF in wxWebViewChromium.
*/
#undef wxHAVE_CEF_DEBUG
/*
Use GStreamer for Unix.

View file

@ -29,6 +29,15 @@
#include <gdk/gdkx.h>
#endif
// When not using debug version of CEF under Unix we need to make sure to
// predefine NDEBUG before including its headers to avoid ODR violations.
#ifndef wxHAVE_CEF_DEBUG
#ifndef NDEBUG
#define NDEBUG
#define wxUNDEF_NDEBUG
#endif
#endif
#ifdef __WXOSX__
#include "wx/osx/private/webview_chromium.h"
#endif
@ -55,6 +64,10 @@ wxGCC_WARNING_RESTORE(unused-parameter)
#pragma warning(pop)
#endif
#ifdef wxUNDEF_NDEBUG
#undef NDEBUG
#endif
#if CHROME_VERSION_BUILD < 5845
#error "Unsupported CEF version"
#endif