KDE/kdevelop/buildtools/managers/cmake
Aleix Pol Gonzalez
aleixpol at gmail.com
Tue Sep 2 23:17:54 UTC 2008
SVN commit 856474 by apol:
Let CMake work with subprojects.
This is a very usual use case and a place where many people found "buggy" the way to work because when importing a subproject made KDevelop to mess up
because of the non-parsed CMakeLists.txt files placed in parent directories. Now KDevelop looks if there are and it parses them too.
**Warning** it will always look for it, it is not yet configurable in the project file (it is configurable in the .kdev4/project.kdev4 file, should be
moved)
Now it is possible to parse a cmake subproject without parsing the other subdirectories below or in the same level. It can be useful when you are
working on a large project and you don't need the whole to be supported by KDevelop (for instance, when I'm working on KAlgebra in KDE-Edu, I don't
need, let's say, the Marble buildtool information).
CCMAIL: kdevelop-devel at kdevelop.org
M +1 -0 cmakeconfig.kcfg
M +36 -13 cmakemanager.cpp
M +1 -0 cmakemanager.h
M +4 -2 cmakepreferences.cpp
--- trunk/KDE/kdevelop/buildtools/managers/cmake/cmakeconfig.kcfg #856473:856474
@@ -3,6 +3,7 @@
<kcfg>
<kcfgfile arg="true"/>
<group name="CMake">
+ <entry name="projectRoot" key="ProjectRoot" type="Url" />
<entry name="buildDirs" key="BuildDirs" type="PathList" />
<entry name="currentBuildDir" key="CurrentBuildDir" type="Url" />
<entry name="currentInstallDir" key="CurrentInstallDir" type="Url" />
--- trunk/KDE/kdevelop/buildtools/managers/cmake/cmakemanager.cpp #856473:856474
@@ -175,7 +175,7 @@
KSharedConfig::Ptr cfg = item->project()->projectConfiguration();
KConfigGroup group(cfg.data(), "CMake");
KUrl path = group.readEntry("CurrentBuildDir");
- KUrl projectPath = item->project()->folder();
+ KUrl projectPath = m_realRoot[item->project()];
ProjectFolderItem *fi=dynamic_cast<ProjectFolderItem*>(item);
for(; !fi && item; )
@@ -244,6 +244,25 @@
}
else
{
+ KSharedConfig::Ptr cfg = project->projectConfiguration();
+ KConfigGroup group(cfg.data(), "CMake");
+ m_subprojectRoot[project] = folderUrl;
+
+ if(group.hasKey("ProjectRoot"))
+ {
+ folderUrl=group.readEntry("ProjectRoot");
+ }
+ else
+ {
+ KUrl aux=folderUrl;
+ for(; QFile::exists(aux.toLocalFile()+"/CMakeLists.txt"); aux=aux.upUrl())
+ {
+ kDebug() << "checking" << aux;
+ folderUrl=aux;
+ }
+ group.writeEntry("ProjectRoot", folderUrl);
+ }
+
m_realRoot[project] = folderUrl;
m_watchers[project] = new KDirWatch(project);
m_modulePathPerProject[project]=m_modulePathDef;
@@ -375,21 +394,25 @@
folder->setText(v.projectName());
}
- foreach (const QString& subf, v.subdirectories() )
+ KUrl subroot=m_subprojectRoot[item->project()];
+ foreach (const QString& subf, v.subdirectories())
{
- if( entries.contains( subf ) )
+ KUrl path(folder->url());
+ path.addPath(subf);
+
+ kDebug(9042) << "Found subdir " << path << "which should be into" << subroot;
+ if(subroot.isParentOf(path) || path.isParentOf(subroot))
{
- entries.removeAll( subf );
+ if(entries.contains(subf))
+ {
+ entries.removeAll(subf);
+ }
+
+ CMakeFolderItem* a = new CMakeFolderItem( item->project(), subf, folder );
+ a->setUrl(path);
+ a->setDefinitions(v.definitions());
+ folderList.append( a );
}
-
-
- KUrl path(folder->url());
- path.addPath(subf);
-
- CMakeFolderItem* a = new CMakeFolderItem( item->project(), subf, folder );
- a->setUrl(path);
- a->setDefinitions(v.definitions());
- folderList.append( a );
}
QString folderUrl= folder->url().toLocalFile(KUrl::RemoveTrailingSlash);
--- trunk/KDE/kdevelop/buildtools/managers/cmake/cmakemanager.h #856473:856474
@@ -141,6 +141,7 @@
QMap<KDevelop::IProject*, KDirWatch*> m_watchers;
QMap<KDevelop::IProject*, CacheValues> m_projectCache;
QMap<KDevelop::IProject*, KUrl> m_realRoot;
+ QMap<KDevelop::IProject*, KUrl> m_subprojectRoot;
QMap<KUrl, CMakeFolderItem*> m_folderPerUrl;
--- trunk/KDE/kdevelop/buildtools/managers/cmake/cmakepreferences.cpp #856473:856474
@@ -68,8 +68,8 @@
connect(m_prefsUi->showAdvanced, SIGNAL(toggled(bool)), this, SLOT(showAdvanced(bool)));
showInternal(m_prefsUi->showInternal->checkState());
- m_srcFolder=KUrl(args[1].toString());
- m_srcFolder=m_srcFolder.upUrl();
+// m_srcFolder=KUrl(args[1].toString()).upUrl();
+
kDebug(9042) << "Source folder: " << m_srcFolder << args[1].toString();
// foreach(const QVariant &v, args)
// {
@@ -93,6 +93,8 @@
m_prefsUi->buildDirs->clear();
m_prefsUi->buildDirs->addItems(CMakeSettings::buildDirs());
m_prefsUi->buildDirs->setCurrentIndex( m_prefsUi->buildDirs->findText( CMakeSettings::currentBuildDir().toLocalFile() ) );
+
+ m_srcFolder=CMakeSettings::projectRoot();
if(m_prefsUi->buildDirs->count()==0)
{
More information about the KDevelop-devel
mailing list