forked from qt/qtwebengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
206 lines (178 loc) · 6.88 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.19)
include(.cmake.conf)
include(ExternalProject)
include(cmake/Functions.cmake)
project(QtWebEngineRepoSuperBuild
VERSION "${QT_REPO_MODULE_VERSION}"
DESCRIPTION "Qt WebEngine Libraries"
HOMEPAGE_URL "https://qt.io/"
LANGUAGES CXX C
)
# Make sure we use the fixed BASE argument of qt_add_resource.
set(QT_USE_FIXED_QT_ADD_RESOURCE_BASE TRUE)
option(FORCE_TEST_RUN "Forces test run after compilation" FALSE)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core)
# coin configures 'just' for test build
if(QT_BUILD_STANDALONE_TESTS)
qt_build_repo()
return()
endif()
set(installDir ${CMAKE_CURRENT_BINARY_DIR}/install)
### FEATURES
qt_build_repo_begin()
qt_feature_module_begin(ONLY_EVALUATE_FEATURES)
# Enable printing of feature summary by forcing qt_configure_record_command
# to work in spite of ONLY_EVALUATE_FEATURES.
set(__QtFeature_only_evaluate_features OFF)
include(configure.cmake)
include(src/core/api/configure.cmake)
qt_feature_module_end(ONLY_EVALUATE_FEATURES)
if(NOT ${webEngineSupport})
add_custom_target(WebEngineErrorMessage ALL
${CMAKE_COMMAND} -E cmake_echo_color --red "QtWebEngine will not be built: ${webEngineError}"
COMMENT "Check QtWebEngine support")
message("-- Support check for QtWebEngine failed: ${webEngineError}")
set(QT_FEATURE_qtwebengine_build OFF CACHE BOOL "Build QtWebEngine" FORCE)
endif()
if(NOT ${pdfSupport})
add_custom_target(PdfErrorMessage ALL
${CMAKE_COMMAND} -E cmake_echo_color --red "QtPdf will not be built: ${pdfError}"
COMMENT "Check QtPdf support")
message("-- Support check for QtPdf failed: ${pdfError}")
set(QT_FEATURE_qtpdf_build OFF CACHE BOOL "Build QtPdf" FORCE)
endif()
if(NOT QT_FEATURE_qtwebengine_build AND NOT QT_FEATURE_qtpdf_build)
# coin missing artifacts workaround
install(FILES coin-bug-707 DESTINATION ${INSTALL_DATADIR})
return()
endif()
add_subdirectory(src/core/api)
add_subdirectory(src/process)
add_subdirectory(src/webenginewidgets)
add_subdirectory(src/webenginequick)
qt_build_repo_end()
### NINJA
if(NOT Ninja_FOUND)
externalproject_add(ninja
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/ninja
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ninja
INSTALL_DIR ${installDir}
PREFIX ninja
USES_TERMINAL_BUILD ON
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=<INSTALL_DIR>
)
endif()
### GN
if(NOT Gn_FOUND)
externalproject_add(gn
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/gn
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gn
INSTALL_DIR ${installDir}
PREFIX gn
USES_TERMINAL_BUILD ON
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=<INSTALL_DIR>
-DWEBENGINE_ROOT_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
)
endif()
### LIBS
# on windows source path can be specified without hard drive letter,
# however we need that for gn use REALPATH
get_filename_component(WEBENGINE_ROOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
get_qt_features(featureList webengine)
get_qt_features(featureList qtwebengine)
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/qtbase/lib/cmake/Qt6/qt.toolchain.cmake")
list(APPEND libsCmakeArgs
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
)
endif()
list(TRANSFORM featureList PREPEND "-D")
list(APPEND libsCmakeArgs
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DWEBENGINE_ROOT_BUILD_PATH=${CMAKE_CURRENT_BINARY_DIR}"
"-DWEBENGINE_ROOT_SOURCE_DIR=${WEBENGINE_ROOT_SOURCE_DIR}"
"-DWEBENGINE_REPO_BUILD=TRUE"
"${featureList}"
)
if(LINUX)
set(cmd "${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src")
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/build.sh CONTENT "ulimit -n 4096 && ${cmd}\n")
set(coinBug699 COMMAND bash build.sh)
else()
if ("${CMAKE_DEFAULT_CONFIGS}" STREQUAL "all")
set(coinBug699 COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src)
else()
set(coinBug699 COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src --config $<CONFIG>)
endif()
endif()
externalproject_add(libs
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src
PREFIX libs
USES_TERMINAL_CONFIGURE ON
USES_TERMINAL_BUILD ON
BUILD_ALWAYS TRUE
CMAKE_ARGS ${libsCmakeArgs}
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Starting $<CONFIG> build"
${coinBug699}
COMMAND ${CMAKE_COMMAND} -E echo "$<CONFIG> build complete"
# TODO: this is aworkaround for broken qt_lib_webengine*.pri files,
# coin does the in-source build and later calls qmake to build examples
# and this leftover file gets sucked instead of install or src/mkspecs,
# simply remove it, we need to implment a dry run in qt base to fix it.
COMMAND ${CMAKE_COMMAND} -E remove_directory ../mkspecs
)
if(QT_BUILD_EXAMPLES AND BUILD_SHARED_LIBS)
externalproject_add(examples
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/examples
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/examples
PREFIX examples
USES_TERMINAL_BUILD ON
BUILD_ALWAYS TRUE
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
"${featureList}"
)
externalproject_add_stepdependencies(examples install libs)
endif()
if(FORCE_TEST_RUN OR QT_BUILD_TESTS)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS QuickTest Test)
unset(testRunCommand)
if(FORCE_TEST_RUN)
set(testRunCommand TEST_COMMAND ctest)
endif()
externalproject_add(tests
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/tests
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/tests
PREFIX tests
USES_TERMINAL_BUILD ON
USES_TERMINAL_TEST ON
BUILD_ALWAYS TRUE
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
"${featureList}"
INSTALL_COMMAND ""
${testRunCommand}
)
externalproject_add_stepdependencies(tests install libs)
if(QT_BUILD_EXAMPLES AND BUILD_SHARED_LIBS)
externalproject_add_stepdependencies(tests install examples)
endif()
endif()
if(NOT Gn_FOUND)
externalproject_add_stepdependencies(libs install gn)
endif()
if(NOT Ninja_FOUND)
externalproject_add_stepdependencies(gn install ninja)
endif()
if(NOT QT_FEATURE_framework)
# install resources (again), coin calls install with DESTDIR
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/translations/qtwebengine_locales
DESTINATION ${CMAKE_INSTALL_PREFIX}/translations
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resources
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
endif()