From ea81b69cde70316b5b5b161d8fb9bf904b229523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 21 Nov 2019 13:33:28 +0100 Subject: [PATCH] Implement qtbase fixes for superbuilds Change-Id: I0d3445cf0740e3925fa9342dac4d07892518afe5 Reviewed-by: Qt CMake Build Bot Reviewed-by: Cristian Adam --- cmake/3rdpartyConfig.cmake.in | 4 +- cmake/FindWrapPCRE2.cmake | 5 +- cmake/QtBaseGlobalTargets.cmake | 8 +- cmake/QtBuild.cmake | 97 +++++++++++++++---- cmake/QtBuildInformation.cmake | 35 +++++++ .../QtBuildInternalsConfig.cmake | 49 +++------- cmake/QtModuleConfig.cmake.in | 9 +- cmake/QtPluginConfig.cmake.in | 2 + cmake/QtPlugins.cmake.in | 31 ++++-- cmake/QtPostProcess.cmake | 4 +- qmake/CMakeLists.txt | 2 +- src/corelib/CMakeLists.txt | 2 +- .../other/qaccessibilitylinux/CMakeLists.txt | 3 +- 13 files changed, 169 insertions(+), 82 deletions(-) create mode 100644 cmake/QtBuildInformation.cmake diff --git a/cmake/3rdpartyConfig.cmake.in b/cmake/3rdpartyConfig.cmake.in index fe15a1efc6..6af3792333 100644 --- a/cmake/3rdpartyConfig.cmake.in +++ b/cmake/3rdpartyConfig.cmake.in @@ -10,4 +10,6 @@ set(CMAKE_MODULE_PATH "${_import_prefix}" ${CMAKE_MODULE_PATH} ) set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}") -include("${CMAKE_CURRENT_LIST_DIR}/@target@Targets.cmake") +if (NOT QT_NO_CREATE_TARGETS) + include("${CMAKE_CURRENT_LIST_DIR}/@target@Targets.cmake") +endif() diff --git a/cmake/FindWrapPCRE2.cmake b/cmake/FindWrapPCRE2.cmake index b69c5078a5..08f660bdfc 100644 --- a/cmake/FindWrapPCRE2.cmake +++ b/cmake/FindWrapPCRE2.cmake @@ -1,4 +1,7 @@ -include_guard(GLOBAL) # pragma once equivalent +if(TARGET WrapPCRE2::WrapPCRE2) + set(WrapPCRE2_FOUND TRUE) + return() +endif() find_package(PCRE2 CONFIG QUIET) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 037faa0e65..5f38f96681 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -203,6 +203,7 @@ qt_internal_export_modern_cmake_config_targets_file(TARGETS ${__export_targets} qt_copy_or_install(FILES cmake/ModuleDescription.json.in cmake/QtBuild.cmake + cmake/QtBuildInformation.cmake cmake/QtCompilerFlags.cmake cmake/QtCompilerOptimization.cmake cmake/QtFeature.cmake @@ -221,13 +222,8 @@ qt_copy_or_install(FILES cmake/QtPluginDependencies.cmake.in DESTINATION "${__GlobalConfig_install_dir}" ) -if(QT_WILL_INSTALL) - # NOTE: QtFeature.cmake is included by the Qt module config files unconditionally - # In a prefix build, QtFeature.cmake is not copied to the build dir by default - # Thus do it explicitly in that case so we can use the module config files in the examples - file(COPY cmake/QtFeature.cmake DESTINATION "${__GlobalConfig_install_dir}") -endif() +file(COPY cmake/QtFeature.cmake DESTINATION "${__GlobalConfig_build_dir}") # TODO: Check whether this is the right place to install these qt_copy_or_install(DIRECTORY cmake/3rdparty DESTINATION "${__GlobalConfig_install_dir}") diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 2b21ac9673..d8d0980215 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -49,6 +49,18 @@ endif() set(QT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}") +# Find the path to mkspecs/, depending on whether we are building as part of a standard qtbuild, +# or a module against an already installed version of qt. +if(NOT QT_MKSPECS_DIR) + if("${QT_BUILD_INTERNALS_PATH}" STREQUAL "") + get_filename_component(QT_MKSPECS_DIR "${CMAKE_CURRENT_LIST_DIR}/../mkspecs" ABSOLUTE) + else() + # We can rely on CMAKE_INSTALL_PREFIX being set by QtBuildInternalsExtra.cmake + get_filename_component(QT_MKSPECS_DIR "${CMAKE_INSTALL_PREFIX}/mkspecs" ABSOLUTE) + endif() + set(QT_MKSPECS_DIR "${QT_MKSPECS_DIR}" CACHE INTERNAL "") +endif() + # the default RPATH to be used when installing, but only if it's not a system directory LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") @@ -239,7 +251,8 @@ else() endif() # Compute the values of QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR -# taking into account whether the current build is a prefix build or a non-prefix build. +# taking into account whether the current build is a prefix build or a non-prefix build, +# and whether it is a superbuild or non-superbuild. # # These values should be prepended to file paths in commands or properties, # in order to correctly place generated Config files, generated Targets files, @@ -248,17 +261,29 @@ endif() # The build dir variables will always be absolute paths. # The QT_INSTALL_DIR variable will have a relative path in a prefix build, # which means that it can be empty, so use qt_join_path to prevent accidental absolute paths. -if(QT_WILL_INSTALL) - # In the usual prefix build case, the build dir is the current module build dir, - # and the install dir is the prefix, so we don't set it. - set(QT_BUILD_DIR "${CMAKE_BINARY_DIR}") - set(QT_INSTALL_DIR "") +if(QT_SUPERBUILD) + # In this case, we always copy all the build products in qtbase/{bin,lib,...} + if(QT_WILL_INSTALL) + set(QT_BUILD_DIR "${QtBase_BINARY_DIR}") + set(QT_INSTALL_DIR "") + else() + set(QT_BUILD_DIR "${QtBase_BINARY_DIR}") + set(QT_INSTALL_DIR "${QtBase_BINARY_DIR}") + endif() else() - # When doing a non-prefix build, both the build dir and install dir are the same, - # pointing to the qtbase build dir. - set(QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}") - set(QT_INSTALL_DIR "${QT_BUILD_DIR}") + if(QT_WILL_INSTALL) + # In the usual prefix build case, the build dir is the current module build dir, + # and the install dir is the prefix, so we don't set it. + set(QT_BUILD_DIR "${CMAKE_BINARY_DIR}") + set(QT_INSTALL_DIR "") + else() + # When doing a non-prefix build, both the build dir and install dir are the same, + # pointing to the qtbase build dir. + set(QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}") + set(QT_INSTALL_DIR "${QT_BUILD_DIR}") + endif() endif() + set(__config_path_part "${INSTALL_LIBDIR}/cmake") set(QT_CONFIG_BUILD_DIR "${QT_BUILD_DIR}/${__config_path_part}") set(QT_CONFIG_INSTALL_DIR "${QT_INSTALL_DIR}") @@ -421,6 +446,14 @@ endfunction() # cmake_install.cmake file with an empty one. This means we will always replace the file on # every reconfiguration, but not when doing null builds. function(qt_remove_install_target) + # On superbuilds we only do this for qtbase - it will correctly remove the + # cmake_install.cmake at the root of the repository. + if(QT_SUPERBUILD) + if(NOT (PROJECT_NAME STREQUAL "QtBase")) + return() + endif() + endif() + set(file_in "${CMAKE_BINARY_DIR}/.remove_cmake_install_in.txt") set(file_generated "${CMAKE_BINARY_DIR}/.remove_cmake_install_generated.txt") set(cmake_install_file "${CMAKE_BINARY_DIR}/cmake_install.cmake") @@ -849,7 +882,7 @@ function(qt_internal_add_linker_version_script target) qt_ensure_perl() add_custom_command(TARGET "${target}" PRE_LINK - COMMAND "${HOST_PERL}" "${PROJECT_SOURCE_DIR}/mkspecs/features/data/unix/findclasslist.pl" < "${infile}" > "${outfile}" + COMMAND "${HOST_PERL}" "${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl" < "${infile}" > "${outfile}" BYPRODUCTS "${outfile}" DEPENDS "${infile}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Generating version linker script" @@ -1577,6 +1610,15 @@ function(qt_add_module target) endif() if(NOT arg_HEADER_MODULE) + # This property is used for super builds with static libraries. We use + # it in QtPlugins.cmake.in to avoid "polluting" the dependency chain + # for the target in it's project directory. + # E.g: When we process find_package(Qt6 ... Gui) in QtDeclarative, the + # rules in QtPugins.cmake add all the known Gui plugins as interface + # dependencies. This in turn causes circular dependencies on every + # plugin which links against Gui. Plugin A -> GUI -> Plugin A .... + + set_target_properties(${target} PROPERTIES QT_BUILD_PROJECT_NAME ${PROJECT_NAME}) # Plugin types associated to a module if(NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x") # Reset the variable containing the list of plugins for the given plugin type @@ -2152,6 +2194,10 @@ function(qt_add_plugin target) qt_internal_add_target_aliases("${target}") qt_skip_warnings_are_errors_when_repo_unclean("${target}") + # Disable linking of plugins against other plugins during static regular and + # super builds. The latter causes cyclic dependencies otherwise. + set_target_properties(${target} PROPERTIES QT_DEFAULT_PLUGINS 0) + set_target_properties("${target}" PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${output_directory}" RUNTIME_OUTPUT_DIRECTORY "${output_directory}" @@ -2601,11 +2647,11 @@ function(qt_add_executable name) ${ARGN}) if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x") - set(arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}") + set(arg_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}") endif() get_filename_component(arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" - ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}") + ABSOLUTE BASE_DIR "${QT_BUILD_DIR}") if ("x${arg_INSTALL_DIRECTORY}" STREQUAL "x") set(arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}") @@ -3357,7 +3403,7 @@ function(qt_compute_injection_forwarding_header target) get_filename_component(file_name "${arg_SOURCE}" NAME) set(source_absolute_path "${CMAKE_CURRENT_BINARY_DIR}/${arg_SOURCE}") - file(RELATIVE_PATH relpath "${CMAKE_BINARY_DIR}" "${source_absolute_path}") + file(RELATIVE_PATH relpath "${PROJECT_BINARY_DIR}" "${source_absolute_path}") if (arg_PRIVATE) set(fwd "${PROJECT_VERSION}/${module}/private/${file_name}") @@ -3382,9 +3428,15 @@ function(qt_add_docs) set(target ${ARGV0}) set(doc_project ${ARGV1}) - set(qdoc_bin "${CMAKE_INSTALL_PREFIX}/bin/qdoc") - set(qtattributionsscanner_bin "${CMAKE_INSTALL_PREFIX}/bin/qtattributionsscanner") - set(qhelpgenerator_bin "${CMAKE_INSTALL_PREFIX}/bin/qhelpgenerator") + if (NOT QT_SUPERBUILD OR QT_WILL_INSTALL) + set(qdoc_bin "${CMAKE_INSTALL_PREFIX}/bin/qdoc") + set(qtattributionsscanner_bin "${CMAKE_INSTALL_PREFIX}/bin/qtattributionsscanner") + set(qhelpgenerator_bin "${CMAKE_INSTALL_PREFIX}/bin/qhelpgenerator") + else() + set(qdoc_bin "${CMAKE_INSTALL_PREFIX}/qtbase/bin/qdoc") + set(qtattributionsscanner_bin "${CMAKE_INSTALL_PREFIX}/qtbase/bin/qtattributionsscanner") + set(qhelpgenerator_bin "${CMAKE_INSTALL_PREFIX}/qtbase/bin/qhelpgenerator") + endif() get_target_property(target_type ${target} TYPE) if (NOT target_type STREQUAL "INTERFACE_LIBRARY") @@ -3415,6 +3467,9 @@ function(qt_add_docs) if (QT_WILL_INSTALL) set(qdoc_output_dir "${CMAKE_BINARY_DIR}/doc/${doc_target}") set(index_dir "${CMAKE_BINARY_DIR}/doc") + elseif (QT_SUPERBUILD) + set(qdoc_output_dir "${CMAKE_INSTALL_PREFIX}/qtbase/doc/${doc_target}") + set(index_dir "${CMAKE_INSTALL_PREFIX}/qtbase/doc") else() set(qdoc_output_dir "${CMAKE_INSTALL_PREFIX}/doc/${doc_target}") set(index_dir "${CMAKE_INSTALL_PREFIX}/doc") @@ -3439,8 +3494,14 @@ function(qt_add_docs) "${include_path_args}" ) + if (QT_SUPERBUILD AND NOT QT_WILL_INSTALL) + set(qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/qtbase/doc") + else() + set(qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/doc") + endif() + set(qdoc_env_args - "QT_INSTALL_DOCS=\"${CMAKE_INSTALL_PREFIX}/doc\"" + "QT_INSTALL_DOCS=\"${qt_install_docs_env}\"" "QT_VERSION=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" "QT_VER=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" "QT_VERSION_TAG=${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}" diff --git a/cmake/QtBuildInformation.cmake b/cmake/QtBuildInformation.cmake new file mode 100644 index 0000000000..097192b2ab --- /dev/null +++ b/cmake/QtBuildInformation.cmake @@ -0,0 +1,35 @@ +function(qt_print_feature_summary) + include(FeatureSummary) + feature_summary(WHAT PACKAGES_FOUND + REQUIRED_PACKAGES_NOT_FOUND + RECOMMENDED_PACKAGES_NOT_FOUND + OPTIONAL_PACKAGES_NOT_FOUND + RUNTIME_PACKAGES_NOT_FOUND + FATAL_ON_MISSING_REQUIRED_PACKAGES) +endfunction() + +function(qt_print_build_instructions) + if((NOT PROJECT_NAME STREQUAL "QtBase" AND + NOT PROJECT_NAME STREQUAL "Qt") OR + QT_BUILD_STANDALONE_TESTS) + + return() + endif() + + set(build_command "cmake --build . --parallel") + set(install_command "cmake --install .") + + message("Qt is now configured for building. Just run '${build_command}'.") + if(QT_WILL_INSTALL) + message("Once everything is built, you must run '${install_command}'.") + message("Qt will be installed into '${CMAKE_INSTALL_PREFIX}'") + else() + message("Once everything is built, Qt is installed.") + message("You should NOT run '${install_command}'") + message("Note that this build cannot be deployed to other machines or devices.") + endif() + message("To configure and build other modules, you can use the following convenience script: + ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qt-cmake") + message("\nIf reconfiguration fails for some reason, try to remove 'CMakeCache.txt' \ +from the build directory \n") +endfunction() diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 17ef9b9027..2703e06fe5 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -19,12 +19,12 @@ macro(qt_set_up_build_internals_paths) set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}") list(PREPEND CMAKE_MODULE_PATH "${QT_CMAKE_MODULE_PATH}") - # When doing a non-prefix build, prepend the qtbase source cmake directory to CMAKE_MODULE_PATH, + # Prepend the qtbase source cmake directory to CMAKE_MODULE_PATH, # so that if a change is done in cmake/QtBuild.cmake, it gets automatically picked up when # building qtdeclarative, rather than having to build qtbase first (which will copy # QtBuild.cmake to the build dir). This is similar to qmake non-prefix builds, where the # source qtbase/mkspecs directory is used. - if(NOT QT_WILL_INSTALL) + if(EXISTS "${QT_SOURCE_TREE}/cmake") list(PREPEND CMAKE_MODULE_PATH "${QT_SOURCE_TREE}/cmake") endif() @@ -94,6 +94,8 @@ macro(qt_build_repo_begin) endmacro() macro(qt_build_repo_end) + include(QtBuildInformation) + if(NOT QT_BUILD_STANDALONE_TESTS) # Delayed actions on some of the Qt targets: include(QtPostProcess) @@ -110,41 +112,16 @@ macro(qt_build_repo_end) endif() endif() - # Print a feature summary: - feature_summary(WHAT PACKAGES_FOUND - REQUIRED_PACKAGES_NOT_FOUND - RECOMMENDED_PACKAGES_NOT_FOUND - OPTIONAL_PACKAGES_NOT_FOUND - RUNTIME_PACKAGES_NOT_FOUND - FATAL_ON_MISSING_REQUIRED_PACKAGES) + if(NOT QT_SUPERBUILD) + qt_print_feature_summary() + endif() endif() - qt_print_build_instructions() + if(NOT QT_SUPERBUILD) + qt_print_build_instructions() + endif() endmacro() -function(qt_print_build_instructions) - if(NOT PROJECT_NAME STREQUAL "QtBase" OR QT_BUILD_STANDALONE_TESTS) - return() - endif() - - set(build_command "cmake --build . --parallel") - set(install_command "cmake --install .") - - message("Qt is now configured for building. Just run '${build_command}'.") - if(QT_WILL_INSTALL) - message("Once everything is built, you must run '${install_command}'.") - message("Qt will be installed into '${CMAKE_INSTALL_PREFIX}'") - else() - message("Once everything is built, Qt is installed.") - message("You should NOT run '${install_command}'") - message("Note that this build cannot be deployed to other machines or devices.") - endif() - message("To configure and build other modules, you can use the following convenience script: - ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qt-cmake") - message("\nIf reconfiguration fails for some reason, try to remove 'CMakeCache.txt' \ -from the build directory \n") -endfunction() - macro(qt_build_repo) qt_build_repo_begin(${ARGN}) @@ -199,7 +176,7 @@ macro(qt_build_tests) qt_path_join(_qt_build_tests_install_prefix ${CMAKE_INSTALL_PREFIX} ${_qt_build_tests_install_prefix}) endif() - include("${_qt_build_tests_install_prefix}/${CMAKE_PROJECT_NAME}TestsConfig.cmake" OPTIONAL) + include("${_qt_build_tests_install_prefix}/${PROJECT_NAME}TestsConfig.cmake" OPTIONAL) # Of course we always need the test module as well. find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test) @@ -222,8 +199,8 @@ macro(qt_examples_build_begin) # Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake. # Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those # find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored. - list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") - list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") + list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") + list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") # Also make sure the CMake config files do not recreate the already-existing targets set(QT_NO_CREATE_TARGETS TRUE) set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index fc7225b076..8e24362502 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -14,11 +14,6 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependenci include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") endif() -# Guard against multiple inclusion of the plugins file in the same local directory scope. -if(NOT TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@) - set(_QT_NEED_TO_INCLUDE_PLUGINS_@target@ TRUE) -endif() - if (NOT QT_NO_CREATE_TARGETS) include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake") if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS) @@ -35,11 +30,9 @@ include(${_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir}/QtFeature.cmake) qt_make_features_available(@QT_CMAKE_EXPORT_NAMESPACE@::@target@) set("@INSTALL_CMAKE_NAMESPACE@@target@_FOUND" TRUE) -if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake" - AND _QT_NEED_TO_INCLUDE_PLUGINS_@target@) +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake") endif() -unset(_QT_NEED_TO_INCLUDE_PLUGINS_@target@) list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@") diff --git a/cmake/QtPluginConfig.cmake.in b/cmake/QtPluginConfig.cmake.in index ab812abcf2..5fde0bc511 100644 --- a/cmake/QtPluginConfig.cmake.in +++ b/cmake/QtPluginConfig.cmake.in @@ -1,3 +1,5 @@ +include_guard(DIRECTORY) + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in index fb87a54c0d..692b5b1836 100644 --- a/cmake/QtPlugins.cmake.in +++ b/cmake/QtPlugins.cmake.in @@ -1,3 +1,5 @@ +include_guard(DIRECTORY) + @QT_MODULE_PLUGIN_INCLUDES@ if(NOT @BUILD_SHARED_LIBS@) @@ -17,6 +19,18 @@ if(NOT @BUILD_SHARED_LIBS@) set(_manual_plugins_genex "$>") set(_no_plugins_genex "$>") + # In super builds the rules below pollute the dependency rule for the + # plugin target when it's being build, causing cyclic dependencies. + # to overcome this, we check if the current target where this rule evaluates + # has a QT_BUILD_PROJECT_NAME equal to the current PROJECT_NAME. + # If so we disable the injection of plugin link rules to avoid cyclic + # dependencies. + if (@QT_SUPERBUILD@) + set(_build_allow_plugin_link_rules_genex "$,@PROJECT_NAME@>>") + else() + set(_build_allow_plugin_link_rules_genex TRUE) + endif() + # The code in here uses the properties defined in qt_import_plugins (Qt6CoreMacros.cmake) foreach(target @qt_plugins@) set(_plugin_target "@INSTALL_CMAKE_NAMESPACE@::${target}") @@ -64,13 +78,16 @@ if(NOT @BUILD_SHARED_LIBS@) # Complete condition that defines whether a static plugin is linked string(CONCAT _plugin_condition - "$" ">" ">>" ) diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 2e0fe602a8..b20b85bef9 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -353,11 +353,11 @@ function(qt_internal_create_config_file_for_standalone_tests) # of the current repo. This is used for standalone tests. configure_file( "${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in" - "${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake" + "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake" @ONLY ) qt_install(FILES - "${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake" + "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake" DESTINATION "${config_install_dir}" COMPONENT Devel ) diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index 5f5f1f63c0..056f17699b 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -122,7 +122,7 @@ qt_add_tool(qmake # special case generators/win32 library $ # special case - ${CMAKE_BINARY_DIR}/src/corelib/global # special case: for qconfig.cpp + "${PROJECT_BINARY_DIR}/src/corelib/global" # special case: for qconfig.cpp PRECOMPILED_HEADER "qmake_pch.h" ) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index f8d70de115..77f0d5a02d 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -243,7 +243,7 @@ qt_add_module(Core QT_NO_FOREACH QT_NO_USING_NAMESPACE INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}/global # special case + "${CMAKE_CURRENT_BINARY_DIR}/global" # special case ../3rdparty/tinycbor/src # special case: remove ../3rdparty/... PRECOMPILED_HEADER diff --git a/tests/auto/other/qaccessibilitylinux/CMakeLists.txt b/tests/auto/other/qaccessibilitylinux/CMakeLists.txt index 533d08504a..905e68edc4 100644 --- a/tests/auto/other/qaccessibilitylinux/CMakeLists.txt +++ b/tests/auto/other/qaccessibilitylinux/CMakeLists.txt @@ -1,6 +1,7 @@ # Generated from qaccessibilitylinux.pro. # special case begin -if (NOT QT_FEATURE_accessibility OR NOT TARGET Qt::LinuxAccessibilitySupportPrivate) +if (NOT QT_FEATURE_accessibility OR NOT TARGET Qt::LinuxAccessibilitySupportPrivate + OR (QT_BUILD_STANDALONE_TESTS AND QT_WILL_INSTALL)) return() endif() # special case end