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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# These are functions aim to help during configure step checks and build setup
macro(qt_webengine_run_configure configure_file_path)
# Run main configure that does not belong to any module
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_file_path})
qt_webengine_version_sanity_check()
qt_webengine_check_support()
qt_feature_module_end(ONLY_EVALUATE_FEATURES)
endmacro()
function(qt_webengine_configure_begin)
set(configure_checks "" PARENT_SCOPE)
set(configure_versions "" PARENT_SCOPE)
endfunction()
# Sets QT_CONFIGURE_CHECK_(module)_build and prints found issues and does the cleanup
function(qt_webengine_configure_end)
qt_webengine_cleanup_configure_checks()
qt_webengine_cleanup_configure_versions()
endfunction()
macro(qt_webengine_version_sanity_check)
foreach(check ${configure_versions})
if(NOT DEFINED QT_CONFIGURE_CHECK_${check})
message(WARNING "Version for check '${check}' defined but no configure check for it")
endif()
endforeach()
endmacro()
macro(qt_webengine_check_support)
foreach(module_checked ${configure_checks})
set(error_message "The following configure errors were found:")
set(warning_message "The following configure warnings were found:")
string(TOLOWER ${module_checked} module)
set(QT_CONFIGURE_CHECK_${module}_build ON CACHE BOOL "Build ${module_checked} Modules" FORCE)
if(${configure_checks_${module}_error} OR ${configure_checks_${module}_warning})
foreach(check ${configure_checks_${module}})
if(NOT ${configure_checks_${module}_${check}})
if(NOT ${configure_checks_${module}_${check}_optional})
string(APPEND error_message "\n * ${configure_checks_${module}_${check}_error}")
else()
string(APPEND warning_message "\n * ${configure_checks_${module}_${check}_error}")
endif()
endif()
endforeach()
if(${configure_checks_${module}_warning})
message(STATUS "Configure checks for ${module} found issues.${warning_message}")
qt_configure_add_report_entry(
TYPE WARNING
MESSAGE "${module_checked} has warnings. ${warning_message}"
)
endif()
if(${configure_checks_${module}_error})
message(STATUS "Configure checks for ${module} failed.${error_message}")
set(QT_CONFIGURE_CHECK_${module}_build OFF CACHE BOOL "Build ${module_checked} Modules" FORCE)
qt_configure_add_report_entry(
TYPE WARNING
MESSAGE "${module_checked} won't be built. ${error_message}"
)
qt_webengine_add_error_target(${module_checked} "Delete CMakeCache.txt and try to reconfigure.")
endif()
endif()
endforeach()
endmacro()
macro(qt_webengine_cleanup_configure_checks)
foreach(module_checked ${configure_checks})
string(TOLOWER ${module_checked} module)
foreach(check ${configure_checks_${module}})
unset(configure_checks_${module}_${check}_error PARENT_SCOPE)
unset(configure_checks_${module}_${check} PARENT_SCOPE)
unset(configure_checks_${module}_${check}_optional PARENT_SCOPE)
endforeach()
unset(configure_checks_${module} PARENT_SCOPE)
unset(configure_checks_${module}_error PARENT_SCOPE)
unset(configure_checks_${module}_warning PARENT_SCOPE)
unset(configure_checks_${module}_documentation PARENT_SCOPE)
endforeach()
unset(configure_checks PARENT_SCOPE)
endmacro()
macro(qt_webengine_cleanup_configure_versions)
foreach(check ${configure_versions})
unset(QT_CONFIGURE_CHECK_${check}_version PARENT_SCOPE)
endforeach()
unset(configure_versions PARENT_SCOPE)
endmacro()
function(qt_webengine_generate_documentation in_file_path out_file_path)
foreach(tag ${configure_checks_qtwebengine_documentation})
foreach(doc ${configure_checks_qtwebengine_documentation_${tag}})
string(APPEND DOCUMENTATION_${tag} "\n \\li ${doc}")
endforeach()
endforeach()
configure_file(${in_file_path} ${out_file_path} @ONLY)
endfunction()
function(qt_webengine_set_version check version)
if(NOT DEFINED QT_CONFIGURE_CHECK_${check}_version)
set(QT_CONFIGURE_CHECK_${check}_version ${version} PARENT_SCOPE)
set(configure_versions ${configure_versions} ${check} PARENT_SCOPE)
else()
message(FATAL_ERROR "Version '${check}' redefined. Aborting ...")
endif()
endfunction()
function(qt_webengine_add_error_target module error_message)
add_custom_target(${module}_error_message ALL
${CMAKE_COMMAND} -E cmake_echo_color --red "${module} will not be built: ${error_message}"
COMMENT "${module} configure check"
VERBATIM
)
endfunction()
function(qt_webengine_normalize_check name out_var)
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" name "${name}")
set(${out_var} "${name}" PARENT_SCOPE)
endfunction()
# Sets QT_CONFIGURE_CHECK_(check) according to CONDITION
function(qt_webengine_configure_check check)
qt_webengine_normalize_check("${check}" check)
cmake_parse_arguments(PARSE_ARGV 1 arg
"OPTIONAL" "" "MODULES;MESSAGE;CONDITION;TAGS;DOCUMENTATION"
)
_qt_internal_validate_all_args_are_parsed(arg)
foreach(m ${arg_MODULES})
string(TOLOWER ${m} module)
if(NOT DEFINED configure_checks_${module})
set(configure_checks_${module} "" PARENT_SCOPE)
set(configure_checks_${module}_error OFF PARENT_SCOPE)
set(configure_checks_${module}_warning OFF PARENT_SCOPE)
set(configure_checks_${module}_documentation "" PARENT_SCOPE)
set(configure_checks ${m} ${configure_checks})
set(configure_checks ${configure_checks} PARENT_SCOPE)
endif()
if(NOT DEFINED configure_checks_${module}_${check})
set(configure_checks_${module}_${check}_error "" PARENT_SCOPE)
if("x${arg_CONDITION}" STREQUAL "x")
set(arg_CONDITION ON)
endif()
if(NOT "x${arg_PLATFORM}" STREQUAL "x")
set(arg_CONDITION NOT ${arg_PLATFORM} OR ${arg_CONDITION})
endif()
qt_evaluate_config_expression(result ${arg_CONDITION})
set(configure_checks_${module}_${check} ${result} PARENT_SCOPE)
set(QT_CONFIGURE_CHECK_${check} ${result} PARENT_SCOPE)
if(NOT ${result})
if(NOT ${arg_OPTIONAL})
set(configure_checks_${module}_error ON PARENT_SCOPE)
else()
set(configure_checks_${module}_warning ON PARENT_SCOPE)
endif()
set(configure_checks_${module}_${check}_error ${arg_MESSAGE} PARENT_SCOPE)
endif()
if(NOT ${arg_OPTIONAL})
set(configure_checks_${module}_${check}_optional FALSE PARENT_SCOPE)
else()
set(configure_checks_${module}_${check}_optional TRUE PARENT_SCOPE)
endif()
if(DEFINED arg_DOCUMENTATION)
if(NOT DEFINED arg_TAGS)
set(arg_TAGS ALL_PLATFORMS)
endif()
foreach(tag ${arg_TAGS})
if(NOT DEFINED configure_checks_${module}_documentation_${tag})
set(configure_checks_${module}_documentation
${configure_checks_${module}_documentation} ${tag} PARENT_SCOPE)
endif()
set(configure_checks_${module}_documentation_${tag}
${configure_checks_${module}_documentation_${tag}}
${arg_DOCUMENTATION} PARENT_SCOPE
)
endforeach()
endif()
set(configure_checks_${module} ${check} ${configure_checks_${module}} PARENT_SCOPE)
else()
message(FATAL_ERROR "Duplicated config check '${check}' found. Aborting !")
endif()
endforeach()
endfunction()
function(qt_webengine_configure_check_for_ulimit)
message(STATUS "Checking 'ulimit -n'")
execute_process(COMMAND bash -c "ulimit -n"
OUTPUT_VARIABLE ulimit_output
)
string(REGEX MATCHALL "[0-9]+" limit "${ulimit_output}")
message(STATUS "Open files limit ${limit}")
if(NOT (QT_FEATURE_use_gold_linker OR QT_FEATURE_use_lld_linker) AND ulimit_output LESS 4096)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.21.0")
message(STATUS "Creating linker launcher")
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/linker_ulimit.sh
CONTENT "#!/bin/bash\nulimit -n 4096\nexec \"$@\""
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
)
set(COIN_BUG_699 ON PARENT_SCOPE)
else()
set(PRINT_BFD_LINKER_WARNING ON PARENT_SCOPE)
endif()
endif()
endfunction()
# Configures multi/matrix build
function(qt_webengine_add_build feature value)
list(APPEND cmake_args
"-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DMATRIX_SUBBUILD=ON"
"-DFEATURE_${feature}=${value}"
)
if(CMAKE_C_COMPILER_LAUNCHER)
list(APPEND cmake_args "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}")
endif()
if(CMAKE_CXX_COMPILER_LAUNCHER)
list(APPEND cmake_args "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}")
endif()
externalproject_add(${feature}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${feature}-${value}
PREFIX ${feature}-${value}
CMAKE_ARGS ${cmake_args}
USES_TERMINAL_BUILD ON
USES_TERMINAL_CONFIGURE ON
BUILD_ALWAYS TRUE
INSTALL_COMMAND ""
)
get_property(dep_tracker GLOBAL PROPERTY MATRIX_DEPENDENCY_TRACKER)
foreach(dep ${dep_tracker})
add_dependencies(${feature} ${dep})
endforeach()
set(dep_tracker "${dep_tracker}" ${feature})
set_property(GLOBAL PROPERTY MATRIX_DEPENDENCY_TRACKER "${dep_tracker}")
endfunction()
function(qt_webengine_is_file_inside_root_build_dir out_var file)
set(result ON)
if(NOT QT_CONFIGURE_RUNNING)
file(RELATIVE_PATH relpath "${WEBENGINE_ROOT_BUILD_DIR}" "${file}")
if(IS_ABSOLUTE "${relpath}" OR relpath MATCHES "^\\.\\./")
set(result OFF)
endif()
endif()
set(${out_var} ${result} PARENT_SCOPE)
endfunction()
function(qt_webengine_get_windows_sdk_version result_sdk_full result_sdk_minor)
set(windows_sdk_version $ENV{WindowsSDKVersion})
string(REGEX REPLACE "([0-9.]+).*" "\\1" windows_sdk_version "${windows_sdk_version}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" sdk_minor "${windows_sdk_version}")
set(${result_sdk_full} "${windows_sdk_version}" PARENT_SCOPE)
set(${result_sdk_minor} "${sdk_minor}" PARENT_SCOPE)
endfunction()
function(qt_webengine_configure_check_coin white_list_file webengine_check pdf_check)
if("${webengine_check}" STREQUAL "" OR "${pdf_check}" STREQUAL "")
return()
endif()
set(coin_id $ENV{COIN_PLATFORM_ID})
if(coin_id)
set(res OFF)
file(READ ${white_list_file} white_list)
string(REPLACE "\n" ";" white_list "${white_list}")
foreach(line IN LISTS white_list)
string(REPLACE " " ";" line "${line}")
list(REMOVE_ITEM line "")
if(NOT line)
continue()
endif()
list(POP_FRONT line id)
if(id MATCHES "^#") # skip comments
continue()
endif()
if(id)
set(${id} ${line})
endif()
endforeach()
if(DEFINED ${coin_id})
list(POP_FRONT ${coin_id} webengine_build)
list(POP_FRONT ${coin_id} pdf_build)
set(res ON)
if(webengine_build AND NOT webengine_check)
set(res OFF)
endif()
if(pdf_build AND NOT pdf_check)
set(res OFF)
endif()
else()
message(WARNING "Undefined coin sanity check for ${coin_id} platform")
return()
endif()
if(NOT res)
message(FATAL_ERROR "!!! Coin sanity check failed for ${coin_id} platform with:
(qtwebegine=${QT_CONFIGURE_CHECK_qtwebengine_build} qtpdf=${QT_CONFIGURE_CHECK_qtpdf_build}), but expected: (qtwebengine=${webengine_build} qtpdf=${pdf_build})")
endif()
endif()
endfunction()
|