diff options
author | Cristian Adam <cristian.adam@qt.io> | 2023-10-22 14:22:20 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2023-10-24 09:13:50 +0000 |
commit | 5e3d14e2e932da0a3dc3314d2802bc3df0dc504c (patch) | |
tree | b240261265ab8a41f7464becd00659b676c03483 | |
parent | 0fe891678a9d47b4bc956edba911659bd22d9bb8 (diff) |
CMakePM: Allow CMAKE_SYSROOT to be taken from the CMake preset probe
One could have a toolchainfile that sets the CMAKE_SYSROOT. We need to
be able to read the value later, and not just from the CMake Presets
cmakeCache array.
Task-number: QTCREATORBUG-29643
Change-Id: I63697219195b043813516c8214329ce583dc0676
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 74d5056bf7..b8748bc6f9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -264,6 +264,7 @@ static CMakeConfig configurationFromPresetProbe( const QString prefixPath = cache.stringValueOf("CMAKE_PREFIX_PATH"); const QString findRootPath = cache.stringValueOf("CMAKE_FIND_ROOT_PATH"); const QString qtHostPath = cache.stringValueOf("QT_HOST_PATH"); + const QString sysRoot = cache.stringValueOf("CMAKE_SYSROOT"); if (!cmakeMakeProgram.isEmpty()) { args.emplace_back( @@ -282,6 +283,9 @@ static CMakeConfig configurationFromPresetProbe( if (!qtHostPath.isEmpty()) { args.emplace_back(QStringLiteral("-DQT_HOST_PATH=%1").arg(qtHostPath)); } + if (!sysRoot.isEmpty()) { + args.emplace_back(QStringLiteral("-DCMAKE_SYSROOT=%1").arg(sysRoot)); + } } qCDebug(cmInputLog) << "CMake probing for compilers: " << cmakeExecutable.toUserOutput() @@ -745,9 +749,6 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath, const CMakeConfig cache = configurePreset.cacheVariables ? configurePreset.cacheVariables.value() : CMakeConfig(); - - data->sysroot = cache.filePathValueOf("CMAKE_SYSROOT"); - CMakeConfig config; const bool noCompilers = cache.valueOf("CMAKE_C_COMPILER").isEmpty() && cache.valueOf("CMAKE_CXX_COMPILER").isEmpty(); @@ -778,6 +779,8 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath, configurePreset.generator.value().toUtf8()); } + data->sysroot = config.filePathValueOf("CMAKE_SYSROOT"); + const auto [qmake, cmakePrefixPath] = qtInfoFromCMakeCache(config, env); if (!qmake.isEmpty()) data->qt = findOrCreateQtVersion(qmake); |