forked from qt-creator/qt-creator
CMakePM: Use architecture and toolset for project import
This fixes issues with Visual C++ generator, which needs the right parameters to pinpoint the right compilers. Also use CMAKE_TOOLCHAIN_FILE for qmake detection. Change-Id: I6edc84c7ed1a892fbc5545ff61dc06ac20720f0a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -165,6 +165,14 @@ static CMakeConfig configurationFromPresetProbe(
|
|||||||
args.emplace_back("-G");
|
args.emplace_back("-G");
|
||||||
args.emplace_back(configurePreset.generator.value());
|
args.emplace_back(configurePreset.generator.value());
|
||||||
}
|
}
|
||||||
|
if (configurePreset.architecture && configurePreset.architecture.value().value) {
|
||||||
|
args.emplace_back("-A");
|
||||||
|
args.emplace_back(configurePreset.architecture.value().value.value());
|
||||||
|
}
|
||||||
|
if (configurePreset.toolset && configurePreset.toolset.value().value) {
|
||||||
|
args.emplace_back("-T");
|
||||||
|
args.emplace_back(configurePreset.toolset.value().value.value());
|
||||||
|
}
|
||||||
|
|
||||||
if (configurePreset.cacheVariables) {
|
if (configurePreset.cacheVariables) {
|
||||||
const CMakeConfig cache = configurePreset.cacheVariables
|
const CMakeConfig cache = configurePreset.cacheVariables
|
||||||
@@ -233,7 +241,9 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
|
|||||||
prefixPath = config.stringValueOf("CMAKE_PREFIX_PATH");
|
prefixPath = config.stringValueOf("CMAKE_PREFIX_PATH");
|
||||||
}
|
}
|
||||||
qCDebug(cmInputLog) << "PrefixPath:" << prefixPath;
|
qCDebug(cmInputLog) << "PrefixPath:" << prefixPath;
|
||||||
if (prefixPath.isEmpty())
|
|
||||||
|
FilePath toolchainFile = config.filePathValueOf(QByteArray("CMAKE_TOOLCHAIN_FILE"));
|
||||||
|
if (prefixPath.isEmpty() && toolchainFile.isEmpty())
|
||||||
return FilePath();
|
return FilePath();
|
||||||
|
|
||||||
// Run a CMake project that would do qmake probing
|
// Run a CMake project that would do qmake probing
|
||||||
@@ -284,9 +294,10 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
|
|||||||
cmake.setTimeOutMessageBoxEnabled(false);
|
cmake.setTimeOutMessageBoxEnabled(false);
|
||||||
|
|
||||||
QString cmakeGenerator = config.stringValueOf(QByteArray("CMAKE_GENERATOR"));
|
QString cmakeGenerator = config.stringValueOf(QByteArray("CMAKE_GENERATOR"));
|
||||||
|
QString cmakeGeneratorPlatform = config.stringValueOf(QByteArray("CMAKE_GENERATOR_PLATFORM"));
|
||||||
|
QString cmakeGeneratorToolset = config.stringValueOf(QByteArray("CMAKE_GENERATOR_TOOLSET"));
|
||||||
FilePath cmakeExecutable = config.filePathValueOf(QByteArray("CMAKE_COMMAND"));
|
FilePath cmakeExecutable = config.filePathValueOf(QByteArray("CMAKE_COMMAND"));
|
||||||
FilePath cmakeMakeProgram = config.filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"));
|
FilePath cmakeMakeProgram = config.filePathValueOf(QByteArray("CMAKE_MAKE_PROGRAM"));
|
||||||
FilePath toolchainFile = config.filePathValueOf(QByteArray("CMAKE_TOOLCHAIN_FILE"));
|
|
||||||
FilePath hostPath = config.filePathValueOf(QByteArray("QT_HOST_PATH"));
|
FilePath hostPath = config.filePathValueOf(QByteArray("QT_HOST_PATH"));
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
@@ -296,6 +307,14 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
|
|||||||
args.push_back(qtcQMakeProbeDir.filePath("build").path());
|
args.push_back(qtcQMakeProbeDir.filePath("build").path());
|
||||||
args.push_back("-G");
|
args.push_back("-G");
|
||||||
args.push_back(cmakeGenerator);
|
args.push_back(cmakeGenerator);
|
||||||
|
if (!cmakeGeneratorPlatform.isEmpty()) {
|
||||||
|
args.push_back("-A");
|
||||||
|
args.push_back(cmakeGeneratorPlatform);
|
||||||
|
}
|
||||||
|
if (!cmakeGeneratorToolset.isEmpty()) {
|
||||||
|
args.push_back("-T");
|
||||||
|
args.push_back(cmakeGeneratorToolset);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cmakeMakeProgram.isEmpty()) {
|
if (!cmakeMakeProgram.isEmpty()) {
|
||||||
args.push_back(QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.toString()));
|
args.push_back(QStringLiteral("-DCMAKE_MAKE_PROGRAM=%1").arg(cmakeMakeProgram.toString()));
|
||||||
@@ -303,6 +322,7 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config)
|
|||||||
if (toolchainFile.isEmpty()) {
|
if (toolchainFile.isEmpty()) {
|
||||||
args.push_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
|
args.push_back(QStringLiteral("-DCMAKE_PREFIX_PATH=%1").arg(prefixPath));
|
||||||
} else {
|
} else {
|
||||||
|
if (!prefixPath.isEmpty())
|
||||||
args.push_back(QStringLiteral("-DCMAKE_FIND_ROOT_PATH=%1").arg(prefixPath));
|
args.push_back(QStringLiteral("-DCMAKE_FIND_ROOT_PATH=%1").arg(prefixPath));
|
||||||
args.push_back(QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.toString()));
|
args.push_back(QStringLiteral("-DCMAKE_TOOLCHAIN_FILE=%1").arg(toolchainFile.toString()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user