Merge branch 'chromium-improvements' of https://github.com/MaartenBent/wxWidgets

Improvement to building Chromium using CMake: detect unknown build
configurations and make known "RelWithDebInfo" and "MinSizeRel" work
correctly.

See #24354.
This commit is contained in:
Vadim Zeitlin 2024-02-25 00:33:37 +01:00
commit 58b6239647
6 changed files with 78 additions and 23 deletions

View file

@ -11,6 +11,20 @@ include(../../source_groups.cmake)
include(cef_version_info.cmake)
set(KNOWN_CONFIGS "Debug;Release;RelWithDebInfo;MinSizeRel")
if(CMAKE_CONFIGURATION_TYPES)
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
if (NOT cfg IN_LIST KNOWN_CONFIGS)
message(WARNING "Unknown build configuration '${cfg}', this might cause issues with libcef_dll_wrapper")
endif()
endforeach()
elseif(CMAKE_BUILD_TYPE)
if (NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_CONFIGS)
message(WARNING "Unknown build configuration '${cfg}', this might cause issues with libcef_dll_wrapper")
endif()
endif()
find_path(CEF_ROOT
NAMES libcef_dll
HINTS
@ -70,8 +84,27 @@ if(NOT CEF_SHOW_RESULTS)
set(CMAKE_MESSAGE_LOG_LEVEL ERROR)
endif()
# prevent libcef_dll_wrapper from creating only Release and Debug configs
# in multi-configuration generators
# variable_watch does not seem to be scoped, and we can't unset it, or replace it,
# and we don't care if it is changed later, so use enable_guard
# to stop the guard from working after libcef_dll_wrapper is added.
set(enable_guard 1)
macro(set_readonly VAR)
set(_${VAR}_ ${${VAR}})
variable_watch(${VAR} readonly_guard)
endmacro()
macro(readonly_guard VAR access value)
if (enable_guard AND "${access}" STREQUAL "MODIFIED_ACCESS" AND NOT "${value}" STREQUAL "${_${VAR}_}")
set(${VAR} ${_${VAR}_})
message(WARNING "Blocked changing variable '${VAR}' to '${value}', reset to '${${VAR}}'")
endif()
endmacro()
set_readonly(CMAKE_CONFIGURATION_TYPES)
add_subdirectory(${CEF_ROOT} ${CEF_BUILD_DIR} EXCLUDE_FROM_ALL)
set(enable_guard 0)
set(CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL})
set_target_properties(libcef_dll_wrapper PROPERTIES
@ -80,22 +113,43 @@ set_target_properties(libcef_dll_wrapper PROPERTIES
)
if(NOT MSVC)
set_target_properties(libcef_dll_wrapper PROPERTIES COMPILE_OPTIONS "-Wno-extra")
target_compile_options(libcef_dll_wrapper PRIVATE "-Wno-extra")
endif()
# libcef_dll_wrapper only sets properties for Debug and Release.
# Extract the release options/flags and apply them to RelWithDebInfo and MinSizeRel.
macro(rls_flags property)
get_target_property(props libcef_dll_wrapper ${property})
string(FIND "${props}" "$<CONFIG:Release>:" index)
math(EXPR index "${index}+18")
string(SUBSTRING "${props}" ${index} -1 props)
string(FIND "${props}" ">" index)
string(SUBSTRING "${props}" 0 ${index} props)
if ("${property}" STREQUAL "COMPILE_DEFINITIONS")
target_compile_definitions(libcef_dll_wrapper PRIVATE
$<$<CONFIG:RelWithDebInfo>:${props}>
$<$<CONFIG:MinSizeRel>:${props}>
)
else()
target_compile_options(libcef_dll_wrapper PRIVATE
$<$<CONFIG:RelWithDebInfo>:${props}>
$<$<CONFIG:MinSizeRel>:${props}>
)
endif()
endmacro()
rls_flags(COMPILE_DEFINITIONS)
rls_flags(COMPILE_OPTIONS)
add_library(libcef SHARED IMPORTED GLOBAL)
if(APPLE)
set_target_properties(libcef PROPERTIES
IMPORTED_LOCATION_DEBUG "${CEF_ROOT}/Debug/Chromium Embedded Framework.framework/Chromium Embedded Framework"
IMPORTED_LOCATION_RELEASE "${CEF_ROOT}/Release/Chromium Embedded Framework.framework/Chromium Embedded Framework"
IMPORTED_LOCATION "${CEF_ROOT}/Release/Chromium Embedded Framework.framework/Chromium Embedded Framework"
)
else()
set_target_properties(libcef PROPERTIES
IMPORTED_LOCATION ${CEF_ROOT}/Release/libcef${CMAKE_SHARED_LIBRARY_SUFFIX}
IMPORTED_LOCATION_DEBUG ${CEF_ROOT}/Debug/libcef${CMAKE_SHARED_LIBRARY_SUFFIX}
IMPORTED_IMPLIB_DEBUG ${CEF_ROOT}/Debug/libcef${CMAKE_IMPORT_LIBRARY_SUFFIX}
IMPORTED_LOCATION_RELEASE ${CEF_ROOT}/Release/libcef${CMAKE_SHARED_LIBRARY_SUFFIX}
IMPORTED_IMPLIB_RELEASE ${CEF_ROOT}/Release/libcef${CMAKE_IMPORT_LIBRARY_SUFFIX}
IMPORTED_LOCATION "${CEF_ROOT}/Release/libcef${CMAKE_SHARED_LIBRARY_SUFFIX}"
IMPORTED_IMPLIB "${CEF_ROOT}/Release/libcef${CMAKE_IMPORT_LIBRARY_SUFFIX}"
)
endif()

View file

@ -10,18 +10,19 @@
# 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
# cmake -D CEF_VERSION=x.y.z+b -P cef_update_version_info.cmake
if(NOT DEFINED CEF_VERSION)
message(FATAL_ERROR "CEF_VERSION not defined")
endif()
set(CEF_BASE_URL "https://cef-builds.spotifycdn.com/cef_binary_")
set(CEF_DISTRIBUTION "_minimal")
set(CEF_FILE_EXT ".tar.bz2")
set(sha_file ${CMAKE_BINARY_DIR}/__info_sha.txt)
foreach(platform windows64 windowsarm64 windows32 macosx64 macosarm64 linux64 linuxarm64 linuxarm)
file(DOWNLOAD "${CEF_BASE_URL}${CEF_VERSION}_${platform}${CEF_FILE_EXT}.sha1" "${sha_file}")
file(DOWNLOAD "${CEF_BASE_URL}${CEF_VERSION}_${platform}${CEF_DISTRIBUTION}${CEF_FILE_EXT}.sha1" "${sha_file}")
file(READ "${sha_file}" CEF_SHA1_${platform})
endforeach()

View file

@ -18,27 +18,27 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(CEF_PLATFORM "macosarm64")
set(CEF_SHA1 "289ba3c54d801f757ef527f581ce49bd135c37d6")
set(CEF_SHA1 "ea0807407c6d9dc1bb58cc0d4c67e9c3a1208e93")
else()
set(CEF_PLATFORM "macosx64")
set(CEF_SHA1 "d52703aa67772ef8cbb9d1a264a454f930df795b")
set(CEF_SHA1 "91fbc0347bacaadb20816c0b14a5a2c06c5a58f6")
endif()
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SIZEOF_VOID_P LESS 8)
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm")
set(CEF_PLATFORM "linuxarm")
set(CEF_SHA1 "4173bc576d34258e7de8624b216c36bfd5b7cbf0")
set(CEF_SHA1 "267658ad627828a8482f69600f7f295190902124")
else()
message(ERROR "Unsupported Linux system")
endif()
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(CEF_PLATFORM "linuxarm64")
set(CEF_SHA1 "1a375eeb5d5c8a6df2e5911d5f6cfa25719ec140")
set(CEF_SHA1 "6457fc5dd3a847728f7b36f19a8d7291a3c5295d")
else()
set(CEF_PLATFORM "linux64")
set(CEF_SHA1 "a6b4166a5622a650165fa09c553ddaa9ade2338b")
set(CEF_SHA1 "e41bb03c6cd04d23e6a562b7783ec1da8eaa666c")
endif()
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@ -47,18 +47,18 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(ERROR "Unsupported Windows system")
else()
set(CEF_PLATFORM "windows32")
set(CEF_SHA1 "f7a9f407108eeefc1469b0b51ada59c38b135de9")
set(CEF_SHA1 "28ba21dfc7eb68764c8a658ab7d0b6904122ab33")
endif()
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(CEF_PLATFORM "windowsarm64")
set(CEF_SHA1 "0a6286fafdf30f560bfff6a9bd6604ddaa9ff433")
set(CEF_SHA1 "34e99674098383de12b67bb9242f64c9d10633ed")
else()
set(CEF_PLATFORM "windows64")
set(CEF_SHA1 "5053b25559fbb310d0858e21fd81a2067e7b79b6")
set(CEF_SHA1 "f44288f1bb32ae88e3384874970352048267d9af")
endif()
endif()
else()
message(ERROR "Unsupported CEF system")
endif()
set(CEF_URL "https://cef-builds.spotifycdn.com/cef_binary_119.4.7+g55e15c8+chromium-119.0.6045.199_${CEF_PLATFORM}.tar.bz2")
set(CEF_URL "https://cef-builds.spotifycdn.com/cef_binary_121.3.13+g5c4a81b+chromium-121.0.6167.184_${CEF_PLATFORM}${CEF_DISTRIBUTION}.tar.bz2")

View file

@ -61,4 +61,4 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
else()
message(ERROR "Unsupported CEF system")
endif()
set(CEF_URL "@CEF_BASE_URL@@CEF_VERSION@_${CEF_PLATFORM}@CEF_FILE_EXT@")
set(CEF_URL "@CEF_BASE_URL@@CEF_VERSION@_${CEF_PLATFORM}${CEF_DISTRIBUTION}@CEF_FILE_EXT@")

View file

@ -20,7 +20,7 @@ if(wxUSE_WEBVIEW_CHROMIUM AND TARGET webviewsample)
add_custom_command(
TARGET webviewsample
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_ROOT}/$<CONFIG> $<TARGET_FILE_DIR:webviewsample>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_ROOT}/Release $<TARGET_FILE_DIR:webviewsample>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CEF_ROOT}/Resources $<TARGET_FILE_DIR:webviewsample>
COMMENT "Copying webviewsample CEF resources..."
)
@ -38,7 +38,7 @@ if(wxUSE_WEBVIEW_CHROMIUM AND TARGET webviewsample)
TARGET webviewsample
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CEF_ROOT}/$<CONFIG>/Chromium Embedded Framework.framework"
"${CEF_ROOT}/Release/Chromium Embedded Framework.framework"
"$<TARGET_FILE_DIR:webviewsample>/../Frameworks/Chromium Embedded Framework.framework"
)

View file

@ -263,7 +263,7 @@ public:
new wxWebViewConfigurationImplChromium);
}
virtual void* GetNativeConfiguration() const
virtual void* GetNativeConfiguration() const override
{
// Our "native" configuration is our own Chromium-specific class from
// which we inherit.