Skip to content

Commit

Permalink
Merge branch 'cef-docs'
Browse files Browse the repository at this point in the history
CEF-related documentation and build improvements.

See wxWidgets#24230.
  • Loading branch information
vadz committed Jan 24, 2024
2 parents 509f853 + f265775 commit 5e1890c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 12 deletions.
45 changes: 40 additions & 5 deletions build/cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,46 @@ if(wxUSE_GUI)
message(WARNING "WebviewChromium libcef_dll_wrapper can only be built with MSVC... disabled")
wx_option_force_value(wxUSE_WEBVIEW_CHROMIUM OFF)
endif()
if(wxUSE_WEBVIEW_CHROMIUM AND CMAKE_CXX_STANDARD LESS 14)
# We shouldn't disable this option as it's disabled by default and
# if it is on, it means that CEF is meant to be used, but we can't
# continue neither as libcef_dll_wrapper will fail to build.
message(FATAL_ERROR "WebviewChromium requires at least C++14 but configured to use C++${CMAKE_CXX_STANDARD}")
if(wxUSE_WEBVIEW_CHROMIUM)
# Check for C++17 support as it's required by CEF: we trust
# CMAKE_CXX_STANDARD if it is defined, but we need to compile a
# test program if it is not because the compiler could be
# supporting C++17 anyway.
if (DEFINED CMAKE_CXX_STANDARD)
if (CMAKE_CXX_STANDARD GREATER_EQUAL 17)
set(wxHAVE_CXX17 ON)
endif()
else()
check_cxx_source_compiles("
#if defined(_MSVC_LANG)
#if _MSVC_LANG < 201703L
#error C++17 support is required
#endif
#elif __cplusplus < 201703L
#error C++17 support is required
#endif
int main() {
[[maybe_unused]] auto unused = 17;
}"
wxHAVE_CXX17)
endif()

if (NOT wxHAVE_CXX17)
# We shouldn't disable this option as it's disabled by default and
# if it is on, it means that CEF is meant to be used, but we can't
# continue neither as libcef_dll_wrapper will fail to build
# (actually it may still succeed with CEF v116 which provided
# its own stand-in for std::in_place used in CEF headers, but
# not with the later versions, so just fail instead of trying
# to detect CEF version here, as even v116 officially only
# supports C++17 anyhow).
if (DEFINED CMAKE_CXX_STANDARD)
set(cxx17_error_details "configured to use C++${CMAKE_CXX_STANDARD}")
else()
set(cxx17_error_details "the compiler doesn't support C++17 by default and CMAKE_CXX_STANDARD is not set")
endif()
message(FATAL_ERROR "WebviewChromium requires at least C++17 but ${cxx17_error_details}")
endif()
endif()
endif()

Expand Down
3 changes: 2 additions & 1 deletion build/cmake/lib/webview_chromium/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ set(USE_SANDBOX OFF) # Disable usage of sandbox on windows
add_subdirectory(${CEF_ROOT} ${CEF_BUILD_DIR} EXCLUDE_FROM_ALL)
set_target_properties(libcef_dll_wrapper PROPERTIES
FOLDER "Third Party Libraries"
COMPILE_FLAGS "-Wno-extra"
OUTPUT_NAME "libcef_dll_wrapper"
)

Expand All @@ -68,6 +67,8 @@ if(MSVC)
get_target_property(cef_compile_options libcef_dll_wrapper COMPILE_OPTIONS)
string(REGEX REPLACE "/MTd?;" "" cef_compile_options "${cef_compile_options}")
set_target_properties(libcef_dll_wrapper PROPERTIES COMPILE_OPTIONS "${cef_compile_options}")
else()
set_target_properties(libcef_dll_wrapper PROPERTIES COMPILE_OPTIONS "-Wno-extra")
endif()

add_library(libcef SHARED IMPORTED GLOBAL)
Expand Down
3 changes: 2 additions & 1 deletion build/cmake/setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ check_type_size(ssize_t SSIZE_T)

test_big_endian(WORDS_BIGENDIAN)

if(wxUSE_WEBVIEW_CHROMIUM)
# For generators using build type, ensure that wxHAVE_CEF_DEBUG matches it.
if(wxUSE_WEBVIEW_CHROMIUM AND DEFINED CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
if(${build_type} STREQUAL DEBUG)
set(wxHAVE_CEF_DEBUG ON)
Expand Down
8 changes: 8 additions & 0 deletions build/msw/wx_webview.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;_UNICODE;WXBUILDING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -187,6 +188,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;_UNICODE;WXBUILDING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -225,6 +227,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;NDEBUG;_UNICODE;WXBUILDING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -262,6 +265,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;NDEBUG;_UNICODE;WXBUILDING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -298,6 +302,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;_UNICODE;WXBUILDING;WXDLLNAME=$(TargetName);WXUSINGDLL;WXMAKINGDLL_WEBVIEW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -339,6 +344,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;_UNICODE;WXBUILDING;WXDLLNAME=$(TargetName);WXUSINGDLL;WXMAKINGDLL_WEBVIEW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -380,6 +386,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;NDEBUG;_UNICODE;WXBUILDING;WXDLLNAME=$(TargetName);WXUSINGDLL;WXMAKINGDLL_WEBVIEW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -424,6 +431,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE=1;_CRT_NON_CONFORMING_SWPRINTFS=1;_SCL_SECURE_NO_WARNINGS=1;__WXMSW__;NDEBUG;_UNICODE;WXBUILDING;WXDLLNAME=$(TargetName);WXUSINGDLL;WXMAKINGDLL_WEBVIEW;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
15 changes: 10 additions & 5 deletions interface/wx/webview_chromium.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@
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. 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.
distribution, which basically means using `cmake` to do it. Please note:
* Under Windows you must use `-DCEF_RUNTIME_LIBRARY_FLAG=/MD` option
to match the default wxWidgets build configuration.
* Under Unix remember that if you use `-DCMAKE_BUILD_TYPE=Debug` 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.
* Under all platforms you may want to use `-DCEF_USE_SANDBOX=OFF`
option to avoid linking with the sandbox library which is not
provided in the "Minimal Distribution" if you don't use this feature.
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
Expand Down

0 comments on commit 5e1890c

Please sign in to comment.