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);
|
Utils::FilePath toolchainFile = Utils::FilePath::fromString(toolchainFileName);
|
||||||
if (toolchainFile.isRelativePath()) {
|
if (toolchainFile.isRelativePath()) {
|
||||||
for (const auto &path : {sourceDirectory, buildDirectory}) {
|
for (const auto &path : {sourceDirectory, buildDirectory}) {
|
||||||
Utils::FilePath probePath = toolchainFile.resolvePath(path);
|
Utils::FilePath probePath = path.resolvePath(toolchainFile);
|
||||||
if (probePath.exists() && probePath != path) {
|
if (probePath.exists() && probePath != path) {
|
||||||
toolchainFile = probePath;
|
toolchainFile = probePath;
|
||||||
break;
|
break;
|
||||||
@@ -231,6 +231,8 @@ void updateToolchainFile(
|
|||||||
if (!toolchainFile.exists())
|
if (!toolchainFile.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const QString toolchainFileString = toolchainFile.cleanPath().toString();
|
||||||
|
|
||||||
// toolchainFile takes precedence to CMAKE_TOOLCHAIN_FILE
|
// toolchainFile takes precedence to CMAKE_TOOLCHAIN_FILE
|
||||||
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
|
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
|
||||||
: CMakeConfig();
|
: CMakeConfig();
|
||||||
@@ -239,11 +241,11 @@ void updateToolchainFile(
|
|||||||
return item.key == "CMAKE_TOOLCHAIN_FILE";
|
return item.key == "CMAKE_TOOLCHAIN_FILE";
|
||||||
});
|
});
|
||||||
if (it != cache.end())
|
if (it != cache.end())
|
||||||
it->value = toolchainFile.toString().toUtf8();
|
it->value = toolchainFileString.toUtf8();
|
||||||
else
|
else
|
||||||
cache << CMakeConfigItem("CMAKE_TOOLCHAIN_FILE",
|
cache << CMakeConfigItem("CMAKE_TOOLCHAIN_FILE",
|
||||||
CMakeConfigItem::FILEPATH,
|
CMakeConfigItem::FILEPATH,
|
||||||
toolchainFile.toString().toUtf8());
|
toolchainFileString.toUtf8());
|
||||||
|
|
||||||
configurePreset.cacheVariables = cache;
|
configurePreset.cacheVariables = cache;
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
"architecture" : {
|
"architecture" : {
|
||||||
"value": "x64"
|
"value": "x64"
|
||||||
},
|
},
|
||||||
"toolchainFile" : "c:/Qt/6.3.2/msvc2019_64/lib/cmake/Qt6/qt.toolchain.cmake",
|
"toolchainFile" : "../cmakepresets/msvc-toolchain.cmake",
|
||||||
"condition" : {
|
"condition" : {
|
||||||
"type": "not",
|
"type": "not",
|
||||||
"condition": {
|
"condition": {
|
||||||
@@ -55,7 +55,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"environment" : {
|
"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