Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better CEF integration #1557

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions src/CMakeModules/Bootstrap_Linux.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required (VERSION 3.16)

include(ExternalProject)
include(FetchContent)

if(POLICY CMP0135)
Expand Down Expand Up @@ -59,38 +58,19 @@ FIND_PACKAGE (X11 REQUIRED)

if (ENABLE_HTML)
if (USE_SYSTEM_CEF)
set(CEF_LIB_PATH "/usr/lib/casparcg-cef-117")
set(CEF_INCLUDE_PATH "/usr/include/casparcg-cef-117")

set(CEF_LIB
"-Wl,-rpath,${CEF_LIB_PATH} ${CEF_LIB_PATH}/libcef.so"
"${CEF_LIB_PATH}/libcef_dll_wrapper.a"
)
find_package(CEF 117 REQUIRED)
Julusian marked this conversation as resolved.
Show resolved Hide resolved
else()
casparcg_add_external_project(cef)
ExternalProject_Add(cef
FetchContent_Declare(cef
URL ${CASPARCG_DOWNLOAD_MIRROR}/cef/cef_binary_117.2.5%2Bgda4c36a%2Bchromium-117.0.5938.152_linux64_minimal.tar.bz2
URL_HASH SHA1=7e6c9cf591cf3b1dabe65a7611f5fc166df2ec1e
DOWNLOAD_DIR ${CASPARCG_DOWNLOAD_CACHE}
CMAKE_ARGS -DUSE_SANDBOX=Off
INSTALL_COMMAND ""
PATCH_COMMAND git apply ${CASPARCG_PATCH_DIR}/cef117.patch
BUILD_BYPRODUCTS
"<SOURCE_DIR>/Release/libcef.so"
"<BINARY_DIR>/libcef_dll_wrapper/libcef_dll_wrapper.a"
)
ExternalProject_Get_Property(cef SOURCE_DIR)
ExternalProject_Get_Property(cef BINARY_DIR)

# Note: All of these must be referenced in the BUILD_BYPRODUCTS above, to satisfy ninja
set(CEF_LIB
"${SOURCE_DIR}/Release/libcef.so"
"${BINARY_DIR}/libcef_dll_wrapper/libcef_dll_wrapper.a"
)
set(USE_SANDBOX OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(cef)

set(CEF_INCLUDE_PATH "${SOURCE_DIR}")
set(CEF_BIN_PATH "${SOURCE_DIR}/Release")
set(CEF_RESOURCE_PATH "${SOURCE_DIR}/Resources")
set(CEF_BIN_PATH "${cef_SOURCE_DIR}/Release")
set(CEF_RESOURCE_PATH "${cef_SOURCE_DIR}/Resources")
endif()
endif ()

Expand Down
26 changes: 11 additions & 15 deletions src/CMakeModules/Bootstrap_Windows.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required (VERSION 3.16)

include(ExternalProject)
include(FetchContent)

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
Expand Down Expand Up @@ -61,7 +62,7 @@ else ()
--with-libraries=regex
--with-libraries=system
--with-libraries=thread
BUILD_COMMAND ./b2 install debug release --prefix=${BOOST_INSTALL_DIR} link=static threading=multi runtime-link=shared -j ${CONFIG_CPU_COUNT}
BUILD_COMMAND ./b2 install debug release --prefix=${BOOST_INSTALL_DIR} link=static threading=multi runtime-link=shared -j ${CONFIG_CPU_COUNT}
INSTALL_COMMAND ""
)
set(BOOST_INCLUDE_PATH "${BOOST_INSTALL_DIR}/include/boost-1_74")
Expand Down Expand Up @@ -221,24 +222,19 @@ set(LIBERATION_FONTS_BIN_PATH "${PROJECT_SOURCE_DIR}/shell/liberation-fonts")
casparcg_add_runtime_dependency("${LIBERATION_FONTS_BIN_PATH}/LiberationMono-Regular.ttf")

# CEF
if (ENABLE_HTML)
casparcg_add_external_project(cef)
ExternalProject_Add(cef
if(ENABLE_HTML)
FetchContent_Declare(cef
URL ${CASPARCG_DOWNLOAD_MIRROR}/cef/cef_binary_117.2.5%2Bgda4c36a%2Bchromium-117.0.5938.152_windows64_minimal.tar.bz2
URL_HASH MD5=cff21bce81bada2a9e5f0afbec0858f0
DOWNLOAD_DIR ${CASPARCG_DOWNLOAD_CACHE}
CMAKE_ARGS -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD
INSTALL_COMMAND ""
PATCH_COMMAND git apply ${CASPARCG_PATCH_DIR}/cef117.patch
PATCH_COMMAND git apply ${CASPARCG_PATCH_DIR}/cef117.patch
)
ExternalProject_Get_Property(cef SOURCE_DIR)
ExternalProject_Get_Property(cef BINARY_DIR)
set(USE_SANDBOX OFF CACHE INTERNAL "")
set(CEF_RUNTIME_LIBRARY_FLAG "/MD" CACHE INTERNAL "")
FetchContent_MakeAvailable(cef)

set(CEF_INCLUDE_PATH ${SOURCE_DIR})
set(CEF_BIN_PATH ${SOURCE_DIR}/Release)
set(CEF_RESOURCE_PATH ${SOURCE_DIR}/Resources)
link_directories(${SOURCE_DIR}/Release)
link_directories(${BINARY_DIR}/libcef_dll_wrapper)
set(CEF_BIN_PATH ${cef_SOURCE_DIR}/Release)
set(CEF_RESOURCE_PATH ${cef_SOURCE_DIR}/Resources)

casparcg_add_runtime_dependency_dir("${CEF_RESOURCE_PATH}/locales")
casparcg_add_runtime_dependency("${CEF_RESOURCE_PATH}/chrome_100_percent.pak")
Expand All @@ -256,7 +252,7 @@ if (ENABLE_HTML)
casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vk_swiftshader.dll")
casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vk_swiftshader_icd.json")
casparcg_add_runtime_dependency("${CEF_BIN_PATH}/vulkan-1.dll")
endif ()
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT casparcg)
Expand Down
119 changes: 84 additions & 35 deletions src/CMakeModules/patches/cef117.patch
Original file line number Diff line number Diff line change
@@ -1,39 +1,88 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -132,11 +132,8 @@
# Global setup.
#

-# For VS2022 and Xcode 12+ support.
-cmake_minimum_required(VERSION 3.21)
-
-# Only generate Debug and Release configuration types.
-set(CMAKE_CONFIGURATION_TYPES Debug Release)
+# VS2022 and Xcode 12+ support needs 3.21, but ubuntu22.04 ships with 3.20
+cmake_minimum_required(VERSION 3.20)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -140,7 +140,7 @@ set(CMAKE_CONFIGURATION_TYPES Debug Rele

# Project name.
# TODO: Change this line to match your project name when you copy this file.
@@ -234,22 +231,3 @@
-project(cef)
+project(cef VERSION 117.2.5)

# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
@@ -253,3 +253,13 @@ if(DOXYGEN_FOUND)
else()
message(WARNING "Doxygen must be installed to generate API documentation.")
endif()
+
+
+#
+# Install targets.
+#
+
+include(GNUInstallDirs)
+install(DIRECTORY ${CEF_INCLUDE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(DIRECTORY ${CEF_BINARY_DIR}/ ${CEF_RESOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(PROGRAMS ${CEF_BINARY_DIR}/chrome-sandbox DESTINATION ${CMAKE_INSTALL_LIBDIR})
--- a/cmake/cef_variables.cmake
+++ b/cmake/cef_variables.cmake
@@ -53,6 +53,7 @@ endif()

# Path to the include directory.
set(CEF_INCLUDE_PATH "${_CEF_ROOT}")
+set(CEF_INCLUDE_DIR "${_CEF_ROOT}/include")

# Path to the libcef_dll_wrapper target.
set(CEF_LIBCEF_DLL_WRAPPER_PATH "${_CEF_ROOT}/libcef_dll")
--- /dev/null
+++ b/libcef_dll/CEFConfig.cmake
@@ -0,0 +1,4 @@
+include("${CMAKE_CURRENT_LIST_DIR}/CEFTargets.cmake")
+
+add_library(CEF::CEF INTERFACE IMPORTED)
+target_link_libraries(CEF::CEF INTERFACE CEF::libcef_dll_wrapper)
--- a/libcef_dll/CMakeLists.txt
+++ b/libcef_dll/CMakeLists.txt
@@ -782,3 +782,43 @@ target_compile_definitions(${CEF_TARGET}

# Display configuration settings.
PRINT_CEF_CONFIG()
-
-
-#
-# Define the API documentation target.
-#
-
-find_package(Doxygen)
-if(DOXYGEN_FOUND)
- add_custom_target(apidocs ALL
- # Generate documentation in the docs/html directory.
- COMMAND "${DOXYGEN_EXECUTABLE}" Doxyfile
- # Write a docs/index.html file.
- COMMAND ${CMAKE_COMMAND} -E echo "<html><head><meta http-equiv=\"refresh\" content=\"0;URL='html/index.html'\"/></head></html>" > docs/index.html
- WORKING_DIRECTORY "${CEF_ROOT}"
- COMMENT "Generating API documentation with Doxygen..."
- VERBATIM )
-else()
- message(WARNING "Doxygen must be installed to generate API documentation.")
-endif()
# Remove the default "lib" prefix from the resulting library.
set_target_properties(${CEF_TARGET} PROPERTIES PREFIX "")
+
+
+#
+# Install targets.
+#
+
+include(GNUInstallDirs)
+if(NOT CMAKE_INSTALL_CMAKEDIR)
+ set(CEF_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake)
+else()
+ set(CEF_INSTALL_CMAKEDIR ${CMAKE_INSTALL_CMAKEDIR})
+endif()
+
+target_include_directories(${CEF_TARGET} PUBLIC
+ $<BUILD_INTERFACE:${CEF_INCLUDE_PATH}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+target_link_directories(${CEF_TARGET} PUBLIC
+ $<BUILD_INTERFACE:${CEF_BINARY_DIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>
+)
+if(OS_WINDOWS)
+ target_link_libraries(${CEF_TARGET} PUBLIC libcef.lib)
+else()
+ target_link_libraries(${CEF_TARGET} PUBLIC cef)
+endif()
+
+install(TARGETS ${CEF_TARGET} EXPORT CEF DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(EXPORT CEF FILE CEFTargets.cmake NAMESPACE CEF:: DESTINATION ${CEF_INSTALL_CMAKEDIR})
+install(FILES CEFConfig.cmake DESTINATION ${CEF_INSTALL_CMAKEDIR})
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/CEFConfigVersion.cmake
+ VERSION ${PROJECT_VERSION_MAJOR}
+ COMPATIBILITY SameMajorVersion
+)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CEFConfigVersion.cmake DESTINATION ${CEF_INSTALL_CMAKEDIR})
+
+add_library(CEF::CEF INTERFACE IMPORTED GLOBAL)
+target_link_libraries(CEF::CEF INTERFACE ${CEF_TARGET})
45 changes: 15 additions & 30 deletions src/modules/html/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
cmake_minimum_required (VERSION 3.16)
project (html)
cmake_minimum_required(VERSION 3.16)
project(html)

set(SOURCES
producer/html_cg_proxy.cpp
producer/html_producer.cpp
producer/html_cg_proxy.cpp
producer/html_cg_proxy.h

html.cpp
)
set(HEADERS
producer/html_cg_proxy.h
producer/html_producer.h
producer/html_producer.cpp
producer/html_producer.h

html.h
html.cpp
html.h
)

casparcg_add_module_project(html
SOURCES ${SOURCES} ${HEADERS}
INIT_FUNCTION "html::init"
UNINIT_FUNCTION "html::uninit"
CLI_INTERCEPTOR "html::intercept_command_line"
casparcg_add_module_project(html SOURCES ${SOURCES}
INIT_FUNCTION "html::init"
UNINIT_FUNCTION "html::uninit"
CLI_INTERCEPTOR "html::intercept_command_line"
)
target_link_libraries(html CEF::CEF)

# TODO: remove when appropriate
target_include_directories(html PRIVATE
..
../..
${CEF_INCLUDE_PATH}
)
)

set_target_properties(html PROPERTIES FOLDER modules)
source_group(sources\\producer producer/*)
source_group(sources ./*)

if(MSVC)
target_link_libraries(html
libcef
optimized Release/libcef_dll_wrapper
debug Debug/libcef_dll_wrapper
)
else()
target_link_libraries(html
${CEF_LIB}
)
endif()

Loading