diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2020-06-17 10:45:09 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2020-06-18 14:13:43 +0000 |
commit | 054f5617f838a78ebc81ae0d3e368aafeb3fc3c6 (patch) | |
tree | 59c9d616c2a209267c056138cd3009c0463df93b /src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp | |
parent | faf9c883f2f5772f074e3c13ebbde3057e4dfddf (diff) |
CMake: Make import of build directories using Qt 6 work
Make import of build directories using Qt 6 work. This assumes that
Qt 6 will use the same layout as Qt 5 and that there is qmake (which
is assumed everywhere in Creator right now).
Change-Id: I37194b186127befb3df32ebacf86c032c71ef18a
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index fc6b396997..4b768414f6 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -122,11 +122,18 @@ static Utils::FilePath qmakeFromCMakeCache(const CMakeConfig &config) return qmake; // Check Qt5 settings: oh, the horror! - const Utils::FilePath qtCMakeDir - = Utils::FilePath::fromUtf8(CMakeConfigItem::valueOf(QByteArray("Qt5Core_DIR"), config)); - qCDebug(cmInputLog()) << "Qt5Core_DIR=" << qtCMakeDir.toUserOutput(); + const Utils::FilePath qtCMakeDir = [config]() { + Utils::FilePath tmp = Utils::FilePath::fromUtf8( + CMakeConfigItem::valueOf(QByteArray("Qt5Core_DIR"), config)); + if (tmp.isEmpty()) { + tmp = Utils::FilePath::fromUtf8( + CMakeConfigItem::valueOf(QByteArray("Qt6Core_DIR"), config)); + } + return tmp; + }(); + qCDebug(cmInputLog()) << "QtXCore_DIR=" << qtCMakeDir.toUserOutput(); const Utils::FilePath canQtCMakeDir = Utils::FilePath::fromString(qtCMakeDir.toFileInfo().canonicalFilePath()); - qCInfo(cmInputLog()) << "Qt5Core_DIR (canonical)=" << canQtCMakeDir.toUserOutput(); + qCInfo(cmInputLog()) << "QtXCore_DIR (canonical)=" << canQtCMakeDir.toUserOutput(); if (qtCMakeDir.isEmpty()) return Utils::FilePath(); const Utils::FilePath baseQtDir = canQtCMakeDir.parentDir().parentDir().parentDir(); // Up 3 levels... @@ -147,8 +154,11 @@ static Utils::FilePath qmakeFromCMakeCache(const CMakeConfig &config) // endif() QFile extras(qtCMakeDir.toString() + "/Qt5CoreConfigExtras.cmake"); - if (!extras.open(QIODevice::ReadOnly)) - return Utils::FilePath(); + if (!extras.open(QIODevice::ReadOnly)) { + extras.setFileName(qtCMakeDir.toString() + "/Qt6CoreConfigExtras.cmake"); + if (!extras.open(QIODevice::ReadOnly)) + return Utils::FilePath(); + } QByteArray data; bool inQmakeSection = false; @@ -172,7 +182,8 @@ static Utils::FilePath qmakeFromCMakeCache(const CMakeConfig &config) line.replace(")", " ) "); line = line.simplified(); - if (line == "if ( NOT TARGET Qt5::qmake )") + if (line == "if ( NOT TARGET Qt5::qmake )" + || line == "if ( NOT TARGET Qt6::qmake )") inQmakeSection = true; if (!inQmakeSection) |