diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index b3da6c688bde813411d74c53ba048f002e510c31..86c71af8e4cd906a5c7adfc270f648c0cbe950d7 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -104,8 +104,7 @@ void CMakeProject::fileChanged(const QString &fileName)
 
 void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
 {
-    CMakeTarget *target(qobject_cast<CMakeTarget *>(sender()));
-    if (!bc || !target || target != activeTarget())
+    if (!bc || bc->target() != activeTarget())
         return;
 
     CMakeBuildConfiguration * cmakebc(qobject_cast<CMakeBuildConfiguration *>(bc));