diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
index 80b15b4c94b471979be597db48bc6b7fb01e7982..c49ae2dbbe697cf6c4e49ba45807e18c5757ae7c 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
@@ -55,6 +55,8 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
     m_ui.buttonBox->button(QDialogButtonBox::Save)->setFocus(Qt::TabFocusReason);
     m_ui.buttonBox->button(QDialogButtonBox::Save)->setMinimumWidth(130); // bad magic number to avoid resizing of button
 
+    m_ui.saveBeforeBuildCheckBox->setVisible(false);
+
     foreach (IFile *file, items) {
         QString visibleName;
         QString directory;
@@ -121,3 +123,14 @@ QList<IFile*> SaveItemsDialog::itemsToSave() const
 {
     return m_itemsToSave;
 }
+
+void SaveItemsDialog::setAlwaysSaveMessage(const QString &msg)
+{
+    m_ui.saveBeforeBuildCheckBox->setText(msg);
+    m_ui.saveBeforeBuildCheckBox->setVisible(true);
+}
+
+bool SaveItemsDialog::alwaysSaveChecked()
+{
+    return m_ui.saveBeforeBuildCheckBox->isChecked();
+}
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.h b/src/plugins/coreplugin/dialogs/saveitemsdialog.h
index ff22baa1f66fa04eb1c4d1432ed3aab199a61b66..237db0d752d63bdc36fa2dd10741cd358586bc6e 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.h
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.h
@@ -57,7 +57,8 @@ public:
         QList<Core::IFile *> items);
 
     void setMessage(const QString &msg);
-
+    void setAlwaysSaveMessage(const QString &msg);
+    bool alwaysSaveChecked();
     QList<Core::IFile *> itemsToSave() const;
 
 private slots:
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.ui b/src/plugins/coreplugin/dialogs/saveitemsdialog.ui
index 966be8f4f303261e840bec53bf4dbf44c8e49c7c..6f37a47ddda003b1ed3ba41be87bd8c0536f8dd9 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.ui
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.ui
@@ -56,6 +56,13 @@
      </column>
     </widget>
    </item>
+   <item>
+    <widget class="QCheckBox" name="saveBeforeBuildCheckBox">
+     <property name="text">
+      <string>Automatically save all Files before building</string>
+     </property>
+    </widget>
+   </item>
    <item>
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp
index 5a9276fd85183df55134fd13eb0cefa253c076d0..b42611b2217c28fd829ee6de8dbc4b95949b84f3 100644
--- a/src/plugins/coreplugin/filemanager.cpp
+++ b/src/plugins/coreplugin/filemanager.cpp
@@ -292,9 +292,11 @@ QList<IFile *> FileManager::saveModifiedFilesSilently(const QList<IFile *> &file
     Asks the user whether to save the files listed in \a files . Returns the files that have not been saved.
 */
 QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
-                                                     bool *cancelled, const QString &message)
+                                              bool *cancelled, const QString &message,
+                                              const QString &alwaysSaveMessage,
+                                              bool *alwaysSave)
 {
-    return saveModifiedFiles(files, cancelled, false, message);
+    return saveModifiedFiles(files, cancelled, false, message, alwaysSaveMessage, alwaysSave);
 }
 
 static QMessageBox::StandardButton skipFailedPrompt(QWidget *parent, const QString &fileName)
@@ -307,7 +309,11 @@ static QMessageBox::StandardButton skipFailedPrompt(QWidget *parent, const QStri
 }
 
 QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
-                                                     bool *cancelled, bool silently, const QString &message)
+                                              bool *cancelled,
+                                              bool silently,
+                                              const QString &message,
+                                              const QString &alwaysSaveMessage,
+                                              bool *alwaysSave)
 {
     if (cancelled)
         (*cancelled) = false;
@@ -338,12 +344,18 @@ QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
             SaveItemsDialog dia(m_mainWindow, modifiedFiles);
             if (!message.isEmpty())
                 dia.setMessage(message);
+            if (!alwaysSaveMessage.isNull())
+                dia.setAlwaysSaveMessage(alwaysSaveMessage);
             if (dia.exec() != QDialog::Accepted) {
                 if (cancelled)
                     (*cancelled) = true;
+                if (alwaysSave)
+                    *alwaysSave = dia.alwaysSaveChecked();
                 notSaved = modifiedFiles;
                 return notSaved;
             }
+            if (alwaysSave)
+                *alwaysSave = dia.alwaysSaveChecked();
             filesToSave = dia.itemsToSave();
         }
 
diff --git a/src/plugins/coreplugin/filemanager.h b/src/plugins/coreplugin/filemanager.h
index 52dafe4ca882556b78f49aa82959d9df6543a923..6be80514fd8f0c9cc3acc926ea8f37504afd7fe6 100644
--- a/src/plugins/coreplugin/filemanager.h
+++ b/src/plugins/coreplugin/filemanager.h
@@ -97,7 +97,9 @@ public:
     QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files);
     QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
                                      bool *cancelled = 0,
-                                     const QString &message = QString());
+                                     const QString &message = QString(),
+                                     const QString &alwaysSaveMessage = QString::null,
+                                     bool *alwaysSave = 0);
 
 signals:
     void currentFileChanged(const QString &filePath);
@@ -116,7 +118,10 @@ private:
     void updateFileInfo(IFile *file);
 
     QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
-                               bool *cancelled, bool silently, const QString &message);
+                               bool *cancelled, bool silently,
+                               const QString &message,
+                               const QString &alwaysSaveMessage = QString::null,
+                               bool *alwaysSave = 0);
 
     QMap<IFile*, FileInfo> m_managedFiles;
 
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 4dbf49d75612e28a4c9a9ce659ea4d71871283fb..eae61dd93b120be2310b7d8377ae0459822a5834 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1324,10 +1324,14 @@ bool ProjectExplorerPlugin::saveModifiedFiles(const QList<Project *> & projects)
             Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave);
         } else {
             bool cancelled = false;
-            Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled);
+            bool alwaysSave = false;
+            Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave, &cancelled, QString::null, "Always save files before build", &alwaysSave);
             if (cancelled) {
                 return false;
             }
+            if (alwaysSave) {
+                m_projectExplorerSettings.saveBeforeBuild = true;
+            }
         }
     }
     return true;