CMakePM: Fix Qt detection for Presets with toolchain file

When CMAKE_TOOLCHAIN_FILE and CMAKE_PREFIX_PATH were both set, the later
was ignored.

This resulted in Kits being created without Qt and without Qml
Debugging.

Task-number: QTCREATORBUG-28982
Change-Id: Ib45b4ac8335391f85a0b9c321196597d1c0a7a3f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Cristian Adam
2023-05-19 15:21:51 +02:00
parent bf4934feb9
commit 0d3d4892c6

View File

@@ -330,6 +330,7 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
FilePath cmakeExecutable = config.filePathValueOf(QByteArray("CMAKE_COMMAND"));
FilePath cmakeMakeProgram = config.filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"));
FilePath hostPath = config.filePathValueOf(QByteArray("QT_HOST_PATH"));
const QString findRootPath = config.stringValueOf("CMAKE_FIND_ROOT_PATH");
QStringList args;
args.push_back("-S");
@@ -350,13 +351,16 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
if (!cmakeMakeProgram.isEmpty()) {
args.push_back(QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.toString()));
}
if (toolchainFile.isEmpty()) {
args.push_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
} else {
if (!prefixPath.isEmpty())
args.push_back(QStringLiteral("-DCMAKE_FIND_ROOT_PATH=%1").arg(prefixPath));
if (!toolchainFile.isEmpty()) {
args.push_back(QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.toString()));
}
if (!prefixPath.isEmpty()) {
args.push_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
}
if (!findRootPath.isEmpty()) {
args.push_back(QStringLiteral("-DCMAKE_FIND_ROOT_PATH=%1").arg(findRootPath));
}
if (!hostPath.isEmpty()) {
args.push_back(QStringLiteral("-DQT_HOST_PATH=%1").arg(hostPath.toString()));
}