From 5a93c457e5b7bdbd79144270ddceb60a6f36c6de Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 26 Mar 2025 10:31:22 +0100 Subject: [PATCH] Teach syncqt to look for module headers in install path If we build the specific module against installed Qt syncqt cannot detect the installed module headers, since it only checks the build paths. This adds the installIncludeDir argument for syncqt so it now attempts looking for the included header file in Qt install path. This will raise early warnings in Qt per-module builds too, but not only when building top-level Qt or for non-prefixed builds. Pick-to: 6.5 6.8 6.9 Change-Id: I5a28ec35a776b5b39f4a8923c9bf91e857f45e4a Reviewed-by: Alexandru Croitor --- cmake/QtSyncQtHelpers.cmake | 8 ++++++++ src/tools/syncqt/main.cpp | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cmake/QtSyncQtHelpers.cmake b/cmake/QtSyncQtHelpers.cmake index 76a88954901..9cdad4c07c2 100644 --- a/cmake/QtSyncQtHelpers.cmake +++ b/cmake/QtSyncQtHelpers.cmake @@ -84,6 +84,13 @@ function(qt_internal_target_sync_headers target # std::filesystem API get_filename_component(source_dir_real "${sync_source_directory}" REALPATH) get_filename_component(binary_dir_real "${CMAKE_CURRENT_BINARY_DIR}" REALPATH) + if(QT6_INSTALL_PREFIX) + get_filename_component(install_dir_real "${QT6_INSTALL_PREFIX}" REALPATH) + set(install_include_dir_argument + -installIncludeDir "${install_dir_real}/${QT6_INSTALL_HEADERS}") + else() + set(install_include_dir_argument "") + endif() if(QT_REPO_PUBLIC_NAMESPACE_REGEX) set(public_namespaces_filter -publicNamespaceFilter "${QT_REPO_PUBLIC_NAMESPACE_REGEX}") @@ -113,6 +120,7 @@ function(qt_internal_target_sync_headers target -binaryDir "${binary_dir_real}" -privateHeadersFilter "${private_filter_regex}" -includeDir "${module_build_interface_include_dir}" + ${install_include_dir_argument} -privateIncludeDir "${module_build_interface_private_include_dir}" -qpaIncludeDir "${module_build_interface_qpa_include_dir}" -rhiIncludeDir "${module_build_interface_rhi_include_dir}" diff --git a/src/tools/syncqt/main.cpp b/src/tools/syncqt/main.cpp index ab646e6cd14..be14700f6f0 100644 --- a/src/tools/syncqt/main.cpp +++ b/src/tools/syncqt/main.cpp @@ -205,6 +205,8 @@ public: const std::string &includeDir() const { return m_includeDir; } + const std::string &installIncludeDir() const { return m_installIncludeDir; } + const std::string &privateIncludeDir() const { return m_privateIncludeDir; } const std::string &qpaIncludeDir() const { return m_qpaIncludeDir; } @@ -339,6 +341,7 @@ private: { "-module", { &m_moduleName } }, { "-sourceDir", { &m_sourceDir } }, { "-binaryDir", { &m_binaryDir } }, + { "-installIncludeDir", { &m_installIncludeDir, true } }, { "-privateHeadersFilter", { &privateHeadersFilter, true } }, { "-qpaHeadersFilter", { &qpaHeadersFilter, true } }, { "-rhiHeadersFilter", { &rhiHeadersFilter, true } }, @@ -499,10 +502,10 @@ private: // Convert all paths from command line to a generic one. void normilizePaths() { - static std::array paths = { - &m_sourceDir, &m_binaryDir, &m_includeDir, &m_privateIncludeDir, - &m_qpaIncludeDir, &m_rhiIncludeDir, &m_stagingDir, - &m_versionScriptFile, + const std::array paths = { + &m_sourceDir, &m_binaryDir, &m_includeDir, + &m_installIncludeDir, &m_privateIncludeDir, &m_qpaIncludeDir, + &m_rhiIncludeDir, &m_stagingDir, &m_versionScriptFile, }; for (auto path : paths) { if (!path->empty()) @@ -514,6 +517,7 @@ private: std::string m_sourceDir; std::string m_binaryDir; std::string m_includeDir; + std::string m_installIncludeDir; std::string m_privateIncludeDir; std::string m_qpaIncludeDir; std::string m_rhiIncludeDir; @@ -1328,8 +1332,11 @@ public: } for (const auto &module : m_commandLineArgs->knownModules()) { std::string suggestedHeader = "Qt" + module + '/' + includedHeader; - if (std::filesystem::exists(m_commandLineArgs->includeDir() + "/../" - + suggestedHeader)) { + const std::string suggestedHeaderReversePath = "/../" + suggestedHeader; + if (std::filesystem::exists(m_commandLineArgs->includeDir() + + suggestedHeaderReversePath) + || std::filesystem::exists(m_commandLineArgs->installIncludeDir() + + '/' + suggestedHeader)) { faults |= IncludeChecks; std::cerr << m_warningMessagePreamble << m_currentFileString << ":" << m_currentFileLineNumber