forked from qt-creator/qt-creator
CMakePM: Add installDir CMakePresets support
Is part of CMakePrests v3, and slipped at the implementation time. Task-number: QTCREATORBUG-24555 Change-Id: Id3ce90c0a979d44287fc03ae1dd49a64e964cdf2 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -253,6 +253,44 @@ void updateToolchainFile(
|
||||
configurePreset.cacheVariables = cache;
|
||||
}
|
||||
|
||||
void updateInstallDir(PresetsDetails::ConfigurePreset &configurePreset,
|
||||
const Utils::Environment &env,
|
||||
const Utils::FilePath &sourceDirectory)
|
||||
{
|
||||
if (!configurePreset.installDir)
|
||||
return;
|
||||
|
||||
QString installDirString = configurePreset.installDir.value();
|
||||
CMakePresets::Macros::expand(configurePreset, env, sourceDirectory, installDirString);
|
||||
|
||||
// Resolve the relative path first to source and afterwards to build directory
|
||||
Utils::FilePath installDir = Utils::FilePath::fromString(installDirString);
|
||||
if (installDir.isRelativePath()) {
|
||||
Utils::FilePath probePath = sourceDirectory.resolvePath(installDir);
|
||||
if (probePath != sourceDirectory) {
|
||||
installDir = probePath;
|
||||
}
|
||||
}
|
||||
installDirString = installDir.cleanPath().toString();
|
||||
|
||||
// installDir takes precedence to CMAKE_INSTALL_PREFIX
|
||||
CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value()
|
||||
: CMakeConfig();
|
||||
|
||||
auto it = std::find_if(cache.begin(), cache.end(), [](const CMakeConfigItem &item) {
|
||||
return item.key == "CMAKE_INSTALL_PREFIX";
|
||||
});
|
||||
if (it != cache.end())
|
||||
it->value = installDirString.toUtf8();
|
||||
else
|
||||
cache << CMakeConfigItem("CMAKE_INSTALL_PREFIX",
|
||||
CMakeConfigItem::PATH,
|
||||
installDirString.toUtf8());
|
||||
|
||||
configurePreset.cacheVariables = cache;
|
||||
}
|
||||
|
||||
|
||||
template<class PresetType>
|
||||
void expandConditionValues(const PresetType &preset,
|
||||
const Utils::Environment &env,
|
||||
|
||||
Reference in New Issue
Block a user