2009-11-23 12:11:48 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
2009-11-23 13:29:45 +01:00
|
|
|
#include "cmakeproject.h"
|
2009-11-25 18:50:20 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2009-11-23 13:29:45 +01:00
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace Internal;
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro)
|
2009-12-08 12:21:11 +01:00
|
|
|
: BuildConfiguration(pro),
|
|
|
|
|
m_toolChain(0),
|
|
|
|
|
m_clearSystemEnvironment(false)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 12:21:11 +01:00
|
|
|
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro, const QMap<QString, QVariant> &map)
|
|
|
|
|
: BuildConfiguration(pro, map),
|
|
|
|
|
m_toolChain(0)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
|
|
|
|
|
2009-12-08 12:21:11 +01:00
|
|
|
QMap<QString, QVariant>::const_iterator it = map.constFind("clearSystemEnvironment");
|
|
|
|
|
m_clearSystemEnvironment = (it != map.constEnd() && it.value().toBool());
|
|
|
|
|
m_userEnvironmentChanges =
|
|
|
|
|
ProjectExplorer::EnvironmentItem::fromStringList(
|
|
|
|
|
map.value("userEnvironmentChanges").toStringList());
|
|
|
|
|
m_msvcVersion = map.value("msvcVersion").toString();
|
|
|
|
|
m_buildDirectory = map.value("buildDirectory").toString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeBuildConfiguration *source)
|
|
|
|
|
: BuildConfiguration(source),
|
|
|
|
|
m_toolChain(0),
|
|
|
|
|
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
|
|
|
|
|
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
|
|
|
|
|
m_buildDirectory(source->m_buildDirectory),
|
|
|
|
|
m_msvcVersion(source->m_msvcVersion)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildConfiguration::toMap(QMap<QString, QVariant> &map) const
|
|
|
|
|
{
|
|
|
|
|
map.insert("userEnvironmentChanges",
|
|
|
|
|
ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
|
|
|
|
map.insert("msvcVersion", m_msvcVersion);
|
|
|
|
|
map.insert("buildDirectory", m_buildDirectory);
|
|
|
|
|
BuildConfiguration::toMap(map);
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
2009-11-23 13:29:45 +01:00
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
CMakeBuildConfiguration::~CMakeBuildConfiguration()
|
|
|
|
|
{
|
|
|
|
|
delete m_toolChain;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeProject *CMakeBuildConfiguration::cmakeProject() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<CMakeProject *>(project());
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
ProjectExplorer::Environment CMakeBuildConfiguration::baseEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::Environment env = useSystemEnvironment() ?
|
|
|
|
|
ProjectExplorer::Environment(QProcess::systemEnvironment()) :
|
|
|
|
|
ProjectExplorer::Environment();
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Environment CMakeBuildConfiguration::environment() const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::Environment env = baseEnvironment();
|
|
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildConfiguration::setUseSystemEnvironment(bool b)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (b == m_clearSystemEnvironment)
|
2009-11-25 18:50:20 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_clearSystemEnvironment = !b;
|
2009-11-25 18:50:20 +01:00
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeBuildConfiguration::useSystemEnvironment() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return !m_clearSystemEnvironment;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<ProjectExplorer::EnvironmentItem> CMakeBuildConfiguration::userEnvironmentChanges() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_userEnvironmentChanges;
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_userEnvironmentChanges == diff)
|
2009-11-25 18:50:20 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_userEnvironmentChanges = diff;
|
2009-11-25 18:50:20 +01:00
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeBuildConfiguration::buildDirectory() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
QString buildDirectory = m_buildDirectory;
|
2009-11-25 18:50:20 +01:00
|
|
|
if (buildDirectory.isEmpty())
|
2009-11-26 14:43:27 +01:00
|
|
|
buildDirectory = cmakeProject()->sourceDirectory() + "/qtcreator-build";
|
2009-11-25 18:50:20 +01:00
|
|
|
return buildDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain::ToolChainType CMakeBuildConfiguration::toolChainType() const
|
|
|
|
|
{
|
|
|
|
|
if (m_toolChain)
|
|
|
|
|
return m_toolChain->type();
|
|
|
|
|
return ProjectExplorer::ToolChain::UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain *CMakeBuildConfiguration::toolChain() const
|
|
|
|
|
{
|
2009-12-03 19:45:09 +01:00
|
|
|
updateToolChain();
|
2009-11-25 18:50:20 +01:00
|
|
|
return m_toolChain;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
void CMakeBuildConfiguration::updateToolChain() const
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
|
|
|
|
ProjectExplorer::ToolChain *newToolChain = 0;
|
2009-12-03 19:45:09 +01:00
|
|
|
if (msvcVersion().isEmpty()) {
|
2009-11-25 18:50:20 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
newToolChain = ProjectExplorer::ToolChain::createMinGWToolChain("gcc", QString());
|
|
|
|
|
#else
|
|
|
|
|
newToolChain = ProjectExplorer::ToolChain::createGccToolChain("gcc");
|
|
|
|
|
#endif
|
2009-12-03 19:45:09 +01:00
|
|
|
} else { // msvc
|
2009-12-08 12:21:11 +01:00
|
|
|
newToolChain = ProjectExplorer::ToolChain::createMSVCToolChain(m_msvcVersion, false);
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ProjectExplorer::ToolChain::equals(newToolChain, m_toolChain)) {
|
|
|
|
|
delete newToolChain;
|
|
|
|
|
newToolChain = 0;
|
|
|
|
|
} else {
|
|
|
|
|
delete m_toolChain;
|
|
|
|
|
m_toolChain = newToolChain;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_buildDirectory == buildDirectory)
|
2009-12-03 19:45:09 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_buildDirectory = buildDirectory;
|
2009-12-03 19:45:09 +01:00
|
|
|
emit buildDirectoryChanged();
|
|
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
QString CMakeBuildConfiguration::msvcVersion() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_msvcVersion;
|
2009-12-03 19:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildConfiguration::setMsvcVersion(const QString &msvcVersion)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_msvcVersion == msvcVersion)
|
2009-12-03 19:45:09 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_msvcVersion = msvcVersion;
|
2009-12-03 19:45:09 +01:00
|
|
|
updateToolChain();
|
|
|
|
|
|
|
|
|
|
emit msvcVersionChanged();
|
|
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|