add API to query build type (unknown, release, debug) to BuildConfiguration

Merge-request: 261
Reviewed-by: dt <qtc-committer@nokia.com>
This commit is contained in:
Milian Wolff
2011-03-03 16:12:00 +01:00
committed by dt
parent 0ecd80c6c5
commit d6ea2945f0
7 changed files with 61 additions and 0 deletions

View File

@@ -273,3 +273,36 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer
delete bc;
return 0;
}
ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
{
QString cmakeBuildType;
QFile cmakeCache(buildDirectory() + "/CMakeCache.txt");
if (cmakeCache.open(QIODevice::ReadOnly)) {
while (!cmakeCache.atEnd()) {
QString line = cmakeCache.readLine();
if (line.startsWith("CMAKE_BUILD_TYPE")) {
if (int pos = line.indexOf('=')) {
cmakeBuildType = line.mid(pos + 1).trimmed();
}
break;
}
}
cmakeCache.close();
}
// Cover all common CMake build types
if (cmakeBuildType.compare("Release", Qt::CaseInsensitive) == 0
|| cmakeBuildType.compare("MinSizeRel", Qt::CaseInsensitive) == 0)
{
return Release;
} else if (cmakeBuildType.compare("Debug", Qt::CaseInsensitive) == 0
|| cmakeBuildType.compare("debugfull", Qt::CaseInsensitive) == 0
|| cmakeBuildType.compare("RelWithDebInfo", Qt::CaseInsensitive) == 0)
{
return Debug;
}
return Unknown;
}