CMakePM: Proper handling of relative toolchain files in CMakePresets

Previously it was only tested with absolute paths.

Change-Id: I3871da60f3f1b17ae4d2d4cfb69d1be60da1435b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Cristian Adam
2022-10-24 12:48:49 +02:00
parent fb94873765
commit 4fdbfe1641
3 changed files with 9 additions and 5 deletions

View File

@@ -220,7 +220,7 @@ void updateToolchainFile(
Utils::FilePath toolchainFile = Utils::FilePath::fromString(toolchainFileName);
if (toolchainFile.isRelativePath()) {
for (const auto &path : {sourceDirectory, buildDirectory}) {
Utils::FilePath probePath = toolchainFile.resolvePath(path);
Utils::FilePath probePath = path.resolvePath(toolchainFile);
if (probePath.exists() && probePath != path) {
toolchainFile = probePath;
break;
@@ -231,6 +231,8 @@ void updateToolchainFile(
if (!toolchainFile.exists())
return;
const QString toolchainFileString = toolchainFile.cleanPath().toString();
// toolchainFile takes precedence to CMAKE_TOOLCHAIN_FILE
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
: CMakeConfig();
@@ -239,11 +241,11 @@ void updateToolchainFile(
return item.key == "CMAKE_TOOLCHAIN_FILE";
});
if (it != cache.end())
it->value = toolchainFile.toString().toUtf8();
it->value = toolchainFileString.toUtf8();
else
cache << CMakeConfigItem("CMAKE_TOOLCHAIN_FILE",
CMakeConfigItem::FILEPATH,
toolchainFile.toString().toUtf8());
toolchainFileString.toUtf8());
configurePreset.cacheVariables = cache;
}

View File

@@ -45,7 +45,7 @@
"architecture" : {
"value": "x64"
},
"toolchainFile" : "c:/Qt/6.3.2/msvc2019_64/lib/cmake/Qt6/qt.toolchain.cmake",
"toolchainFile" : "../cmakepresets/msvc-toolchain.cmake",
"condition" : {
"type": "not",
"condition": {
@@ -55,7 +55,8 @@
}
},
"environment" : {
"HOST_SYSTEM_NAME": "Windows"
"HOST_SYSTEM_NAME": "Windows",
"QT_VERSION": "6.3.2"
}
},
{

View File

@@ -0,0 +1 @@
include($ENV{SYSTEMDRIVE}/Qt/$ENV{QT_VERSION}/msvc2019_64/lib/cmake/Qt6/qt.toolchain.cmake)