forked from qt-creator/qt-creator
CMakePM: Expand cache variables for the preset probe
This way the CMAKE_PREFIX_PATH set to $env{HOME}/Qt (Linux) or $env{SystemDrive}/Qt (Windows) would work as expected. Change-Id: I03a9102d6d1da2a8740cab738577c47c44166c6c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -197,19 +197,27 @@ static CMakeConfig configurationFromPresetProbe(
|
||||
const CMakeConfig cache = configurePreset.cacheVariables
|
||||
? configurePreset.cacheVariables.value()
|
||||
: CMakeConfig();
|
||||
const FilePath cmakeMakeProgram = cache.filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"));
|
||||
const FilePath toolchainFile = cache.filePathValueOf(QByteArray("CMAKE_TOOLCHAIN_FILE"));
|
||||
const QString prefixPath = cache.stringValueOf(QByteArray("CMAKE_PREFIX_PATH"));
|
||||
const QString findRootPath = cache.stringValueOf(QByteArray("CMAKE_FIND_ROOT_PATH"));
|
||||
const QString qtHostPath = cache.stringValueOf(QByteArray("QT_HOST_PATH"));
|
||||
|
||||
auto expandCacheValue =
|
||||
[configurePreset, env, importPath, cache](const QString &key) -> QString {
|
||||
QString result = cache.stringValueOf(key.toUtf8());
|
||||
CMakePresets::Macros::expand(configurePreset, env, importPath, result);
|
||||
return result;
|
||||
};
|
||||
|
||||
const QString cmakeMakeProgram = expandCacheValue("CMAKE_MAKE_PROGRAM");
|
||||
const QString toolchainFile = expandCacheValue("CMAKE_TOOLCHAIN_FILE");
|
||||
const QString prefixPath = expandCacheValue("CMAKE_PREFIX_PATH");
|
||||
const QString findRootPath = expandCacheValue("CMAKE_FIND_ROOT_PATH");
|
||||
const QString qtHostPath = expandCacheValue("QT_HOST_PATH");
|
||||
|
||||
if (!cmakeMakeProgram.isEmpty()) {
|
||||
args.emplace_back(
|
||||
QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.toString()));
|
||||
QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram));
|
||||
}
|
||||
if (!toolchainFile.isEmpty()) {
|
||||
args.emplace_back(
|
||||
QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.toString()));
|
||||
QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile));
|
||||
}
|
||||
if (!prefixPath.isEmpty()) {
|
||||
args.emplace_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
|
||||
|
@@ -12,7 +12,7 @@
|
||||
"generator": "Ninja",
|
||||
"installDir": "../inst-${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PREFIX_PATH": "c:/Qt/6.3.2/mingw_64"
|
||||
"CMAKE_PREFIX_PATH": "$env{SystemDrive}/Qt/6.3.2/mingw_64"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
@@ -20,7 +20,7 @@
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"environment": {
|
||||
"PATH": "c:/Qt/Tools/mingw1120_64/bin;$penv{PATH}"
|
||||
"PATH": "$env{SystemDrive}/Qt/Tools/mingw1120_64/bin;$penv{PATH}"
|
||||
},
|
||||
"debug" : {
|
||||
"find" : true
|
||||
@@ -34,7 +34,7 @@
|
||||
"inherits" : "mingw",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_PREFIX_PATH": "c:/Qt/6.3.2/mingw_64"
|
||||
"CMAKE_PREFIX_PATH": "$env{SystemDrive}/Qt/6.3.2/mingw_64"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user