Commit ddd9c0fd authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Don't crash when a broken add_executable is found

BUG: 325546
parent e889c2b7
......@@ -443,8 +443,9 @@ CMakeProjectVisitor::VisitorState CMakeProjectVisitor::stackTop() const
return p;
}
void CMakeProjectVisitor::defineTarget(const QString& id, const QStringList& sources, Target::Type t)
void CMakeProjectVisitor::defineTarget(const QString& _id, const QStringList& sources, Target::Type t)
{
QString id = _id.isEmpty() ? "<wrong-target>" : _id;
kDebug(9042) << "Defining target" << id;
if (m_targetForId.contains(id))
kDebug(9032) << "warning! there already was a target called" << id;
......@@ -484,12 +485,12 @@ void CMakeProjectVisitor::defineTarget(const QString& id, const QStringList& sou
}
Target target;
target.name=id.isEmpty() ? "<wrong-target>" : id;
target.name=id;
target.declaration=IndexedDeclaration(d);
target.files=sources;
target.type=t;
target.desc=p.code->at(p.line);
m_targetForId[id]=target;
m_targetForId[target.name]=target;
targetProps["OUTPUT_NAME"] = QStringList(exe);
targetProps["LOCATION"] = QStringList(locationDir+'/'+exe);
......
......@@ -256,3 +256,8 @@ void CMakeManagerTest::testConditionsInSubdirectoryBasedOnRootVariables()
QList< ProjectBaseItem* > subdirectoryFooItems = project->itemsForUrl(subdirectoryFooCpp);
QCOMPARE(subdirectoryFooItems.size(), 4); // three items for the targets, one item for the plain file
}
void CMakeManagerTest::testFaultyTarget()
{
loadProject("faulty_target");
}
......@@ -47,6 +47,7 @@ private slots:
void testCustomTargetSources();
void testConditionsInSubdirectoryBasedOnRootVariables();
void testQt5App();
void testFaultyTarget();
};
#endif // CMAKEMANAGERTEST_H
[Project]
Manager=KDevCMakeManager
Name=faulty_target
add_executable(docbook_analitzacommands main.cpp)
add_executable(caca ${dsadsad})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment