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 <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-03-26 10:31:22 +01:00
parent 91c60f25e0
commit 5a93c457e5
2 changed files with 21 additions and 6 deletions

View File

@ -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}"

View File

@ -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<std::string *, 8> paths = {
&m_sourceDir, &m_binaryDir, &m_includeDir, &m_privateIncludeDir,
&m_qpaIncludeDir, &m_rhiIncludeDir, &m_stagingDir,
&m_versionScriptFile,
const std::array<std::string *, 9> 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