summaryrefslogtreecommitdiffstats
path: root/src/core/api/CMakeLists.txt
blob: f2ceb2dfd82db3918764f3fb6332e7d415d39bd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

find_package(Qt6 ${PROJECT_VERSION} REQUIRED COMPONENTS Gui Network Quick)
find_package(Qt6 ${PROJECT_VERSION} QUIET OPTIONAL_COMPONENTS WebChannel Positioning)

set(qtWebEngineProcessName QtWebEngineProcess)

qt_internal_add_module(WebEngineCore
     SOURCES
        qtwebenginecoreglobal.cpp qtwebenginecoreglobal.h qtwebenginecoreglobal_p.h
        qwebenginecertificateerror.cpp qwebenginecertificateerror.h
        qwebengineclientcertificateselection.cpp qwebengineclientcertificateselection.h
        qwebengineclientcertificatestore.cpp qwebengineclientcertificatestore.h
        qwebengineclienthints.cpp qwebengineclienthints.h
        qwebenginecontextmenurequest.cpp qwebenginecontextmenurequest.h qwebenginecontextmenurequest_p.h
        qwebenginecookiestore.cpp qwebenginecookiestore.h qwebenginecookiestore_p.h
        qwebenginedesktopmediarequest.cpp qwebenginedesktopmediarequest.h qwebenginedesktopmediarequest_p.h
        qwebenginedownloadrequest.cpp qwebenginedownloadrequest.h qwebenginedownloadrequest_p.h
        qwebenginefilesystemaccessrequest.cpp qwebenginefilesystemaccessrequest.h
        qwebenginefindtextresult.cpp qwebenginefindtextresult.h
        qwebenginefullscreenrequest.cpp qwebenginefullscreenrequest.h
        qwebenginehistory.cpp qwebenginehistory.h qwebenginehistory_p.h
        qwebenginehttprequest.cpp qwebenginehttprequest.h
        qwebengineloadinginfo.cpp qwebengineloadinginfo.h
        qwebenginemessagepumpscheduler.cpp qwebenginemessagepumpscheduler_p.h
        qwebenginenavigationrequest.cpp qwebenginenavigationrequest.h
        qwebenginenewwindowrequest.cpp qwebenginenewwindowrequest.h qwebenginenewwindowrequest_p.h
        qwebenginenotification.cpp qwebenginenotification.h
        qwebenginepage.cpp qwebenginepage.h qwebenginepage_p.h
        qwebengineprofile.cpp qwebengineprofile.h qwebengineprofile_p.h
        qwebenginequotarequest.cpp qwebenginequotarequest.h
        qwebengineregisterprotocolhandlerrequest.cpp qwebengineregisterprotocolhandlerrequest.h
        qwebenginescript.cpp qwebenginescript.h
        qwebenginescriptcollection.cpp qwebenginescriptcollection.h qwebenginescriptcollection_p.h
        qwebenginesettings.cpp qwebenginesettings.h
        qwebengineurlrequestinfo.cpp qwebengineurlrequestinfo.h qwebengineurlrequestinfo_p.h
        qwebengineurlrequestinterceptor.h qwebengineurlrequestinterceptor.cpp
        qwebengineurlrequestjob.cpp qwebengineurlrequestjob.h
        qwebengineurlscheme.cpp qwebengineurlscheme.h
        qwebengineurlschemehandler.cpp qwebengineurlschemehandler.h
        qwebengineglobalsettings.cpp qwebengineglobalsettings.h qwebengineglobalsettings_p.h
        qwebenginewebauthuxrequest.cpp qwebenginewebauthuxrequest.h qwebenginewebauthuxrequest_p.h
    DEFINES
        BUILDING_CHROMIUM
    INCLUDE_DIRECTORIES
        ../
        ../../3rdparty/chromium
        ../../3rdparty/chromium/third_party/abseil-cpp
        ../../3rdparty/chromium/third_party/perfetto/include
        ../../3rdparty/chromium/third_party/boringssl/src/include
    LIBRARIES
        Qt::CorePrivate
        Qt::GuiPrivate
        Qt::QuickPrivate
    PUBLIC_LIBRARIES
        Qt::Core
        Qt::Gui
        Qt::Network
        Qt::Quick
    EXTRA_CMAKE_FILES
        "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}WebEngineCoreDeploySupport.cmake"
    NO_GENERATE_CPP_EXPORTS
)

set_target_properties(WebEngineCore PROPERTIES QTWEBENGINEPROCESS_NAME ${qtWebEngineProcessName})
set_target_properties(WebEngineCore PROPERTIES CXX_STANDARD 20)

# Chromium included headers are not clean
qt_skip_warnings_are_errors(WebEngineCore)

if(CLANG OR GCC)
    target_compile_options(WebEngineCore PRIVATE
        "-Wno-unused-parameter"
        "-Wno-expansion-to-defined"
    )
endif()

if(GCC)
    target_compile_options(WebEngineCore PRIVATE
        "-Wno-packed-not-aligned"
    )
endif()

qt_internal_extend_target(WebEngineCore CONDITION QT_FEATURE_webengine_webchannel
    PUBLIC_LIBRARIES
        Qt::WebChannel
)
qt_internal_extend_target(WebEngineCore CONDITION QT_FEATURE_webengine_geolocation
    PUBLIC_LIBRARIES
        Qt::Positioning
)

get_install_config(config)
get_architectures(archs)
get_configs(configs)
list(GET archs 0 arch)

##
#  DOCS
##

qt_internal_add_docs(WebEngineCore
    ../doc/qtwebengine.qdocconf
)

add_code_attributions_target(
    TARGET generate_chromium_attributions
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/chromium_attributions.qdoc
    GN_TARGET :QtWebEngineCore
    FILE_TEMPLATE ../doc/about_credits.tmpl
    ENTRY_TEMPLATE ../doc/about_credits_entry.tmpl
    BUILDDIR ${buildDir}/${config}/${arch}
)
add_dependencies(generate_chromium_attributions run_core_GnDone)
add_dependencies(prepare_docs_WebEngineCore generate_chromium_attributions)

##
#  WEBENGINECORE RESOURCES
##

#TODO: use simply filter / globbing-expressions
set(localeList am ar bg bn ca cs da de el en-GB en-US es-419 es et fa fi fil fr
    gu he hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt-BR pt-PT ro ru sk
    sl sr sv sw ta te th tr uk vi zh-CN zh-TW)

set(resourceList qtwebengine_resources.pak
    qtwebengine_resources_100p.pak
    qtwebengine_resources_200p.pak
    qtwebengine_devtools_resources.pak)

set(stamps ${buildDir}/${config}/${arch}/QtWebEngineCore.stamp)

qt_internal_get_filename_path_mode(path_mode)

if(QT_FEATURE_webengine_v8_context_snapshot)
    foreach(arch ${archs})
       foreach(config ${configs})
           if(MACOS)
               set(ext_arch ".${arch}")
               # QTBUG-118120 gn does not support x86_64h
               if(ext_arch STREQUAL "x86_64h")
                   set(ext_arch "x86_64")
               endif()
           else()
               unset(ext_arch)
           endif()
           if("${config}" STREQUAL "Debug")
               set(ext_debug ".debug")
           else()
               unset(ext_debug)
           endif()
           get_filename_component(resSourcePath ${buildDir}/${config}/${arch}/v8_context_snapshot${ext_arch}${ext_debug}.bin ${path_mode})
           list(APPEND resourceFiles ${resSourcePath})
           if(MACOS)
               set(stamps ${stamps} ${buildDir}/${config}/${arch}/obj/tools/v8_context_snapshot/v8_context_snapshot.stamp)
           endif()
       endforeach()
    endforeach()
endif()

foreach(loc ${localeList})
    get_filename_component(locSourcePath ${buildDir}/${config}/${arch}/qtwebengine_locales/${loc}.pak ${path_mode})
    list(APPEND localeFiles ${locSourcePath})
endforeach()

foreach(res ${resourceList})
    get_filename_component(resSourcePath ${buildDir}/${config}/${arch}/${res} ${path_mode})
    list(APPEND resourceFiles ${resSourcePath})
endforeach()


if(NOT QT_FEATURE_webengine_system_icu)
    get_filename_component(icuFile ${buildDir}/${config}/${arch}/icudtl.dat ${path_mode})
    list(APPEND resourceFiles ${icuFile})
    set_target_properties(WebEngineCore PROPERTIES ICUDTL_FILE ${icuFile})
endif()

if(QT_FEATURE_framework)
    set(allResourceFiles ${localeFiles} ${resourceFiles})
    target_sources(WebEngineCore PRIVATE ${allResourceFiles})

    set_source_files_properties(${localeFiles}
        TARGET_DIRECTORY WebEngineCore
        PROPERTIES MACOSX_PACKAGE_LOCATION Resources/qtwebengine_locales
        GENERATED TRUE
    )
    set_source_files_properties(${resourceFiles}
        TARGET_DIRECTORY WebEngineCore
        PROPERTIES MACOSX_PACKAGE_LOCATION Resources
        GENERATED TRUE
    )

    add_custom_command(OUTPUT ${allResourceFiles} DEPENDS "${stamps}")
    add_custom_target(generate_resources_${config} DEPENDS ${allResourceFiles})

    addCopyCommand(WebEngineCore "${localeFiles}"
        "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/QtWebEngineCore.framework/Versions/A/Resources/qtwebengine_locales/"
    )
    addCopyCommand(WebEngineCore "${resourceFiles}"
        "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/QtWebEngineCore.framework/Versions/A/Resources/"
    )

else()
    install(FILES ${localeFiles}
        DESTINATION ${INSTALL_TRANSLATIONSDIR}/qtwebengine_locales
        CONFIGURATIONS ${config}
    )
    install(FILES ${resourceFiles}
        DESTINATION ${INSTALL_DATADIR}/resources
        CONFIGURATIONS ${config}
    )
    if(QT_SUPERBUILD OR NOT QT_WILL_INSTALL)
        addCopyCommand(WebEngineCore "${localeFiles}"
            ${QT_BUILD_DIR}/${INSTALL_TRANSLATIONSDIR}/qtwebengine_locales
        )
        addCopyCommand(WebEngineCore "${resourceFiles}"
            ${QT_BUILD_DIR}/${INSTALL_DATADIR}/resources
        )
   endif()
endif()