diff options
Diffstat (limited to 'cmake/QtPostProcessHelpers.cmake')
-rw-r--r-- | cmake/QtPostProcessHelpers.cmake | 435 |
1 files changed, 286 insertions, 149 deletions
diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 4b6065e7a9..0a207f6634 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -1,9 +1,13 @@ -function(qt_internal_write_depends_file module) - set(outfile "${QT_BUILD_DIR}/include/${module}/${module}Depends") - set(contents "/* This file was generated by cmake with the info from ${module} target. */\n") +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +function(qt_internal_write_depends_file target) + get_target_property(module_depends_header ${target} _qt_module_depends_header) + set(outfile "${module_depends_header}") + set(contents "/* This file was generated by cmake with the info from ${target} target. */\n") string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n") foreach (m ${ARGN}) - string(APPEND contents "# include <Qt${m}/Qt${m}>\n") + string(APPEND contents "# include <${m}/${m}>\n") endforeach() string(APPEND contents "#endif\n") @@ -25,7 +29,7 @@ macro(qt_collect_third_party_deps target) endif() unset(_target_is_static) - foreach(dep ${${depends_var}} ${optional_public_depends}) + foreach(dep ${${depends_var}} ${optional_public_depends} ${extra_third_party_deps}) # 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}") @@ -36,7 +40,7 @@ macro(qt_collect_third_party_deps target) endif() # Strip any directory scope tokens. - qt_internal_strip_target_directory_scope_token("${dep}" dep) + __qt_internal_strip_target_directory_scope_token("${dep}" dep) if(TARGET ${dep}) list(FIND third_party_deps_seen ${dep} dep_seen) @@ -57,23 +61,58 @@ macro(qt_collect_third_party_deps target) set(package_components "") endif() + get_target_property(package_optional_components ${dep} + INTERFACE_QT_PACKAGE_OPTIONAL_COMPONENTS) + if(NOT package_optional_components) + set(package_optional_components "") + endif() + list(APPEND third_party_deps - "${package_name}\;${package_is_optional}\;${package_version}\;${package_components}") + "${package_name}\;${package_is_optional}\;${package_version}\;${package_components}\;${package_optional_components}") endif() endif() endforeach() endmacro() +# 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() + function(qt_internal_create_module_depends_file target) get_target_property(target_type "${target}" TYPE) + set(is_interface_lib FALSE) if(target_type STREQUAL "INTERFACE_LIBRARY") - set(arg_HEADER_MODULE ON) - else() - set(arg_HEADER_MODULE OFF) + set(is_interface_lib TRUE) endif() set(depends "") - if(target_type STREQUAL "STATIC_LIBRARY" AND NOT arg_HEADER_MODULE) + if(target_type STREQUAL "STATIC_LIBRARY") get_target_property(depends "${target}" LINK_LIBRARIES) endif() @@ -90,13 +129,19 @@ function(qt_internal_create_module_depends_file target) set(target_deps_seen "") set(qt_module_dependencies "") - if(NOT arg_HEADER_MODULE) + if(NOT is_interface_lib) get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES) endif() - if(NOT extra_depends STREQUAL "${extra_depends}-NOTFOUND") + if(NOT extra_depends MATCHES "-NOTFOUND$") list(APPEND target_deps "${extra_depends}") endif() + # 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() + # Used for assembling the content of an include/Module/ModuleDepends.h header. set(qtdeps "") @@ -116,7 +161,7 @@ function(qt_internal_create_module_depends_file target) # Extra QtFooModuleTools packages to be added as dependencies to # QtModuleDependencies.cmake. Needed for QtWaylandCompositor / QtWaylandClient. - if(NOT arg_HEADER_MODULE) + if(NOT is_interface_lib) get_target_property(extra_tools_package_dependencies "${target}" QT_EXTRA_TOOLS_PACKAGE_DEPENDENCIES) if(extra_tools_package_dependencies) @@ -131,41 +176,41 @@ function(qt_internal_create_module_depends_file target) # Normalize module by stripping leading "Qt::" and trailing "Private" if (dep MATCHES "(Qt|${QT_CMAKE_EXPORT_NAMESPACE})::([-_A-Za-z0-9]+)") set(dep "${CMAKE_MATCH_2}") - if (TARGET Qt::${dep}) - get_target_property(dep_type Qt::${dep} TYPE) - if (NOT dep_type STREQUAL "INTERFACE_LIBRARY") - get_target_property(skip_module_depends_include Qt::${dep} QT_MODULE_SKIP_DEPENDS_INCLUDE) - if (skip_module_depends_include) - continue() - endif() - else() - get_target_property(is_versionless_target Qt::${dep} _qt_is_versionless_target) - if(is_versionless_target) - get_target_property(module_has_headers ${QT_CMAKE_EXPORT_NAMESPACE}::${dep} - _qt_module_has_headers) - else() - get_target_property(module_has_headers Qt::${dep} _qt_module_has_headers) - endif() - if (NOT module_has_headers) - continue() - endif() + 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() endif() endif() endif() - if (dep MATCHES "(.*)Private") - set(dep "${CMAKE_MATCH_1}") - endif() list(FIND known_modules "${dep}" _pos) if (_pos GREATER -1) - list(APPEND qtdeps "${dep}") + qt_internal_module_info(module ${QT_CMAKE_EXPORT_NAMESPACE}::${dep}) + list(APPEND qtdeps ${module}) # 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) + qt_internal_get_package_version_of_target("${dep}" dep_package_version) list(APPEND tool_deps_seen ${dep}) list(APPEND tool_deps - "${INSTALL_CMAKE_NAMESPACE}${dep}Tools\;${PROJECT_VERSION}") + "${INSTALL_CMAKE_NAMESPACE}${dep}Tools\;${dep_package_version}") endif() endif() endforeach() @@ -174,46 +219,38 @@ function(qt_internal_create_module_depends_file target) # Add dependency to the main ModuleTool package to ModuleDependencies file. if(${target} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS) + qt_internal_get_package_version_of_target("${target}" main_module_tool_package_version) list(APPEND main_module_tool_deps - "${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}") + "${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${main_module_tool_package_version}") endif() - # Dirty deduplication hack because of https://gitlab.kitware.com/cmake/cmake/issues/19200 foreach(dep ${target_deps}) - if(dep) - list(FIND target_deps_seen "${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 target_deps_seen "${dep_name}\;${dep_ver}") - - if (dep_name MATCHES "${INSTALL_CMAKE_NAMESPACE}(.*)") - list(APPEND qt_module_dependencies "${CMAKE_MATCH_1}") - endif() + if(NOT dep MATCHES ".+Private$" AND + dep MATCHES "${INSTALL_CMAKE_NAMESPACE}(.+)") + # target_deps contains elements that are a pair of target name and version, + # 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() endif() endforeach() - set(target_deps "${target_deps_seen}") + list(REMOVE_DUPLICATES qt_module_dependencies) + + qt_internal_remove_qt_dependency_duplicates(target_deps "${target_deps}") + if (DEFINED qtdeps) list(REMOVE_DUPLICATES qtdeps) endif() - get_target_property(hasModuleHeaders "${target}" INTERFACE_MODULE_HAS_HEADERS) + get_target_property(hasModuleHeaders "${target}" _qt_module_has_headers) if (${hasModuleHeaders}) - get_target_property(module_include_name "${target}" INTERFACE_MODULE_INCLUDE_NAME) - qt_internal_write_depends_file(${module_include_name} ${qtdeps}) + qt_internal_write_depends_file(${target} ${qtdeps}) endif() if(third_party_deps OR main_module_tool_deps OR target_deps) @@ -221,6 +258,10 @@ function(qt_internal_create_module_depends_file 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}) + # 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) + # Configure and install ModuleDependencies file. configure_file( "${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in" @@ -234,6 +275,9 @@ function(qt_internal_create_module_depends_file target) COMPONENT Devel ) + message(TRACE "Recorded dependencies for module: ${target}\n" + " Qt dependencies: ${target_deps}\n" + " 3rd-party dependencies: ${third_party_deps}") endif() if(tool_deps) # The value of the property will be used by qt_export_tools. @@ -249,34 +293,28 @@ function(qt_internal_create_plugin_depends_file target) unset(optional_public_depends) set(target_deps_seen "") - qt_collect_third_party_deps(${target}) - # Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200 - foreach(dep ${target_deps}) - if(dep) - list(FIND target_deps_seen "${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) + # 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() - list(APPEND target_deps_seen "${dep_name}\;${dep_ver}") - endif() - endif() - endforeach() - set(target_deps "${target_deps_seen}") + qt_collect_third_party_deps(${target}) + + qt_internal_remove_qt_dependency_duplicates(target_deps "${target_deps}") if(third_party_deps OR target_deps) # Setup build and install paths - set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/..") + + # 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}") 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. - set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/../..") + set(find_dependency_paths "\${CMAKE_CURRENT_LIST_DIR}/../..;\${_qt_cmake_dir}") endif() else() @@ -298,6 +336,10 @@ function(qt_internal_create_plugin_depends_file target) DESTINATION "${config_install_dir}" COMPONENT Devel ) + + message(TRACE "Recorded dependencies for plugin: ${target}\n" + " Qt dependencies: ${target_deps}\n" + " 3rd-party dependencies: ${third_party_deps}") endif() endfunction() @@ -324,7 +366,17 @@ function(qt_internal_create_qt6_dependencies_file) endif()") endif() - if(third_party_deps) + _qt_internal_determine_if_host_info_package_needed(platform_requires_host_info_package) + + 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 + "${Qt${PROJECT_VERSION_MAJOR}HostInfo_DIR}/.." ABSOLUTE) + endif() + + if(third_party_deps OR platform_requires_host_info_package) # Setup build and install paths. set(path_suffix "${INSTALL_CMAKE_NAMESPACE}") @@ -363,17 +415,14 @@ function(qt_internal_create_depends_files) endforeach() endfunction() -# This function creates the Qt<Module>Plugins.cmake used to list all -# the plug-in target files. -function(qt_internal_create_plugins_files) - # The plugins cmake configuration is only needed for static builds. Dynamic builds don't need - # the application to link against plugins at build time. - if(QT_BUILD_SHARED_LIBS) - return() - endif() +# 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. qt_internal_get_qt_repo_known_modules(repo_known_modules) - message("Generating Plugins files for ${repo_known_modules}...") + set(modules_with_plugins "") foreach (QT_MODULE ${repo_known_modules}) get_target_property(target_type "${QT_MODULE}" TYPE) if(target_type STREQUAL "INTERFACE_LIBRARY") @@ -386,16 +435,72 @@ function(qt_internal_create_plugins_files) if(QT_MODULE STREQUAL "Qml") set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES} -file(GLOB __qt_qml_plugins_config_file_list \"\${CMAKE_CURRENT_LIST_DIR}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake\") +# Qml plugin targets might have dependencies on other qml plugin targets, but the Targets.cmake +# files are included in the order that file(GLOB) returns, which means certain targets that are +# referenced might not have been created yet, and \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE +# might be set to a message saying those targets don't exist. +# +# Postpone checking of which targets don't exist until all Qml PluginConfig.cmake files have been +# included, by including all the files one more time and checking for errors at each step. +# +# TODO: Find a better way to deal with this, perhaps by using find_package() instead of include +# for the Qml PluginConfig.cmake files. + +# Distributions should probably change this default. +if(NOT DEFINED QT_SKIP_AUTO_QML_PLUGIN_INCLUSION) + set(QT_SKIP_AUTO_QML_PLUGIN_INCLUSION OFF) +endif() + +set(__qt_qml_plugins_config_file_list \"\") +set(__qt_qml_plugins_glob_prefixes \"\${CMAKE_CURRENT_LIST_DIR}\") + +# Allow passing additional prefixes where we will glob for PluginConfig.cmake files. +if(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES) + foreach(__qt_qml_plugin_glob_prefix IN LISTS QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES) + if(__qt_qml_plugin_glob_prefix) + list(APPEND __qt_qml_plugins_glob_prefixes \"\${__qt_qml_plugin_glob_prefix}\") + endif() + endforeach() +endif() + +list(REMOVE_DUPLICATES __qt_qml_plugins_glob_prefixes) + +foreach(__qt_qml_plugin_glob_prefix IN LISTS __qt_qml_plugins_glob_prefixes) + file(GLOB __qt_qml_plugins_glob_config_file_list + \"\${__qt_qml_plugin_glob_prefix}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake\") + if(__qt_qml_plugins_glob_config_file_list) + list(APPEND __qt_qml_plugins_config_file_list \${__qt_qml_plugins_glob_config_file_list}) + endif() +endforeach() + if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION) + # First round of inclusions ensure all qml plugin targets are brought into scope. + foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list}) + include(\${__qt_qml_plugin_config_file}) + + # Temporarily unset any failure markers and mark the Qml package as found. + unset(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE) + set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE) + endforeach() + + # For the second round of inclusions, check and bail out early if there are errors. foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list}) include(\${__qt_qml_plugin_config_file}) + + if(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE) + string(APPEND \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + \"\nThe message was set in \${__qt_qml_plugin_config_file} \") + set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() + endif() endforeach() + endif()") endif() - get_target_property(qt_plugins "${QT_MODULE}" QT_PLUGINS) - if(qt_plugins OR QT_MODULE_PLUGIN_INCLUDES) + get_target_property(module_plugin_types "${QT_MODULE}" MODULE_PLUGIN_TYPES) + if(module_plugin_types OR QT_MODULE_PLUGIN_INCLUDES) + list(APPEND modules_with_plugins "${QT_MODULE}") configure_file( "${QT_CMAKE_DIR}/QtPlugins.cmake.in" "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake" @@ -408,6 +513,10 @@ endif()") ) endif() endforeach() + if(modules_with_plugins) + message(STATUS "Generated QtModulePlugins.cmake files for the following modules:" + " ${modules_with_plugins}") + endif() endfunction() function(qt_generate_install_prefixes out_var) @@ -466,12 +575,11 @@ function(qt_generate_build_internals_extra_cmake_code) ${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake) if(CMAKE_BUILD_TYPE) - # Need to force set, because CMake itself initializes a value for CMAKE_BUILD_TYPE - # at the start of project configuration (with an empty value), - # so we need to force override it. string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS - "set(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" CACHE STRING \"Choose the type of build.\" FORCE)\n") - + " +# Used by qt_internal_set_cmake_build_type. +set(__qt_internal_initial_qt_cmake_build_type \"${CMAKE_BUILD_TYPE}\") +") endif() if(CMAKE_CONFIGURATION_TYPES) string(APPEND multi_config_specific @@ -492,14 +600,6 @@ function(qt_generate_build_internals_extra_cmake_code) string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "\nset(QT_MULTI_CONFIG_FIRST_CONFIG \"${QT_MULTI_CONFIG_FIRST_CONFIG}\")\n") endif() - # When building standalone tests against a multi-config Qt, we want to choose the first - # configuration, rather than default to Debug. - if(multi_config_specific) - string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS " -if(QT_BUILD_STANDALONE_TESTS) - set(CMAKE_BUILD_TYPE \"\${QT_MULTI_CONFIG_FIRST_CONFIG}\" CACHE STRING \"Choose the type of build.\" FORCE) -endif()\n") - endif() if(CMAKE_CROSS_CONFIGS) string(APPEND ninja_multi_config_specific @@ -530,14 +630,26 @@ endif()\n") "set(QT_IS_MACOS_UNIVERSAL \"${QT_IS_MACOS_UNIVERSAL}\" CACHE BOOL \"\")\n") endif() - if(CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING) + if(DEFINED QT_APPLE_SDK) + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS + "set(QT_APPLE_SDK \"${QT_APPLE_SDK}\" CACHE BOOL \"\")\n") + endif() + + if(QT_FORCE_FIND_TOOLS) + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS + "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_BUILD_TOOLS_WHEN_CROSSCOMPILING \"TRUE\" CACHE BOOL \"\" FORCE)\n") + "set(QT_FORCE_BUILD_TOOLS \"TRUE\" CACHE BOOL \"\" FORCE)\n") endif() - if(ECM_ENABLE_SANITIZERS) + if(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX) + file(TO_CMAKE_PATH + "${QT_INTERNAL_EXAMPLES_INSTALL_PREFIX}" examples_install_prefix) string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS - "set(ECM_ENABLE_SANITIZERS \"${ECM_ENABLE_SANITIZERS}\" CACHE BOOL \"\" FORCE)\n") + "set(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX \"${examples_install_prefix}\" CACHE STRING \"\")\n") endif() # Save the default qpa platform. @@ -549,18 +661,16 @@ endif()\n") endif() # Save minimum and policy-related CMake versions to ensure the same minimum is - # checked for when building other child repos (qtsvg, etc) and the policy settings - # will be consistent unless the child repos explicitly override them. - qt_internal_get_qt_supported_minimum_cmake_version(min_supported_version) - qt_internal_get_computed_minimum_cmake_version(computed_min_version) - qt_internal_get_min_new_policy_cmake_version(lower_policy_version) - qt_internal_get_max_new_policy_cmake_version(upper_policy_version) - string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS - "set(QT_MIN_SUPPORTED_CMAKE_VERSION \"${min_supported_version}\" CACHE STRING \"Minimum supported CMake version required to build Qt\")\n" - "set(QT_COMPUTED_MIN_CMAKE_VERSION \"${computed_min_version}\" CACHE STRING \"Computed minimum CMake version required to build Qt\")\n" - "set(QT_MIN_NEW_POLICY_CMAKE_VERSION \"${lower_policy_version}\" CACHE STRING \"Oldest CMake version for which NEW policies should be enabled\")\n" - "set(QT_MAX_NEW_POLICY_CMAKE_VERSION \"${upper_policy_version}\" CACHE STRING \"Latest CMake version for which NEW policies should be enabled\")\n" - ) + # 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) # Rpath related things that need to be re-used when building other repos. string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS @@ -589,13 +699,18 @@ endif()\n") string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "set(QT_EXTRA_RPATHS \"${QT_EXTRA_RPATHS}\" CACHE STRING \"\")\n") endif() + 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() # 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) - set(FEATURE_pkg_config \"${FEATURE_pkg_config}\" CACHE STRING \"Using pkg-config\" FORCE) + set(FEATURE_pkg_config \"${FEATURE_pkg_config}\" CACHE BOOL \"Using pkg-config\" FORCE) endif()\n") # The OpenSSL root dir needs to be saved so that repos other than qtbase (like qtopcua) can @@ -608,28 +723,33 @@ endif()\n") "set(OPENSSL_ROOT_DIR \"${openssl_root_cmake_path}\" CACHE STRING \"\")\n") endif() - if(NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "") - string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS - " -# If no explicit CMAKE_STAGING_PREFIX is provided, force set the original Qt staging prefix, -if(\"$\{CMAKE_STAGING_PREFIX}\" STREQUAL \"\" - AND NOT QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX) - set(CMAKE_STAGING_PREFIX \"${CMAKE_STAGING_PREFIX}\" CACHE PATH - \"Staging path prefix, prepended onto install directories on the host machine.\" FORCE) -endif() -") - endif() - qt_generate_install_prefixes(install_prefix_content) string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${install_prefix_content}") - if(NOT QT_SUPERBUILD AND NOT BUILD_SHARED_LIBS) + if(DEFINED OpenGL_GL_PREFERENCE) string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS " -if(DEFINED QT_REPO_MODULE_VERSION AND NOT DEFINED QT_REPO_DEPENDENCIES) - qt_internal_read_repo_dependencies(QT_REPO_DEPENDENCIES \"$\{PROJECT_SOURCE_DIR}\") -endif() +# 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() + + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS + " +set(QT_COPYRIGHT \"${QT_COPYRIGHT}\" CACHE STRING \"\") +") + + # 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() @@ -682,7 +802,7 @@ function(qt_internal_create_config_file_for_standalone_tests) continue() endif() - get_target_property(is_3rd_party "${m}" QT_MODULE_IS_3RDPARTY_LIBRARY) + get_target_property(is_3rd_party "${m}" _qt_module_is_3rdparty_library) if(NOT is_3rd_party) list(APPEND modules "${m}") endif() @@ -697,25 +817,35 @@ function(qt_internal_create_config_file_for_standalone_tests) return() endif() - # Ceate a Config file that calls find_package on the modules that were built as part + # Create a Config file that calls find_package on the modules that were built as part # of the current repo. This is used for standalone tests. + qt_internal_get_standalone_parts_config_file_name(tests_config_file_name) + + # Standalone tests Config files should follow the main versioning scheme. + qt_internal_get_package_version_of_target(Platform main_qt_package_version) + configure_file( "${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in" - "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake" + "${config_build_dir}/${tests_config_file_name}" @ONLY ) qt_install(FILES - "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake" + "${config_build_dir}/${tests_config_file_name}" DESTINATION "${config_install_dir}" COMPONENT Devel ) endfunction() function(qt_internal_install_prl_files) - # Install prl files + # Get locations relative to QT_BUILD_DIR from which prl files should be installed. get_property(prl_install_dirs GLOBAL PROPERTY QT_PRL_INSTALL_DIRS) + + # 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 "") + foreach(prl_install_dir ${prl_install_dirs}) - qt_install(DIRECTORY "${PROJECT_BINARY_DIR}/${prl_install_dir}/" + qt_install(DIRECTORY "${QT_BUILD_DIR}/${prl_install_dir}/" DESTINATION ${prl_install_dir} FILES_MATCHING PATTERN "*.prl" ) @@ -733,8 +863,15 @@ function(qt_internal_generate_user_facing_tools_info) if(NOT filename) set(filename ${target}) endif() + 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() qt_path_join(tool_target_path "${CMAKE_INSTALL_PREFIX}" "${INSTALL_BINDIR}" "${filename}") - qt_path_join(tool_link_path "${INSTALL_PUBLICBINDIR}" "${filename}${PROJECT_VERSION_MAJOR}") + qt_path_join(tool_link_path "${INSTALL_PUBLICBINDIR}" "${linkname}${PROJECT_VERSION_MAJOR}") list(APPEND lines "${tool_target_path} ${tool_link_path}") endforeach() string(REPLACE ";" "\n" content "${lines}") |