forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
1
tests/manual/cmakepresets/msvc-toolchain.cmake
Normal file
1
tests/manual/cmakepresets/msvc-toolchain.cmake
Normal file
@@ -0,0 +1 @@
|
||||
include($ENV{SYSTEMDRIVE}/Qt/$ENV{QT_VERSION}/msvc2019_64/lib/cmake/Qt6/qt.toolchain.cmake)
|
Reference in New Issue
Block a user