diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 596df19c8364f3a26f3f23a7797b0966581a693f..59537b8c87218e107da4dd0267e3d7996746fefd 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -204,6 +204,11 @@ bool CMakeProject::parseCMakeLists()
     CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
     QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
 
+    if (cbpFile.isEmpty()) {
+        emit buildTargetsChanged();
+        return false;
+    }
+
     // setFolderName
     m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName());
     CMakeCbpParser cbpparser;
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 76064be1e057311ecc8b131440d9691dab06179c..a9df983f5464b1218236191ff8e46a83c96e13e7 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -49,6 +49,7 @@
 #include <QtCore/QtConcurrentRun>
 #include <QtCore/QCoreApplication>
 #include <QtCore/QSettings>
+#include <QtCore/QDateTime>
 #include <QtGui/QFormLayout>
 #include <QtGui/QBoxLayout>
 #include <QtGui/QDesktopServices>
@@ -200,11 +201,18 @@ QString CMakeManager::findCbpFile(const QDir &directory)
     //   TODO the cbp file is named like the project() command in the CMakeList.txt file
     //   so this method below could find the wrong cbp file, if the user changes the project()
     //   2name
+    QDateTime t;
+    QString file;
     foreach (const QString &cbpFile , directory.entryList()) {
-        if (cbpFile.endsWith(QLatin1String(".cbp")))
-            return directory.path() + QLatin1Char('/') + cbpFile;
+        if (cbpFile.endsWith(QLatin1String(".cbp"))) {
+            QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
+            if (t.isNull() || fi.lastModified() > t) {
+                file = directory.path() + QLatin1Char('/') + cbpFile;
+                t = fi.lastModified();
+            }
+        }
     }
-    return QString();
+    return file;
 }
 
 // This code is duplicated from qtversionmanager