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

Fix subdirectory scoping in cmake projects

Don't pop the scope until all the subdirectories have been processed.

Thanks to Daniel Calviño Sánchez for such a helpful bug report :)

BUG: 309687
CCBUG: 238455
parent 9963f6a9
......@@ -725,7 +725,6 @@ QStringList resolvePaths(const KUrl& baseUrl, const QStringList& pathsToResolve)
QList<KDevelop::ProjectFolderItem*> CMakeManager::parse( KDevelop::ProjectFolderItem* item )
{
Q_ASSERT(isReloading(item->project()));
QList<KDevelop::ProjectFolderItem*> folderList;
CMakeFolderItem* folder = dynamic_cast<CMakeFolderItem*>( item );
{
......@@ -763,7 +762,6 @@ QList<KDevelop::ProjectFolderItem*> CMakeManager::parse( KDevelop::ProjectFolder
data.vm.pushScope();
ReferencedTopDUContext ctx = includeScript(cmakeListsPath.toLocalFile(), folder->project(), item->url().toLocalFile(), curr);
data.vm.popScope();
folder->setTopDUContext(ctx);
/*{
kDebug() << "dumpiiiiiing" << folder->url();
......@@ -771,6 +769,7 @@ QList<KDevelop::ProjectFolderItem*> CMakeManager::parse( KDevelop::ProjectFolder
KDevelop::dumpDUContext(v.context(), false);
}*/
QList<KDevelop::ProjectFolderItem*> folderList;
QStringList alreadyAdded;
deleteAllLater(castToBase(folder->cleanupBuildFolders(data.subdirectories)));
foreach (const Subdirectory& subf, data.subdirectories)
......@@ -935,6 +934,10 @@ QList<KDevelop::ProjectFolderItem*> CMakeManager::parse( KDevelop::ProjectFolder
setTargetFiles(targetItem, tfiles);
}
foreach(KDevelop::ProjectFolderItem* item, folderList) {
parse(item);
}
data.vm.popScope();
} else if( folder ) {
// Only do cmake-stuff if its a cmake folder
deleteAllLater(castToBase(folder->cleanupBuildFolders(QList<Subdirectory>())));
......@@ -946,7 +949,7 @@ QList<KDevelop::ProjectFolderItem*> CMakeManager::parse( KDevelop::ProjectFolder
// Use item here since folder may be 0.
reloadFiles(item);
return folderList;
return QList<KDevelop::ProjectFolderItem*>();
}
ProjectFileItem* containsFile(const KUrl& file, const QList<ProjectFileItem*>& tfiles)
......
......@@ -280,3 +280,30 @@ void CMakeManagerTest::testTargetIncludePaths()
}
QVERIFY(foundInTarget);
}
void CMakeManagerTest::testConditionsInSubdirectoryBasedOnRootVariables()
{
const TestProjectPaths paths = projectPaths("conditions_in_subdirectory_based_on_root_variables");
defaultConfigure(paths);
ICore::self()->projectController()->openProject(paths.projectFile);
WAIT_FOR_OPEN_SIGNAL;
IProject* project = ICore::self()->projectController()->findProjectByName("conditions_in_subdirectory_based_on_root_variables");
QVERIFY(project);
QVERIFY(project->buildSystemManager());
QCOMPARE(paths.projectFile, project->projectFileUrl());
QCOMPARE(paths.sourceDir, project->folder());
KUrl rootFooCpp(paths.sourceDir, "foo.cpp");
QVERIFY(QFile::exists(rootFooCpp.toLocalFile()));
QList< ProjectBaseItem* > rootFooItems = project->itemsForUrl(rootFooCpp);
QCOMPARE(rootFooItems.size(), 4); // three items for the targets, one item for the plain file
KUrl subdirectoryFooCpp(paths.sourceDir, "subdirectory/foo.cpp");
QVERIFY(QFile::exists(subdirectoryFooCpp.toLocalFile()));
QList< ProjectBaseItem* > subdirectoryFooItems = project->itemsForUrl(subdirectoryFooCpp);
QCOMPARE(subdirectoryFooItems.size(), 4); // three items for the targets, one item for the plain file
}
......@@ -39,6 +39,7 @@ private slots:
void testIncludePaths();
void testRelativePaths();
void testTargetIncludePaths();
void testConditionsInSubdirectoryBasedOnRootVariables();
};
#endif // CMAKEMANAGERTEST_H
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