2022-07-05 11:26:52 +00:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-08-19 13:21:34 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2022-07-05 11:26:52 +00:00
|
|
|
|
2022-08-15 16:29:41 +00:00
|
|
|
function(qt_internal_write_depends_file target)
|
|
|
|
get_target_property(module_depends_header ${target} _qt_module_depends_header)
|
|
|
|
set(outfile "${module_depends_header}")
|
2021-07-30 11:16:10 +00:00
|
|
|
set(contents "/* This file was generated by cmake with the info from ${target} target. */\n")
|
2020-08-14 08:24:57 +00:00
|
|
|
string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n")
|
|
|
|
foreach (m ${ARGN})
|
2021-04-06 16:57:11 +00:00
|
|
|
string(APPEND contents "# include <${m}/${m}>\n")
|
2020-08-14 08:24:57 +00:00
|
|
|
endforeach()
|
|
|
|
string(APPEND contents "#endif\n")
|
|
|
|
|
|
|
|
file(GENERATE OUTPUT "${outfile}" CONTENT "${contents}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
macro(qt_collect_third_party_deps target)
|
|
|
|
set(_target_is_static OFF)
|
|
|
|
get_target_property(_target_type ${target} TYPE)
|
|
|
|
if (${_target_type} STREQUAL "STATIC_LIBRARY")
|
|
|
|
set(_target_is_static ON)
|
|
|
|
endif()
|
|
|
|
unset(_target_type)
|
|
|
|
# If we are doing a non-static Qt build, we only want to propagate public dependencies.
|
|
|
|
# If we are doing a static Qt build, we need to propagate all dependencies.
|
|
|
|
set(depends_var "public_depends")
|
|
|
|
if(_target_is_static)
|
|
|
|
set(depends_var "depends")
|
|
|
|
endif()
|
|
|
|
unset(_target_is_static)
|
|
|
|
|
2025-01-03 16:22:45 +00:00
|
|
|
foreach(dep ${${depends_var}} ${extra_third_party_deps})
|
2020-08-14 08:24:57 +00:00
|
|
|
# Gather third party packages that should be found when using the Qt module.
|
|
|
|
# Also handle nolink target dependencies.
|
|
|
|
string(REGEX REPLACE "_nolink$" "" base_dep "${dep}")
|
|
|
|
if(NOT base_dep STREQUAL dep)
|
|
|
|
# Resets target name like Vulkan_nolink to Vulkan, because we need to call
|
|
|
|
# find_package(Vulkan).
|
|
|
|
set(dep ${base_dep})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Strip any directory scope tokens.
|
2021-04-29 10:47:52 +00:00
|
|
|
__qt_internal_strip_target_directory_scope_token("${dep}" dep)
|
2020-08-14 08:24:57 +00:00
|
|
|
if(TARGET ${dep})
|
|
|
|
list(FIND third_party_deps_seen ${dep} dep_seen)
|
|
|
|
|
|
|
|
get_target_property(package_name ${dep} INTERFACE_QT_PACKAGE_NAME)
|
|
|
|
if(dep_seen EQUAL -1 AND package_name)
|
|
|
|
list(APPEND third_party_deps_seen ${dep})
|
2020-09-14 07:37:03 +00:00
|
|
|
get_target_property(package_is_optional ${dep} INTERFACE_QT_PACKAGE_IS_OPTIONAL)
|
2020-08-14 08:24:57 +00:00
|
|
|
get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
|
|
|
|
if(NOT package_version)
|
|
|
|
set(package_version "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(package_components ${dep} INTERFACE_QT_PACKAGE_COMPONENTS)
|
|
|
|
if(NOT package_components)
|
|
|
|
set(package_components "")
|
|
|
|
endif()
|
|
|
|
|
2021-06-17 10:04:16 +00:00
|
|
|
get_target_property(package_optional_components ${dep}
|
|
|
|
INTERFACE_QT_PACKAGE_OPTIONAL_COMPONENTS)
|
|
|
|
if(NOT package_optional_components)
|
|
|
|
set(package_optional_components "")
|
|
|
|
endif()
|
|
|
|
|
2024-03-07 17:02:56 +00:00
|
|
|
get_target_property(package_components_id ${dep} _qt_package_components_id)
|
|
|
|
if(package_components_id)
|
|
|
|
list(APPEND third_party_deps_package_components_ids ${package_components_id})
|
|
|
|
endif()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
list(APPEND third_party_deps
|
2021-06-17 10:04:16 +00:00
|
|
|
"${package_name}\;${package_is_optional}\;${package_version}\;${package_components}\;${package_optional_components}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
2024-03-07 17:02:56 +00:00
|
|
|
# Collect provided targets for the given list of package component ids.
|
|
|
|
#
|
|
|
|
# ${target} is merely used as a key infix to avoid name clashes in the Dependencies.cmake files.
|
|
|
|
# package_component_ids is a list of '${package_name}-${components}-${optional_components}' keys
|
|
|
|
# that are sanitized not to contain spaces or semicolons.
|
|
|
|
#
|
|
|
|
# The output is a list of variable assignments to add to the dependencies file.
|
|
|
|
# Each variable assignment is the list of provided targets for a given package component id.
|
|
|
|
#
|
|
|
|
# We use these extra assignments instead of adding the info to the existing 'third_party_deps' list
|
|
|
|
# to make the information more readable. That list already has 5 items per package, making it
|
|
|
|
# quite hard to read.
|
|
|
|
function(qt_internal_collect_third_party_dep_packages_info
|
|
|
|
target
|
|
|
|
package_components_ids
|
|
|
|
out_packages_info)
|
|
|
|
|
|
|
|
# There might be multiple calls to find the same package, so remove the duplicates.
|
|
|
|
list(REMOVE_DUPLICATES package_components_ids)
|
|
|
|
|
|
|
|
set(packages_info "")
|
|
|
|
|
|
|
|
foreach(package_key IN LISTS package_components_ids)
|
|
|
|
get_cmake_property(provided_targets _qt_find_package_${package_key}_provided_targets)
|
|
|
|
if(provided_targets)
|
|
|
|
set(key "__qt_${target}_third_party_package_${package_key}_provided_targets")
|
|
|
|
string(APPEND packages_info "set(${key} \"${provided_targets}\")\n")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(${out_packages_info} "${packages_info}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2021-04-06 16:57:11 +00:00
|
|
|
# Filter the dependency targets to collect unique set of the dependencies.
|
|
|
|
# non-Private and Private targets are treated as the single object in this context
|
|
|
|
# since they are defined by the same CMake package. For internal modules
|
|
|
|
# the CMake package will be always Private.
|
|
|
|
function(qt_internal_remove_qt_dependency_duplicates out_deps deps)
|
|
|
|
set(${out_deps} "")
|
|
|
|
foreach(dep ${deps})
|
|
|
|
if(dep)
|
|
|
|
list(FIND ${out_deps} "${dep}" dep_seen)
|
|
|
|
|
|
|
|
if(dep_seen EQUAL -1)
|
|
|
|
list(LENGTH dep len)
|
|
|
|
if(NOT (len EQUAL 2))
|
|
|
|
message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
|
|
|
|
endif()
|
|
|
|
list(GET dep 0 dep_name)
|
|
|
|
list(GET dep 1 dep_ver)
|
|
|
|
|
|
|
|
# Skip over Qt6 dependency, because we will manually handle it in the Dependencies
|
|
|
|
# file before everything else, to ensure that find_package(Qt6Core)-style works.
|
|
|
|
if(dep_name STREQUAL "${INSTALL_CMAKE_NAMESPACE}")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
list(APPEND ${out_deps} "${dep_name}\;${dep_ver}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(${out_deps} "${${out_deps}}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
function(qt_internal_create_module_depends_file target)
|
2024-12-09 20:14:50 +00:00
|
|
|
set(no_value_options "")
|
|
|
|
set(single_value_options "")
|
2025-01-06 10:15:12 +00:00
|
|
|
set(multi_value_options "")
|
2024-12-09 20:14:50 +00:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 1 arg
|
|
|
|
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
|
|
|
|
)
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
get_target_property(target_type "${target}" TYPE)
|
2022-08-10 14:25:19 +00:00
|
|
|
set(is_interface_lib FALSE)
|
2020-08-14 08:24:57 +00:00
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
2022-08-10 14:25:19 +00:00
|
|
|
set(is_interface_lib TRUE)
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(depends "")
|
2022-08-10 14:25:19 +00:00
|
|
|
if(target_type STREQUAL "STATIC_LIBRARY")
|
2020-08-14 08:24:57 +00:00
|
|
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
|
|
|
|
|
|
|
# Used for collecting Qt module dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
|
|
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
|
|
|
set(target_deps_seen "")
|
|
|
|
set(qt_module_dependencies "")
|
|
|
|
|
2022-08-10 14:25:19 +00:00
|
|
|
if(NOT is_interface_lib)
|
2025-01-07 16:51:30 +00:00
|
|
|
# TODO: deprecated code path. QT_EXTRA_PACKAGE_DEPENDENCIES shouldn't be used for the Qt
|
|
|
|
# packages.
|
2020-08-14 08:24:57 +00:00
|
|
|
get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
|
|
|
|
endif()
|
2025-01-07 16:51:30 +00:00
|
|
|
|
2021-04-06 16:57:11 +00:00
|
|
|
if(NOT extra_depends MATCHES "-NOTFOUND$")
|
2020-08-14 08:24:57 +00:00
|
|
|
list(APPEND target_deps "${extra_depends}")
|
|
|
|
endif()
|
|
|
|
|
2021-07-27 11:54:56 +00:00
|
|
|
# Extra 3rd party targets who's packages should be considered dependencies.
|
|
|
|
get_target_property(extra_third_party_deps "${target}" _qt_extra_third_party_dep_targets)
|
|
|
|
if(NOT extra_third_party_deps)
|
|
|
|
set(extra_third_party_deps "")
|
|
|
|
endif()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
# Used for assembling the content of an include/Module/ModuleDepends.h header.
|
|
|
|
set(qtdeps "")
|
|
|
|
|
|
|
|
# Used for collecting third party dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
|
|
|
set(third_party_deps "")
|
|
|
|
set(third_party_deps_seen "")
|
2024-03-07 17:02:56 +00:00
|
|
|
set(third_party_deps_package_components_ids "")
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
# Used for collecting Qt tool dependencies that should be find_package()'d in
|
|
|
|
# ModuleToolsDependencies.cmake.
|
|
|
|
set(tool_deps "")
|
|
|
|
set(tool_deps_seen "")
|
|
|
|
|
|
|
|
# Used for collecting Qt tool dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
|
|
|
set(main_module_tool_deps "")
|
|
|
|
|
2020-09-10 16:43:09 +00:00
|
|
|
# Extra QtFooModuleTools packages to be added as dependencies to
|
|
|
|
# QtModuleDependencies.cmake. Needed for QtWaylandCompositor / QtWaylandClient.
|
2022-08-10 14:25:19 +00:00
|
|
|
if(NOT is_interface_lib)
|
2020-09-10 16:43:09 +00:00
|
|
|
get_target_property(extra_tools_package_dependencies "${target}"
|
|
|
|
QT_EXTRA_TOOLS_PACKAGE_DEPENDENCIES)
|
|
|
|
if(extra_tools_package_dependencies)
|
|
|
|
list(APPEND main_module_tool_deps "${extra_tools_package_dependencies}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
qt_internal_get_qt_all_known_modules(known_modules)
|
|
|
|
|
|
|
|
set(all_depends ${depends} ${public_depends})
|
|
|
|
foreach (dep ${all_depends})
|
|
|
|
# Normalize module by stripping leading "Qt::" and trailing "Private"
|
2020-11-12 10:39:02 +00:00
|
|
|
if (dep MATCHES "(Qt|${QT_CMAKE_EXPORT_NAMESPACE})::([-_A-Za-z0-9]+)")
|
2020-11-10 14:15:09 +00:00
|
|
|
set(dep "${CMAKE_MATCH_2}")
|
2022-02-22 15:57:00 +00:00
|
|
|
set(real_dep_target "Qt::${dep}")
|
|
|
|
|
|
|
|
if(TARGET "${real_dep_target}")
|
|
|
|
get_target_property(is_versionless_target "${real_dep_target}"
|
|
|
|
_qt_is_versionless_target)
|
|
|
|
if(is_versionless_target)
|
|
|
|
set(real_dep_target "${QT_CMAKE_EXPORT_NAMESPACE}::${dep}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(skip_module_depends_include "${real_dep_target}"
|
|
|
|
_qt_module_skip_depends_include)
|
|
|
|
if(skip_module_depends_include)
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(module_has_headers "${real_dep_target}"
|
|
|
|
_qt_module_has_headers)
|
|
|
|
if(NOT module_has_headers)
|
|
|
|
continue()
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(FIND known_modules "${dep}" _pos)
|
|
|
|
if (_pos GREATER -1)
|
2021-04-06 16:57:11 +00:00
|
|
|
qt_internal_module_info(module ${QT_CMAKE_EXPORT_NAMESPACE}::${dep})
|
|
|
|
list(APPEND qtdeps ${module})
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
# Make the ModuleTool package depend on dep's ModuleTool package.
|
|
|
|
list(FIND tool_deps_seen ${dep} dep_seen)
|
|
|
|
if(dep_seen EQUAL -1 AND ${dep} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
qt_internal_get_package_version_of_target("${dep}" dep_package_version)
|
2020-08-14 08:24:57 +00:00
|
|
|
list(APPEND tool_deps_seen ${dep})
|
|
|
|
list(APPEND tool_deps
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
"${INSTALL_CMAKE_NAMESPACE}${dep}Tools\;${dep_package_version}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
qt_collect_third_party_deps(${target})
|
2024-03-07 17:02:56 +00:00
|
|
|
qt_internal_collect_third_party_dep_packages_info(${target}
|
|
|
|
"${third_party_deps_package_components_ids}"
|
|
|
|
packages_info)
|
|
|
|
|
|
|
|
set(third_party_deps_extra_info "")
|
|
|
|
if(packages_info)
|
|
|
|
string(APPEND third_party_deps_extra_info "${packages_info}")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
# Add dependency to the main ModuleTool package to ModuleDependencies file.
|
|
|
|
if(${target} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
qt_internal_get_package_version_of_target("${target}" main_module_tool_package_version)
|
2020-09-10 16:43:09 +00:00
|
|
|
list(APPEND main_module_tool_deps
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
"${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${main_module_tool_package_version}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(dep ${target_deps})
|
2021-04-06 16:57:11 +00:00
|
|
|
if(NOT dep MATCHES ".+Private$" AND
|
|
|
|
dep MATCHES "${INSTALL_CMAKE_NAMESPACE}(.+)")
|
2022-06-10 14:41:59 +00:00
|
|
|
# target_deps contains elements that are a pair of target name and version,
|
2021-08-18 17:26:08 +00:00
|
|
|
# e.g. 'Core\;6.2'
|
|
|
|
# After the extracting from the target_deps list, the element becomes a list itself,
|
|
|
|
# because it loses escape symbol before the semicolon, so ${CMAKE_MATCH_1} is the list:
|
|
|
|
# Core;6.2.
|
|
|
|
# We need to store only the target name in the qt_module_dependencies variable.
|
|
|
|
list(GET CMAKE_MATCH_1 0 dep_name)
|
|
|
|
if(dep_name)
|
|
|
|
list(APPEND qt_module_dependencies "${dep_name}")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2021-04-06 16:57:11 +00:00
|
|
|
list(REMOVE_DUPLICATES qt_module_dependencies)
|
|
|
|
|
|
|
|
qt_internal_remove_qt_dependency_duplicates(target_deps "${target_deps}")
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
if (DEFINED qtdeps)
|
|
|
|
list(REMOVE_DUPLICATES qtdeps)
|
|
|
|
endif()
|
|
|
|
|
2021-07-30 09:41:47 +00:00
|
|
|
get_target_property(hasModuleHeaders "${target}" _qt_module_has_headers)
|
2020-08-14 08:24:57 +00:00
|
|
|
if (${hasModuleHeaders})
|
2022-08-15 16:29:41 +00:00
|
|
|
qt_internal_write_depends_file(${target} ${qtdeps})
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(third_party_deps OR main_module_tool_deps OR target_deps)
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
|
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
|
|
|
|
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
# All module packages should look for the Qt6 package version that qtbase was originally
|
|
|
|
# built as.
|
|
|
|
qt_internal_get_package_version_of_target(Platform main_qt_package_version)
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
# Configure and install ModuleDependencies file.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
message(TRACE "Recorded dependencies for module: ${target}\n"
|
|
|
|
" Qt dependencies: ${target_deps}\n"
|
|
|
|
" 3rd-party dependencies: ${third_party_deps}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
if(tool_deps)
|
|
|
|
# The value of the property will be used by qt_export_tools.
|
|
|
|
set_property(TARGET "${target}" PROPERTY _qt_tools_package_deps "${tool_deps}")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_create_plugin_depends_file target)
|
|
|
|
get_target_property(plugin_install_package_suffix "${target}" _qt_plugin_install_package_suffix)
|
|
|
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
|
|
|
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
|
|
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
|
|
|
set(target_deps_seen "")
|
|
|
|
|
2022-07-08 09:20:18 +00:00
|
|
|
|
|
|
|
# Extra 3rd party targets who's packages should be considered dependencies.
|
|
|
|
get_target_property(extra_third_party_deps "${target}" _qt_extra_third_party_dep_targets)
|
|
|
|
if(NOT extra_third_party_deps)
|
|
|
|
set(extra_third_party_deps "")
|
|
|
|
endif()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
qt_collect_third_party_deps(${target})
|
|
|
|
|
2021-04-06 16:57:11 +00:00
|
|
|
qt_internal_remove_qt_dependency_duplicates(target_deps "${target_deps}")
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
if(third_party_deps OR target_deps)
|
|
|
|
# Setup build and install paths
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
|
|
|
|
# Plugins should look for their dependencies in their associated module package folder as
|
|
|
|
# well as the Qt6 package folder which is stored by the Qt6 package in _qt_cmake_dir.
|
|
|
|
set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/..;\${_qt_cmake_dir}")
|
2020-08-14 08:24:57 +00:00
|
|
|
if(plugin_install_package_suffix)
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${plugin_install_package_suffix}")
|
|
|
|
if(plugin_install_package_suffix MATCHES "/QmlPlugins")
|
|
|
|
# Qml plugins are one folder deeper.
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/../..;\${_qt_cmake_dir}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
else()
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
|
|
|
|
|
|
|
|
# Configure and install ModuleDependencies file.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtPluginDependencies.cmake.in"
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
|
|
|
|
message(TRACE "Recorded dependencies for plugin: ${target}\n"
|
|
|
|
" Qt dependencies: ${target_deps}\n"
|
|
|
|
" 3rd-party dependencies: ${third_party_deps}")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_create_qt6_dependencies_file)
|
|
|
|
# This is used for substitution in the configured file.
|
|
|
|
set(target "${INSTALL_CMAKE_NAMESPACE}")
|
|
|
|
|
|
|
|
# This is the actual target we're querying.
|
|
|
|
set(actual_target Platform)
|
|
|
|
get_target_property(public_depends "${actual_target}" INTERFACE_LINK_LIBRARIES)
|
2020-09-24 10:02:44 +00:00
|
|
|
unset(depends)
|
2020-08-14 08:24:57 +00:00
|
|
|
|
2024-07-01 17:10:26 +00:00
|
|
|
set(third_party_deps "")
|
|
|
|
set(third_party_deps_seen "")
|
|
|
|
set(third_party_deps_package_components_ids "")
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
# We need to collect third party deps that are set on the public Platform target,
|
|
|
|
# like Threads::Threads.
|
|
|
|
# This mimics find_package part of the CONFIG += thread assignment in mkspecs/features/qt.prf.
|
|
|
|
qt_collect_third_party_deps(${actual_target})
|
2024-07-01 17:10:26 +00:00
|
|
|
qt_internal_collect_third_party_dep_packages_info("${INSTALL_CMAKE_NAMESPACE}"
|
|
|
|
"${third_party_deps_package_components_ids}"
|
|
|
|
packages_info)
|
|
|
|
|
|
|
|
set(third_party_deps_extra_info "")
|
|
|
|
if(packages_info)
|
|
|
|
string(APPEND third_party_deps_extra_info "${packages_info}")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
# For Threads we also need to write an extra variable assignment.
|
|
|
|
set(third_party_extra "")
|
|
|
|
if(third_party_deps MATCHES "Threads")
|
|
|
|
string(APPEND third_party_extra "if(NOT QT_NO_THREADS_PREFER_PTHREAD_FLAG)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
|
|
|
endif()")
|
|
|
|
endif()
|
|
|
|
|
2022-07-18 12:14:41 +00:00
|
|
|
_qt_internal_determine_if_host_info_package_needed(platform_requires_host_info_package)
|
|
|
|
|
2022-07-18 14:09:30 +00:00
|
|
|
if(platform_requires_host_info_package)
|
|
|
|
# TODO: Figure out how to make the initial QT_HOST_PATH var relocatable in relation
|
|
|
|
# to the target CMAKE_INSTALL_DIR, if at all possible to do so in a reliable way.
|
|
|
|
get_filename_component(qt_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
|
|
|
|
get_filename_component(qt_host_path_cmake_dir_absolute
|
2025-03-17 16:54:32 +00:00
|
|
|
"${${INSTALL_CMAKE_NAMESPACE}HostInfo_DIR}/.." ABSOLUTE)
|
2022-07-18 14:09:30 +00:00
|
|
|
endif()
|
|
|
|
|
2022-07-18 12:14:41 +00:00
|
|
|
if(third_party_deps OR platform_requires_host_info_package)
|
2020-08-14 08:24:57 +00:00
|
|
|
# Setup build and install paths.
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}")
|
|
|
|
|
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
|
|
|
|
|
|
|
|
# Configure and install QtDependencies file.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtConfigDependencies.cmake.in"
|
|
|
|
"${config_build_dir}/${target}Dependencies.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${target}Dependencies.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Create Depends.cmake & Depends.h files for all modules and plug-ins.
|
|
|
|
function(qt_internal_create_depends_files)
|
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
|
|
|
|
if(PROJECT_NAME STREQUAL "QtBase")
|
|
|
|
qt_internal_create_qt6_dependencies_file()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach (target ${repo_known_modules})
|
|
|
|
qt_internal_create_module_depends_file(${target})
|
2024-12-09 20:14:50 +00:00
|
|
|
if(TARGET "${target}Private")
|
2025-01-06 10:15:12 +00:00
|
|
|
qt_internal_create_module_depends_file(${target}Private)
|
2024-12-09 20:14:50 +00:00
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach (target ${QT_KNOWN_PLUGINS})
|
|
|
|
qt_internal_create_plugin_depends_file(${target})
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2022-07-01 12:45:54 +00:00
|
|
|
# This function creates Qt<Module>Plugins.cmake files used to include all
|
|
|
|
# the plugin Config files that belong to that module.
|
|
|
|
function(qt_internal_create_plugins_auto_inclusion_files)
|
|
|
|
# For static library builds, the plugin targets need to be available for linking.
|
|
|
|
# For shared library builds, the plugin targets are useful for deployment purposes.
|
2020-08-14 08:24:57 +00:00
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
|
2022-07-01 13:00:50 +00:00
|
|
|
set(modules_with_plugins "")
|
2020-08-14 08:24:57 +00:00
|
|
|
foreach (QT_MODULE ${repo_known_modules})
|
|
|
|
get_target_property(target_type "${QT_MODULE}" TYPE)
|
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
# No plugins are provided by a header only module.
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
|
|
|
|
set(QT_MODULE_PLUGIN_INCLUDES "")
|
|
|
|
|
|
|
|
if(QT_MODULE STREQUAL "Qml")
|
|
|
|
set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}
|
2025-01-23 17:23:24 +00:00
|
|
|
__qt_internal_include_qml_plugin_packages()
|
|
|
|
")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
2024-01-30 12:03:06 +00:00
|
|
|
get_target_property(module_plugin_types "${QT_MODULE}" MODULE_PLUGIN_TYPES)
|
|
|
|
if(module_plugin_types OR QT_MODULE_PLUGIN_INCLUDES)
|
2022-07-01 13:00:50 +00:00
|
|
|
list(APPEND modules_with_plugins "${QT_MODULE}")
|
2020-08-14 08:24:57 +00:00
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtPlugins.cmake.in"
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2022-07-01 13:00:50 +00:00
|
|
|
if(modules_with_plugins)
|
|
|
|
message(STATUS "Generated QtModulePlugins.cmake files for the following modules:"
|
|
|
|
" ${modules_with_plugins}")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_generate_install_prefixes out_var)
|
|
|
|
set(content "\n")
|
|
|
|
set(vars INSTALL_BINDIR INSTALL_INCLUDEDIR INSTALL_LIBDIR INSTALL_MKSPECSDIR INSTALL_ARCHDATADIR
|
|
|
|
INSTALL_PLUGINSDIR INSTALL_LIBEXECDIR INSTALL_QMLDIR INSTALL_DATADIR INSTALL_DOCDIR
|
|
|
|
INSTALL_TRANSLATIONSDIR INSTALL_SYSCONFDIR INSTALL_EXAMPLESDIR INSTALL_TESTSDIR
|
CMake: Generate an SPDX v2.3 SBOM file for each built repository
This change adds a new -sbom configure option to allow generating and
installing an SPDX v2.3 SBOM file when building a qt repo.
The -sbom-dir option can be used to configure the location where
each repo sbom file will be installed.
By default it is installed into
$prefix/$archdatadir/sbom/$sbom_lower_project_name.sdpx
which is basically ~/Qt/sbom/qtbase-6.8.0.spdx
The file is installed as part of the default installation rules, but
it can also be installed manually using the "sbom" installation
component, or "sbom_$lower_project_name" in a top-level build. For
example: cmake install . --component sbom_qtbase
CMake 3.19+ is needed to read the qt_attribution.json files for
copyrights, license info, etc. When using an older cmake version,
configuration will error out. It is possible to opt into using an
older cmake version, but the generated sbom will lack all the
attribution file information.
Using an older cmake version is untested and not officially supported.
Implementation notes.
The bulk of the implementation is split into 4 new files:
- QtPublicSbomHelpers.cmake - for Qt-specific collecting, processing
and dispatching the generation of various pieces of the SBOM document
e.g. a SDPX package associated with a target like Core, a SDPX
file entry for each target binary file (per-config shared library,
archive, executable, etc)
- QtPublicSbomGenerationHelpers.cmake - for non-Qt specific
implementation of SPDX generation. This also has some code that was
taken from the cmake-sbom 3rd party project, so it is dual licensed
under the usual Qt build system BSD license, as well as the MIT
license of the 3rd party project
- QtPublicGitHelpers.cmake - for git related features, mainly to embed
queried hashes or tags into version strings, is dual-licensed for
the same reasons as QtPublicSbomGenerationHelpers.cmake
- QtSbomHelpers.cmake - Qt-specific functions that just forward
arguments to the public functions. These are meant to be used in our
Qt CMakeLists.txt instead of the public _qt_internal_add_sbom ones
for naming consistency. These function would mostly be used to
annotate 3rd party libraries with sbom info and to add sbom info
for unusual target setups (like the Bootstrap library), because most
of the handling is already done automatically via
qt_internal_add_module/plugin/etc.
The files are put into Public cmake files, with the future hope of
making this available to user projects in some capacity.
The distinction of Qt-specific and non-Qt specific code might blur a
bit, and thus the separation across files might not always be
consistent, but it was best effort.
The main purpose of the code is to collect various information about
targets and their relationships and generate equivalent SPDX info.
Collection is currently done for the following targets: Qt modules,
plugins, apps, tools, system libraries, bundled 3rd party libraries
and partial 3rd party sources compiled directly as part of Qt targets.
Each target has an equivalent SPDX package generated with information
like version, license, copyright, CPE (common vulnerability
identifier), files that belong to the package, and relationships on
other SPDX packages (associated cmake targets), mostly gathered from
direct linking dependencies.
Each package might also contain files, e.g. libQt6Core.so for the Core
target. Each file also has info like license id, copyrights, but also
the list of source files that were used to generate the file and a
sha1 checksum.
SPDX documents can also refer to packages in other SPDX documents, and
those are referred to via external document references. This is the
case when building qtdeclarative and we refer to Core.
For qt provided targets, we have complete information regarding
licenses, and copyrights.
For bundled 3rd party libraries, we should also have most information,
which is usually parsed from the
src/3rdparty/libfoo/qt_attribution.json files.
If there are multiple attribution files, or if the files have multiple
entries, we create a separate SBOM package for each of those entries,
because each might have a separate copyright or version, and an sbom
package can have only one version (although many copyrights).
For system libraries we usually lack the information because we don't
have attribution files for Find scripts. So the info needs to be
manually annotated via arguments to the sbom function calls, or the
FindFoo.cmake scripts expose that information in some form and we
can query it.
There are also corner cases like 3rdparty sources being directly
included in a Qt library, like the m4dc files for Gui, or PCRE2 for
Bootstrap.
Or QtWebEngine libraries (either Qt bundled or Chromium bundled or
system libraries) which get linked in by GN instead of CMake, so there
are no direct targets for them.
The information for these need to be annotated manually as well.
There is also a distinction to be made for static Qt builds (or any
static Qt library in a shared build), where the system libraries found
during the Qt build might not be the same that are linked into the
final user application or library.
The actual generation of the SBOM is done by file(GENERATE)-ing one
.cmake file for each target, file, external ref, etc, which will be
included in a top-level cmake script.
The top-level cmake script will run through each included file, to
append to a "staging" spdx file, which will then be used in a
configure_file() call to replace some final
variables, like embedding a file checksum.
There are install rules to generate a complete SBOM during
installation, and an optional 'sbom' custom target that allows
building an incomplete SBOM during the build step.
The build target is just for convenience and faster development
iteration time. It is incomplete because it is missing the installed
file SHA1 checksums and the document verification code (the sha1 of
all sha1s). We can't compute those during the build before the files
are actually installed.
A complete SBOM can only be achieved at installation time. The install
script will include all the generated helper files, but also set some
additional variables to ensure checksumming happens, and also handle
multi-config installation, among other small things.
For multi-config builds, CMake doesn't offer a way to run code after
all configs are installed, because they might not always be installed,
someone might choose to install just Release.
To handle that, we rely on ninja installing each config sequentially
(because ninja places the install rules into the 'console' pool which
runs one task at a time).
For each installed config we create a config-specific marker file.
Once all marker files are present, whichever config ends up being
installed as the last one, we run the sbom generation once, and then
delete all marker files.
There are a few internal variables that can be set during
configuration to enable various checks (and other features) on the
generated spdx files:
- QT_INTERNAL_SBOM_VERIFY
- QT_INTERNAL_SBOM_AUDIT
- QT_INTERNAL_SBOM_AUDIT_NO_ERROR
- QT_INTERNAL_SBOM_GENERATE_JSON
- QT_INTERNAL_SBOM_SHOW_TABLE
- QT_INTERNAL_SBOM_DEFAULT_CHECKS
These use 3rd party python tools, so they are not enabled by default.
If enabled, they run at installation time after the sbom is installed.
We will hopefully enable them in CI.
Overall, the code is still a bit messy in a few places, due to time
constraints, but can be improved later.
Some possible TODOs for the future:
- Do we need to handle 3rd party libs linked into a Qt static library
in a Qt shared build, where the Qt static lib is not installed, but
linked into a Qt shared library, somehow specially?
We can record a package for it, but we can't
create a spdx file record for it (and associated source
relationships) because we don't install the file, and spdx requires
the file to be installed and checksummed. Perhaps we can consider
adding some free-form text snippet to the package itself?
- Do we want to add parsing of .cpp source files for Copyrights, to
embed them into the packages? This will likely slow down
configuration quite a bit.
- Currently sbom info attached to WrapFoo packages in one repo is
not exported / available in other repos. E.g. If we annotate
WrapZLIB in qtbase with CPE_VENDOR zlib, this info will not be
available when looking up WrapZLIB in qtimageformats.
This is because they are IMPORTED libraries, and are not
exported. We might want to record this info in the future.
[ChangeLog][Build System] A new -sbom configure option can be used
to generate and install a SPDX SBOM (Software Bill of Materials) file
for each built Qt repository.
Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: I9c730a6bbc47e02ce1836fccf00a14ec8eb1a5f4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-03-07 17:02:56 +00:00
|
|
|
INSTALL_DESCRIPTIONSDIR INSTALL_SBOMDIR)
|
2025-01-21 13:33:59 +00:00
|
|
|
# INSTALL_PUBLICBINDIR is processed only if it is not empty
|
|
|
|
# See usage in qt_internal_generate_user_facing_tools_info
|
|
|
|
if(NOT "${INSTALL_PUBLICBINDIR}" STREQUAL "")
|
|
|
|
list(APPEND vars INSTALL_PUBLICBINDIR)
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
foreach(var ${vars})
|
|
|
|
get_property(docstring CACHE "${var}" PROPERTY HELPSTRING)
|
|
|
|
string(APPEND content "set(${var} \"${${var}}\" CACHE STRING \"${docstring}\" FORCE)\n")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(${out_var} "${content}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_wrap_string_in_if_multi_config content out_var)
|
|
|
|
set(${out_var} "
|
|
|
|
get_property(__qt_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
if(__qt_is_multi_config)
|
|
|
|
${content}endif()
|
|
|
|
unset(__qt_is_multi_config)\n" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_wrap_string_in_if_ninja_multi_config content out_var)
|
|
|
|
set(${out_var} "if(CMAKE_GENERATOR STREQUAL \"Ninja Multi-Config\")
|
|
|
|
${content}endif()\n" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_create_hostinfo_package)
|
|
|
|
set(package "${INSTALL_CMAKE_NAMESPACE}HostInfo")
|
|
|
|
qt_path_join(config_file_path "${QT_CONFIG_BUILD_DIR}/${package}/${package}Config.cmake")
|
|
|
|
qt_path_join(install_destination ${QT_CONFIG_INSTALL_DIR} ${package})
|
|
|
|
set(var_prefix "QT${PROJECT_VERSION_MAJOR}_HOST_INFO_")
|
|
|
|
configure_package_config_file(
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/QtHostInfoConfig.cmake.in"
|
|
|
|
"${config_file_path}"
|
|
|
|
INSTALL_DESTINATION "${install_destination}"
|
|
|
|
NO_SET_AND_CHECK_MACRO
|
|
|
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
|
|
|
qt_install(FILES "${config_file_path}" DESTINATION "${install_destination}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_generate_build_internals_extra_cmake_code)
|
|
|
|
if(PROJECT_NAME STREQUAL "QtBase")
|
|
|
|
qt_create_hostinfo_package()
|
|
|
|
|
|
|
|
foreach(var IN LISTS QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "set(${var} \"${${var}}\" CACHE INTERNAL \"\")\n")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(QT_SOURCE_TREE "${QtBase_SOURCE_DIR}")
|
|
|
|
qt_path_join(extra_file_path
|
|
|
|
${QT_CONFIG_BUILD_DIR}
|
|
|
|
${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2022-01-19 12:13:12 +00:00
|
|
|
"
|
CMake: Simplify default CMAKE_BUILD_TYPE logic
Previously we had four-ish locations where the CMAKE_BUILD_TYPE was
force set.
Twice in QtBuildInternalsExtra.cmake via
qt_internal_force_set_cmake_build_type_conditionally(), depending on
some conditions. This was executed right at
find_package(Qt6 COMPONENTS BuildInternals)
time.
And twice in qt_internal_set_default_build_type() via
qt_build_repo_begin() / qt_prepare_standalone_project() that goes
through QtSetup.cmake. This was executed only if the relevant functions
were called, rather than directly at find_package() time.
The exact logic of which build type ended up being set was very
confusing.
Refactor the code to decide the build type in one single location
when qt_build_repo_begin() / qt_prepare_standalone_project() are
called, rather than directly at find_package() time.
The actual logic when we override the build type depends on many
factors:
- when an explicit CMAKE_BUILD_TYPE is given, honor it, unless it's
a multi-config build
- when it's a multi-config build, don't set any CMAKE_BUILD_TYPE,
use the value of CMAKE_CONFIGURATION_TYPES
- when it's a qtbase build, compute a default unless an explicit value
was given
- the default is Debug if FEATURE_developer_build is ON
- otherwise the default is Release
- when it's a top-level build, only choose a build type for qtbase
- when it's another repo build, use the original build type unless
another was given explicitly (including in a top-level build)
- when it's a standalone tests build
- if qt is multi-config, the tests will be single config, due to
various CI failure reasons, this hasn't changed
- if qt is single config, use the original unless an explicit
value was given
- when it's a single standalone test build, use the original unless
an explicit value was given
To determine when an explicit CMAKE_BUILD_TYPE was given in contrast
to when it was default initialized, we now have one single function
that uses a few heuristics.
The heuristics are needed because we can't reliably determine an
explicitly given 'Debug' build on Windows, because CMake default
initializes to that.
The heuristics include:
- checking whether CMAKE_BUILD_TYPE_INIT is different from
CMAKE_BUILD_TYPE
- checking what the CMAKE_BUILD_TYPE was before the first project()
call when CMake default initializes
- we save the previous value in the qt.toolchain.cmake file
- also in QtAutoDetect during qtbase configuration
- also when building the sqldrivers project
- honoring the value of QT_NO_FORCE_SET_CMAKE_BUILD_TYPE
As a result of the above changes, the build type will be set exactly
zero or one times, for a particular build directory.
Note that the configure script also has some logic on which
CMAKE_BUILD_TYPE / CMAKE_CONFIGURATION_TYPES to pass to CMake
depending on whether -debug / -release / -debug-and-release /
-force-debug-info were passed. But once the values are passed,
CMake will honor them.
Amends 48841c34d2e86a741ec9992b9704c0fa5973503c
Amends 8c912cddebe544010e7da3f87af5b21f3328d7ec
Pick-to: 6.7
Task-number: QTBUG-114958
Task-number: QTBUG-120436
Change-Id: I30db14d1e8e9ff9bd2d7ea1d2256cdeb9493ca0d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-01-22 17:11:31 +00:00
|
|
|
# Used by qt_internal_set_cmake_build_type.
|
2022-01-19 12:13:12 +00:00
|
|
|
set(__qt_internal_initial_qt_cmake_build_type \"${CMAKE_BUILD_TYPE}\")
|
|
|
|
")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
|
|
string(APPEND multi_config_specific
|
|
|
|
" set(CMAKE_CONFIGURATION_TYPES \"${CMAKE_CONFIGURATION_TYPES}\" CACHE STRING \"\" FORCE)\n")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_TRY_COMPILE_CONFIGURATION)
|
|
|
|
string(APPEND multi_config_specific
|
|
|
|
" set(CMAKE_TRY_COMPILE_CONFIGURATION \"${CMAKE_TRY_COMPILE_CONFIGURATION}\")\n")
|
|
|
|
endif()
|
|
|
|
if(multi_config_specific)
|
|
|
|
qt_wrap_string_in_if_multi_config(
|
|
|
|
"${multi_config_specific}"
|
|
|
|
multi_config_specific)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${multi_config_specific}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(QT_MULTI_CONFIG_FIRST_CONFIG)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"\nset(QT_MULTI_CONFIG_FIRST_CONFIG \"${QT_MULTI_CONFIG_FIRST_CONFIG}\")\n")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_CROSS_CONFIGS)
|
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_CROSS_CONFIGS \"${CMAKE_CROSS_CONFIGS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_DEFAULT_BUILD_TYPE)
|
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_DEFAULT_BUILD_TYPE \"${CMAKE_DEFAULT_BUILD_TYPE}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_DEFAULT_CONFIGS)
|
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_DEFAULT_CONFIGS \"${CMAKE_DEFAULT_CONFIGS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(ninja_multi_config_specific)
|
|
|
|
qt_wrap_string_in_if_ninja_multi_config(
|
|
|
|
"${ninja_multi_config_specific}"
|
|
|
|
ninja_multi_config_specific)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${ninja_multi_config_specific}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED BUILD_WITH_PCH)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(BUILD_WITH_PCH \"${BUILD_WITH_PCH}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.
For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
or
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.
The first specified architecture is the one used to do all the
configure tests.
It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.
In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.
For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.
The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.
Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:
kernel: exec_mach_imgact: not running binary built against
preview arm64e ABI.
Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.
Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-24 15:03:35 +00:00
|
|
|
if(DEFINED QT_IS_MACOS_UNIVERSAL)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_IS_MACOS_UNIVERSAL \"${QT_IS_MACOS_UNIVERSAL}\" CACHE BOOL \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
2024-03-18 10:58:22 +00:00
|
|
|
if(DEFINED QT_APPLE_SDK)
|
2021-08-17 07:56:35 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2024-03-18 10:58:22 +00:00
|
|
|
"set(QT_APPLE_SDK \"${QT_APPLE_SDK}\" CACHE BOOL \"\")\n")
|
2021-08-17 07:56:35 +00:00
|
|
|
endif()
|
|
|
|
|
2022-01-10 18:12:32 +00:00
|
|
|
if(QT_FORCE_FIND_TOOLS)
|
2020-08-14 08:24:57 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2022-01-10 18:12:32 +00:00
|
|
|
"set(QT_FORCE_FIND_TOOLS \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(QT_FORCE_BUILD_TOOLS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_FORCE_BUILD_TOOLS \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()
|
|
|
|
|
2022-03-21 10:13:20 +00:00
|
|
|
if(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX)
|
|
|
|
file(TO_CMAKE_PATH
|
|
|
|
"${QT_INTERNAL_EXAMPLES_INSTALL_PREFIX}" examples_install_prefix)
|
2021-12-16 11:55:07 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2022-03-21 10:13:20 +00:00
|
|
|
"set(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX \"${examples_install_prefix}\" CACHE STRING \"\")\n")
|
2021-12-16 11:55:07 +00:00
|
|
|
endif()
|
|
|
|
|
2020-10-26 13:50:23 +00:00
|
|
|
# Save the default qpa platform.
|
|
|
|
if(DEFINED QT_QPA_DEFAULT_PLATFORM)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_QPA_DEFAULT_PLATFORM \"${QT_QPA_DEFAULT_PLATFORM}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
2024-04-11 08:55:53 +00:00
|
|
|
# Save the list of default qpa platforms.
|
|
|
|
# Used by qtwayland/src/plugins/platforms/qwayland-generic/CMakeLists.txt. Otherwise
|
|
|
|
# the DEFAULT_IF condition is evaluated incorrectly.
|
|
|
|
if(DEFINED QT_QPA_PLATFORMS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_QPA_PLATFORMS \"${QT_QPA_PLATFORMS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
2020-11-30 07:46:49 +00:00
|
|
|
# Save minimum and policy-related CMake versions to ensure the same minimum is
|
2021-07-22 14:23:51 +00:00
|
|
|
# checked for when building other downstream repos (qtsvg, etc) and the policy settings
|
|
|
|
# will be consistent unless the downstream repos explicitly override them.
|
|
|
|
# Policy settings can be overridden per-repo, but the minimum CMake version is global for all of
|
|
|
|
# Qt.
|
|
|
|
qt_internal_get_supported_min_cmake_version_for_building_qt(
|
|
|
|
supported_min_version_for_building_qt)
|
|
|
|
qt_internal_get_computed_min_cmake_version_for_building_qt(
|
|
|
|
computed_min_version_for_building_qt)
|
|
|
|
qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
|
|
|
|
qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
|
2020-10-30 16:42:34 +00:00
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
# Rpath related things that need to be re-used when building other repos.
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_RPATH}\" CACHE STRING \"\")\n")
|
|
|
|
if(DEFINED QT_DISABLE_RPATH)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_DISABLE_RPATH \"${QT_DISABLE_RPATH}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2020-08-13 12:36:50 +00:00
|
|
|
if(DEFINED QT_EXTRA_DEFINES)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_DEFINES \"${QT_EXTRA_DEFINES}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(DEFINED QT_EXTRA_INCLUDEPATHS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_INCLUDEPATHS \"${QT_EXTRA_INCLUDEPATHS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(DEFINED QT_EXTRA_FRAMEWORKPATHS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_FRAMEWORKPATHS \"${QT_EXTRA_FRAMEWORKPATHS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(DEFINED QT_EXTRA_LIBDIRS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_LIBDIRS \"${QT_EXTRA_LIBDIRS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
if(DEFINED QT_EXTRA_RPATHS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_RPATHS \"${QT_EXTRA_RPATHS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2022-08-16 11:02:27 +00:00
|
|
|
if(DEFINED QT_DISABLE_DEPRECATED_UP_TO)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_DISABLE_DEPRECATED_UP_TO \"${QT_DISABLE_DEPRECATED_UP_TO}\""
|
|
|
|
" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2020-08-14 08:24:57 +00:00
|
|
|
|
|
|
|
# Save pkg-config feature value to be able to query it internally as soon as BuildInternals
|
|
|
|
# package is loaded. This is to avoid any pkg-config package from being found when
|
|
|
|
# find_package(Qt6Core) is called in case if the feature was disabled.
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
|
|
|
|
if(NOT QT_SKIP_BUILD_INTERNALS_PKG_CONFIG_FEATURE)
|
2022-10-28 09:44:25 +00:00
|
|
|
set(FEATURE_pkg_config \"${FEATURE_pkg_config}\" CACHE BOOL \"Using pkg-config\" FORCE)
|
2020-08-14 08:24:57 +00:00
|
|
|
endif()\n")
|
|
|
|
|
|
|
|
# The OpenSSL root dir needs to be saved so that repos other than qtbase (like qtopcua) can
|
|
|
|
# still successfully find_package(WrapOpenSSL) in the CI.
|
|
|
|
# qmake saves any additional include paths passed via the configure like '-I/foo'
|
|
|
|
# in mkspecs/qmodule.pri, so this file is the closest equivalent.
|
|
|
|
if(DEFINED OPENSSL_ROOT_DIR)
|
|
|
|
file(TO_CMAKE_PATH "${OPENSSL_ROOT_DIR}" openssl_root_cmake_path)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(OPENSSL_ROOT_DIR \"${openssl_root_cmake_path}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
qt_generate_install_prefixes(install_prefix_content)
|
|
|
|
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${install_prefix_content}")
|
|
|
|
|
2021-06-01 10:51:36 +00:00
|
|
|
if(DEFINED OpenGL_GL_PREFERENCE)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"
|
|
|
|
# Use the OpenGL_GL_PREFERENCE value qtbase was built with. But do not FORCE it.
|
|
|
|
set(OpenGL_GL_PREFERENCE \"${OpenGL_GL_PREFERENCE}\" CACHE STRING \"\")
|
|
|
|
")
|
|
|
|
endif()
|
|
|
|
|
2023-03-14 12:31:39 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"
|
|
|
|
set(QT_COPYRIGHT \"${QT_COPYRIGHT}\" CACHE STRING \"\")
|
|
|
|
")
|
|
|
|
|
2024-02-02 11:07:43 +00:00
|
|
|
# Add the apple version requirements to the BuildInternals extra code, so the info is
|
|
|
|
# available when configuring a standalone test.
|
|
|
|
# Otherwise when QtSetup is included after a
|
|
|
|
# find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
|
|
|
|
# call, Qt6ConfigExtras.cmake is not included yet, the requirements are not available and
|
|
|
|
# _qt_internal_check_apple_sdk_and_xcode_versions() would fail.
|
|
|
|
_qt_internal_export_apple_sdk_and_xcode_version_requirements(apple_requirements)
|
|
|
|
if(apple_requirements)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
|
|
|
|
${apple_requirements}
|
|
|
|
")
|
|
|
|
endif()
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
qt_compute_relative_path_from_cmake_config_dir_to_prefix()
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake.in"
|
|
|
|
"${extra_file_path}"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# For every Qt module check if there any android dependencies that require
|
|
|
|
# processing.
|
|
|
|
function(qt_modules_process_android_dependencies)
|
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
foreach (target ${repo_known_modules})
|
2021-02-09 22:07:58 +00:00
|
|
|
qt_internal_android_dependencies(${target})
|
2020-08-14 08:24:57 +00:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_create_tools_config_files)
|
|
|
|
# Create packages like Qt6CoreTools/Qt6CoreToolsConfig.cmake.
|
|
|
|
foreach(module_name ${QT_KNOWN_MODULES_WITH_TOOLS})
|
|
|
|
qt_export_tools("${module_name}")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_create_config_file_for_standalone_tests)
|
|
|
|
set(standalone_tests_config_dir "StandaloneTests")
|
|
|
|
qt_path_join(config_build_dir
|
|
|
|
${QT_CONFIG_BUILD_DIR}
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
|
|
|
|
qt_path_join(config_install_dir
|
|
|
|
${QT_CONFIG_INSTALL_DIR}
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
|
|
|
|
|
|
|
|
# Filter out bundled system libraries. Otherwise when looking for their dependencies
|
|
|
|
# (like PNG for Freetype) FindWrapPNG is searched for during configuration of
|
|
|
|
# standalone tests, and it can happen that Core or Gui features are not
|
|
|
|
# imported early enough, which means FindWrapPNG will try to find a system PNG library instead
|
|
|
|
# of the bundled one.
|
|
|
|
set(modules)
|
|
|
|
foreach(m ${QT_REPO_KNOWN_MODULES})
|
|
|
|
get_target_property(target_type "${m}" TYPE)
|
|
|
|
|
|
|
|
# Interface libraries are never bundled system libraries (hopefully).
|
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
list(APPEND modules "${m}")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
|
2022-02-22 15:57:00 +00:00
|
|
|
get_target_property(is_3rd_party "${m}" _qt_module_is_3rdparty_library)
|
2020-08-14 08:24:57 +00:00
|
|
|
if(NOT is_3rd_party)
|
|
|
|
list(APPEND modules "${m}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
list(JOIN modules " " QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
|
|
|
|
# Skip generating and installing file if no modules were built. This make sure not to install
|
|
|
|
# anything when build qtx11extras on macOS for example.
|
|
|
|
if(NOT QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2022-06-10 14:41:59 +00:00
|
|
|
# Create a Config file that calls find_package on the modules that were built as part
|
2020-08-14 08:24:57 +00:00
|
|
|
# of the current repo. This is used for standalone tests.
|
2024-03-06 16:43:04 +00:00
|
|
|
qt_internal_get_standalone_parts_config_file_name(tests_config_file_name)
|
CMake: Record used package version for each target dependency
When recording which package version to look for in
QtFooModuleDependencies.cmake and other files like it,
instead of using PROJECT_VERSION, use the version of the
package that contains the dependency.
For example if we're hypothetically building the qtdeclarative repo
from the 6.4 branch, against an installed 6.2 qtbase, then
the Qt6QmlModuleDependencies.cmake file will have a
find_package(Qt6Core 6.2) call because qtdeclarative's
find_package(Qt6Core) call found a 6.2 Core when it was configured.
This allows switching the versioning scheme of specific Qt modules
that might not want to follow the general Qt versioning scheme.
The first candidate would be QtWebEngine which might want to
follow the Chromium versioning scheme, something like
Qt 6.94.0 where 94 is the Chromium major version.
Implementation notes.
We now record the package version of a target in a property
called _qt_package_version. We do it for qt modules, plugins,
3rd party libraries, tools and the Platform target.
When we try to look up which version to write into the
QtFooModuleDependencies.cmake file (or the equivalent Plugins and
Tools file), we try to find the version
from a few sources: the property mentioned above, then the
Qt6{target}_VERSION variable, and finally PROJECT_VERSION.
In the latter case, we issue a warning because technically that should
never have to happen, and it's a bug or an unforeseen case if it does.
A few more places also need adjustments:
- package versions to look for when configuring standalone
tests and generating standalone tests Config files
- handling of tools packages
- The main Qt6 package lookup in each Dependencies.cmake files
Note that there are some requirements and consequences in case a
module wants to use a different versioning scheme like 6.94.0.
Requirements.
- The root CMakeLists.txt file needs to call find_package with a
version different from the usual PROJECT_VERSION. Ideally it
should look for a few different Qt versions which are known to be
compatible, for example the last stable and LTS versions, or just
the lowest supported Qt version, e.g. 6.2.6 or whenever this change
would land in the 6.2 branch.
- If the repository has multiple modules, some of which need to
follow the Qt versioning scheme and some not,
project(VERSION x.y.z) calls need to be carefully placed in
subdirectory scopes with appropriate version numbers, so that
qt_internal_add_module / _tool / _plugin pick up the correct
version.
Consequences.
- The .so / .dylib names will contain the new version, e.g. .so.6.94
- Linux ELF symbols will contain the new versions
- syncqt private headers will now exist under a
include/QtFoo/6.94.0/QtFoo/private folder
- pri and prl files will also contain the new version numbers
- pkg-config .pc files contain the new version numbers
- It won't be possible to write
find_package(Qt6 6.94 COMPONENTS WebEngineWidgets) in user code.
One would have to write find_package(Qt6WebEngineWidgets 6.94)
otherwise CMake will try to look for Qt6Config 6.94 which won't
exist.
- Similarly, a
find_package(Qt6 6.4 COMPONENTS Widgets WebEngineWidgets) call
would always find any kind of WebEngine package that is higher than
6.4, which might be 6.94, 6.95, etc.
- In the future, if we fix Qt6Config to pass EXACT to its
subcomponent find_package calls,
a find_package(Qt6 6.5.0 EXACT COMPONENTS Widgets WebEngineWidgets)
would fail to find WebEngineWidgets, because its 6.94.0 version
will not be equal to 6.5.0. Currently we don't pass through EXACT,
so it's not an issue.
Augments 5ffc744b791a114a3180a425dd26e298f7399955
Task-number: QTBUG-103500
Change-Id: I8bdb56bfcbc7f7f6484d1e56651ffc993fd30bab
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-17 06:44:43 +00:00
|
|
|
|
|
|
|
# Standalone tests Config files should follow the main versioning scheme.
|
|
|
|
qt_internal_get_package_version_of_target(Platform main_qt_package_version)
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in"
|
2021-09-07 16:43:20 +00:00
|
|
|
"${config_build_dir}/${tests_config_file_name}"
|
2020-08-14 08:24:57 +00:00
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
qt_install(FILES
|
2021-09-07 16:43:20 +00:00
|
|
|
"${config_build_dir}/${tests_config_file_name}"
|
2020-08-14 08:24:57 +00:00
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_install_prl_files)
|
CMake: Install prl files from all repo build dirs in a top-level build
Previously, in a top-level build we always generated the final prl
file somewhere under QT_BUILD_DIR (which is qtbase_build_dir). After
each repo was processed by QtPostProcess.cmake, we installed the prl
files found in PROJECT_BINARY_DIR.
For qtquickcontrols2 this meant that qml plugin prl files were placed
under qtbase/qml, but we tried installing the prl files from
qtquickcontrols2/qml, which didn't have any prl files.
In a static Qt build, qmake's qt.prf calls qmlimportscanner to
identify which plugins should be linked to the executable. This worked
fine because the plugin .pri files were installed correctly.
None of the qml plugin library dependencies were linked in though.
This is supposed to happen in qmake's C++ code where it tries to
find the associated prl file of a linked library in order to extract
all its dependencies. Because no prl file was found, linking failed
with multiple undefined symbols.
Fix this by installing the prl files from QT_BUILD_DIR rather than
PROJECT_BINARY_DIR.
Note that this will create multiple install rules for certain files,
but it's harmless. An example is imageformats.
We process qtbase plugins, see qjpeg, issue an install rule from under
the qtbase/plugins/imageformats folder. We then process
qtimageformats plugins, see webp, issue another install rule from
under qtbase/plugins/imageformats.
The first install rule will install both qjpeg and qwebp, the second
install rule will merely say all plugins are up-to-date.
Pick-to: 6.1 6.0
Change-Id: I8a4bb67bfafc1d016eab62f4fe66b6ba378ceeb2
Fixes: QTBUG-93021
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-23 16:25:49 +00:00
|
|
|
# Get locations relative to QT_BUILD_DIR from which prl files should be installed.
|
2020-08-14 08:24:57 +00:00
|
|
|
get_property(prl_install_dirs GLOBAL PROPERTY QT_PRL_INSTALL_DIRS)
|
CMake: Install prl files from all repo build dirs in a top-level build
Previously, in a top-level build we always generated the final prl
file somewhere under QT_BUILD_DIR (which is qtbase_build_dir). After
each repo was processed by QtPostProcess.cmake, we installed the prl
files found in PROJECT_BINARY_DIR.
For qtquickcontrols2 this meant that qml plugin prl files were placed
under qtbase/qml, but we tried installing the prl files from
qtquickcontrols2/qml, which didn't have any prl files.
In a static Qt build, qmake's qt.prf calls qmlimportscanner to
identify which plugins should be linked to the executable. This worked
fine because the plugin .pri files were installed correctly.
None of the qml plugin library dependencies were linked in though.
This is supposed to happen in qmake's C++ code where it tries to
find the associated prl file of a linked library in order to extract
all its dependencies. Because no prl file was found, linking failed
with multiple undefined symbols.
Fix this by installing the prl files from QT_BUILD_DIR rather than
PROJECT_BINARY_DIR.
Note that this will create multiple install rules for certain files,
but it's harmless. An example is imageformats.
We process qtbase plugins, see qjpeg, issue an install rule from under
the qtbase/plugins/imageformats folder. We then process
qtimageformats plugins, see webp, issue another install rule from
under qtbase/plugins/imageformats.
The first install rule will install both qjpeg and qwebp, the second
install rule will merely say all plugins are up-to-date.
Pick-to: 6.1 6.0
Change-Id: I8a4bb67bfafc1d016eab62f4fe66b6ba378ceeb2
Fixes: QTBUG-93021
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-23 16:25:49 +00:00
|
|
|
|
|
|
|
# Clear the list of install dirs so the previous values don't pollute the list of install dirs
|
|
|
|
# for the next repository in a top-level build.
|
|
|
|
set_property(GLOBAL PROPERTY QT_PRL_INSTALL_DIRS "")
|
|
|
|
|
2020-08-14 08:24:57 +00:00
|
|
|
foreach(prl_install_dir ${prl_install_dirs})
|
CMake: Install prl files from all repo build dirs in a top-level build
Previously, in a top-level build we always generated the final prl
file somewhere under QT_BUILD_DIR (which is qtbase_build_dir). After
each repo was processed by QtPostProcess.cmake, we installed the prl
files found in PROJECT_BINARY_DIR.
For qtquickcontrols2 this meant that qml plugin prl files were placed
under qtbase/qml, but we tried installing the prl files from
qtquickcontrols2/qml, which didn't have any prl files.
In a static Qt build, qmake's qt.prf calls qmlimportscanner to
identify which plugins should be linked to the executable. This worked
fine because the plugin .pri files were installed correctly.
None of the qml plugin library dependencies were linked in though.
This is supposed to happen in qmake's C++ code where it tries to
find the associated prl file of a linked library in order to extract
all its dependencies. Because no prl file was found, linking failed
with multiple undefined symbols.
Fix this by installing the prl files from QT_BUILD_DIR rather than
PROJECT_BINARY_DIR.
Note that this will create multiple install rules for certain files,
but it's harmless. An example is imageformats.
We process qtbase plugins, see qjpeg, issue an install rule from under
the qtbase/plugins/imageformats folder. We then process
qtimageformats plugins, see webp, issue another install rule from
under qtbase/plugins/imageformats.
The first install rule will install both qjpeg and qwebp, the second
install rule will merely say all plugins are up-to-date.
Pick-to: 6.1 6.0
Change-Id: I8a4bb67bfafc1d016eab62f4fe66b6ba378ceeb2
Fixes: QTBUG-93021
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-23 16:25:49 +00:00
|
|
|
qt_install(DIRECTORY "${QT_BUILD_DIR}/${prl_install_dir}/"
|
2020-08-14 08:24:57 +00:00
|
|
|
DESTINATION ${prl_install_dir}
|
|
|
|
FILES_MATCHING PATTERN "*.prl"
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
2021-02-11 13:01:58 +00:00
|
|
|
|
|
|
|
function(qt_internal_generate_user_facing_tools_info)
|
|
|
|
if("${INSTALL_PUBLICBINDIR}" STREQUAL "")
|
|
|
|
return()
|
|
|
|
endif()
|
2025-01-10 17:28:47 +00:00
|
|
|
qt_path_join(tool_link_base_dir "${CMAKE_INSTALL_PREFIX}" "${INSTALL_PUBLICBINDIR}")
|
2021-02-11 13:01:58 +00:00
|
|
|
get_property(user_facing_tool_targets GLOBAL PROPERTY QT_USER_FACING_TOOL_TARGETS)
|
|
|
|
set(lines "")
|
|
|
|
foreach(target ${user_facing_tool_targets})
|
|
|
|
get_target_property(filename ${target} OUTPUT_NAME)
|
|
|
|
if(NOT filename)
|
|
|
|
set(filename ${target})
|
|
|
|
endif()
|
2024-01-02 20:11:59 +00:00
|
|
|
set(linkname ${filename})
|
|
|
|
if(APPLE)
|
|
|
|
get_target_property(is_macos_bundle ${target} MACOSX_BUNDLE )
|
|
|
|
if(is_macos_bundle)
|
|
|
|
set(filename "${filename}.app/Contents/MacOS/${filename}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-02-11 13:01:58 +00:00
|
|
|
qt_path_join(tool_target_path "${CMAKE_INSTALL_PREFIX}" "${INSTALL_BINDIR}" "${filename}")
|
2024-01-02 20:11:59 +00:00
|
|
|
qt_path_join(tool_link_path "${INSTALL_PUBLICBINDIR}" "${linkname}${PROJECT_VERSION_MAJOR}")
|
2025-01-10 17:28:47 +00:00
|
|
|
_qt_internal_relative_path(tool_target_path BASE_DIRECTORY ${tool_link_base_dir})
|
2021-02-11 13:01:58 +00:00
|
|
|
list(APPEND lines "${tool_target_path} ${tool_link_path}")
|
|
|
|
endforeach()
|
|
|
|
string(REPLACE ";" "\n" content "${lines}")
|
|
|
|
string(APPEND content "\n")
|
|
|
|
set(out_file "${PROJECT_BINARY_DIR}/user_facing_tool_links.txt")
|
|
|
|
file(WRITE "${out_file}" "${content}")
|
|
|
|
endfunction()
|