112 lines
3.8 KiB
CMake
112 lines
3.8 KiB
CMake
# This file is part of Telegram Desktop,
|
|
# the official desktop application for the Telegram messaging service.
|
|
#
|
|
# For license and copyright information please follow this link:
|
|
# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
# TwidgetCore from ThirdParty/twidget (core/src), the renderer
|
|
# core twidget's platforms share: it applies validated widget operations to a
|
|
# document laid out by twidget's litehtml fork, answers layout queries, runs
|
|
# animations, canvas, input and text selection, and records a display list the
|
|
# platform paints. Built as twidget's own twidget_core target is, in fork mode
|
|
# (TW_LITEHTML_TWIDGET) against lib_litehtml, the only litehtml we build; the
|
|
# per-platform backends are not compiled, our Qt backend replaces them.
|
|
# The profile's UA layer (tables.uaStylesheet of widget-sandbox's
|
|
# packages/core/profile.json) is generated at configure time into
|
|
# tw_ua_stylesheet.h, as twidget's own CMakeLists does.
|
|
# Consumers include its headers as "core/src/<name>.h".
|
|
# There is no packaged branch: no distribution ships this library.
|
|
|
|
add_library(lib_widget_renderer STATIC)
|
|
init_target(lib_widget_renderer "(external)")
|
|
|
|
add_library(tdesktop::lib_widget_renderer ALIAS lib_widget_renderer)
|
|
|
|
set(widget_sandbox_root ${third_party_loc}/widget-sandbox)
|
|
set(widget_renderer_root ${third_party_loc}/twidget)
|
|
set(widget_renderer_loc ${widget_renderer_root}/core/src)
|
|
|
|
if (NOT EXISTS ${widget_renderer_loc}/renderer.cpp)
|
|
message(FATAL_ERROR "twidget sources are missing, run 'git submodule update --init --recursive'.")
|
|
endif()
|
|
|
|
set(widget_renderer_gen ${CMAKE_CURRENT_BINARY_DIR}/widget_renderer_gen)
|
|
set(widget_profile_json ${widget_sandbox_root}/packages/core/profile.json)
|
|
if (NOT EXISTS ${widget_profile_json})
|
|
message(FATAL_ERROR "widget-sandbox sources are missing, run 'git submodule update --init --recursive'.")
|
|
endif()
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${widget_profile_json})
|
|
file(READ ${widget_profile_json} widget_profile)
|
|
string(JSON widget_ua_stylesheet GET "${widget_profile}" tables uaStylesheet)
|
|
file(WRITE ${widget_renderer_gen}/tw_ua_stylesheet.h.tmp
|
|
"// Generated by Telegram/cmake/lib_widget_renderer.cmake from packages/core/profile.json (tables.uaStylesheet).\n"
|
|
"#pragma once\n"
|
|
"inline constexpr const char* TW_UA_STYLESHEET = R\"tw-ua(${widget_ua_stylesheet})tw-ua\";\n")
|
|
configure_file(
|
|
${widget_renderer_gen}/tw_ua_stylesheet.h.tmp
|
|
${widget_renderer_gen}/tw_ua_stylesheet.h
|
|
COPYONLY)
|
|
|
|
# Silence third-party warnings. On MSVC the flags must ride an INTERFACE lib
|
|
# linked after common_options to land last and beat its /W4 /WX.
|
|
if (MSVC)
|
|
add_library(lib_widget_renderer_warnings_off INTERFACE)
|
|
target_compile_options(lib_widget_renderer_warnings_off
|
|
INTERFACE
|
|
/W0
|
|
/WX-
|
|
)
|
|
endif()
|
|
|
|
nice_target_sources(lib_widget_renderer ${widget_renderer_loc}
|
|
PRIVATE
|
|
animations.cpp
|
|
animations.h
|
|
backend.h
|
|
canvas.cpp
|
|
canvas.h
|
|
canvas_ops.h
|
|
compositor.cpp
|
|
compositor.h
|
|
computed_style.cpp
|
|
computed_style.h
|
|
css.cpp
|
|
css.h
|
|
display_list.h
|
|
encode.cpp
|
|
filters.cpp
|
|
filters.h
|
|
paint_policy.cpp
|
|
paint_policy.h
|
|
png.cpp
|
|
png.h
|
|
renderer.cpp
|
|
renderer.h
|
|
)
|
|
|
|
target_include_directories(lib_widget_renderer
|
|
PUBLIC
|
|
${widget_renderer_root}
|
|
${widget_sandbox_root}/packages/desktop/sandbox/include
|
|
PRIVATE
|
|
${widget_renderer_gen}
|
|
${widget_renderer_loc}
|
|
)
|
|
|
|
target_compile_definitions(lib_widget_renderer
|
|
PUBLIC
|
|
TW_LITEHTML_TWIDGET
|
|
)
|
|
|
|
target_link_libraries(lib_widget_renderer
|
|
PUBLIC
|
|
tdesktop::lib_litehtml
|
|
tdesktop::lib_widget_sandbox
|
|
)
|
|
|
|
if (MSVC)
|
|
target_compile_definitions(lib_widget_renderer PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
target_link_libraries(lib_widget_renderer PRIVATE lib_widget_renderer_warnings_off)
|
|
else()
|
|
target_compile_options(lib_widget_renderer PRIVATE -w)
|
|
endif()
|