ENH: add support for Fortran to the KDevelop generator

-minor optimization for GetLanguageEnabled()

Alex
This commit is contained in:
Alexander Neundorf 2007-08-31 13:42:21 -04:00
parent 20455c699b
commit d338e69c01
4 changed files with 198 additions and 135 deletions

View File

@ -271,8 +271,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
// figure out which language to use // figure out which language to use
// for now care only for C and C++ // for now care only for C and C++
std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
cmGlobalGenerator* gg=const_cast<cmGlobalGenerator*>(this->GlobalGenerator); if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false)
if (gg->GetLanguageEnabled("CXX") == false)
{ {
compilerIdVar = "CMAKE_C_COMPILER_ID"; compilerIdVar = "CMAKE_C_COMPILER_ID";
} }

View File

@ -645,9 +645,11 @@ bool cmGlobalGenerator::IgnoreFile(const char* l)
return (this->IgnoreExtensions.count(l) > 0); return (this->IgnoreExtensions.count(l) > 0);
} }
bool cmGlobalGenerator::GetLanguageEnabled(const char* l) bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const
{ {
return (this->LanguageEnabled.count(l) > 0); std::map<cmStdString, bool>::const_iterator langIt
= this->LanguageEnabled.find(l);
return (langIt!= this->LanguageEnabled.end());
} }
void cmGlobalGenerator::ClearEnabledLanguages() void cmGlobalGenerator::ClearEnabledLanguages()

View File

@ -70,7 +70,7 @@ public:
* Set/Get and Clear the enabled languages. * Set/Get and Clear the enabled languages.
*/ */
void SetLanguageEnabled(const char*, cmMakefile* mf); void SetLanguageEnabled(const char*, cmMakefile* mf);
bool GetLanguageEnabled(const char*); bool GetLanguageEnabled(const char*) const;
void ClearEnabledLanguages(); void ClearEnabledLanguages();
void GetEnabledLanguages(std::vector<std::string>& lang); void GetEnabledLanguages(std::vector<std::string>& lang);
/** /**

View File

@ -108,6 +108,7 @@ void cmGlobalKdevelopGenerator::Generate()
break; break;
} }
} }
// now create a project file // now create a project file
this->CreateProjectFile(outputDir, projectDir, projectName, this->CreateProjectFile(outputDir, projectDir, projectName,
executable, cmakeFilePattern, fileToOpen); executable, cmakeFilePattern, fileToOpen);
@ -275,11 +276,24 @@ void cmGlobalKdevelopGenerator
const std::string& cmakeFilePattern, const std::string& cmakeFilePattern,
const std::string& fileToOpen) const std::string& fileToOpen)
{ {
this->Blacklist.clear();
std::string filename=outputDir+"/";
filename+=projectname+".kdevelop";
std::string sessionFilename=outputDir+"/";
sessionFilename+=projectname+".kdevses";
if (cmSystemTools::FileExists(filename.c_str()))
{
this->MergeProjectFiles(outputDir, projectDir, filename,
executable, cmakeFilePattern,
fileToOpen, sessionFilename);
}
else
{
// add all subdirectories to the kdevelop blacklist // add all subdirectories to the kdevelop blacklist
// so they are not monitored for added or removed files // so they are not monitored for added or removed files
// since this is basically handled by adding files to the // since this is basically handled by adding files to the cmake files
// cmake files
this->Blacklist.clear();
cmsys::Directory d; cmsys::Directory d;
if (d.Load(projectDir.c_str())) if (d.Load(projectDir.c_str()))
{ {
@ -299,20 +313,6 @@ void cmGlobalKdevelopGenerator
} }
} }
} }
std::string filename=outputDir+"/";
filename+=projectname+".kdevelop";
std::string sessionFilename=outputDir+"/";
sessionFilename+=projectname+".kdevses";
if (cmSystemTools::FileExists(filename.c_str()))
{
this->MergeProjectFiles(outputDir, projectDir, filename,
executable, cmakeFilePattern,
fileToOpen, sessionFilename);
}
else
{
this->CreateNewProjectFile(outputDir, projectDir, filename, this->CreateNewProjectFile(outputDir, projectDir, filename,
executable, cmakeFilePattern, executable, cmakeFilePattern,
fileToOpen, sessionFilename); fileToOpen, sessionFilename);
@ -416,20 +416,38 @@ void cmGlobalKdevelopGenerator
bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str()); bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str()); bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
fout<<"<?xml version = '1.0'?>\n"; bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
fout<<"<kdevelop>\n"; || this->GlobalGenerator->GetLanguageEnabled("CXX"));
fout<<" <general>\n"; bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
fout<<" <author></author>\n"; std::string primaryLanguage = "C++";
fout<<" <email></email>\n"; if (enableFortran && !enableCxx)
fout<<" <version>$VERSION$</version>\n"; {
fout<<" <projectmanagement>KDevCustomProject</projectmanagement>\n"; primaryLanguage="Fortran77";
fout<<" <primarylanguage>C++</primarylanguage>\n"; }
fout<<" <ignoreparts/>\n";
fout<<" <projectdirectory>"<<projectDir.c_str() fout<<"<?xml version = '1.0'?>\n"
<<"</projectdirectory>\n"; //this one is important "<kdevelop>\n"
" <general>\n"
" <author></author>\n"
" <email></email>\n"
" <version>$VERSION$</version>\n"
" <projectmanagement>KDevCustomProject</projectmanagement>\n"
" <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
" <ignoreparts/>\n"
" <projectdirectory>" << projectDir.c_str() <<
"</projectdirectory>\n"; //this one is important
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
// setup additional languages
fout<<" <secondaryLanguages>\n"; fout<<" <secondaryLanguages>\n";
if (enableFortran && enableCxx)
{
fout<<" <language>Fortran</language>\n";
}
if (enableCxx)
{
fout<<" <language>C</language>\n"; fout<<" <language>C</language>\n";
}
fout<<" </secondaryLanguages>\n"; fout<<" </secondaryLanguages>\n";
if (hasSvn) if (hasSvn)
@ -441,99 +459,143 @@ void cmGlobalKdevelopGenerator
fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n"; fout << " <versioncontrol>kdevcvsservice</versioncontrol>\n";
} }
fout<<" </general>\n"; fout<<" </general>\n"
fout<<" <kdevcustomproject>\n"; " <kdevcustomproject>\n"
fout<<" <filelistdirectory>"<<outputDir.c_str() " <filelistdirectory>" << outputDir.c_str() <<
<<"</filelistdirectory>\n"; "</filelistdirectory>\n"
fout<<" <run>\n"; " <run>\n"
fout<<" <mainprogram>"<<executable.c_str()<<"</mainprogram>\n"; " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
fout<<" <directoryradio>custom</directoryradio>\n"; " <directoryradio>custom</directoryradio>\n"
fout<<" <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"; " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
fout<<" <programargs></programargs>\n"; " <programargs></programargs>\n"
fout<<" <terminal>false</terminal>\n"; " <terminal>false</terminal>\n"
fout<<" <autocompile>true</autocompile>\n"; " <autocompile>true</autocompile>\n"
fout<<" <envvars/>\n"; " <envvars/>\n"
fout<<" </run>\n"; " </run>\n"
fout<<" <build>\n"; " <build>\n"
fout<<" <buildtool>make</buildtool>\n"; //this one is important " <buildtool>make</buildtool>\n"; //this one is important
fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
fout<<" </build>\n"; fout<<" </build>\n"
fout<<" <make>\n"; " <make>\n"
fout<<" <abortonerror>false</abortonerror>\n"; " <abortonerror>false</abortonerror>\n"
fout<<" <numberofjobs>1</numberofjobs>\n"; " <numberofjobs>1</numberofjobs>\n"
fout<<" <dontact>false</dontact>\n"; " <dontact>false</dontact>\n"
fout<<" <makebin></makebin>\n"; " <makebin></makebin>\n"
fout<<" <selectedenvironment>default</selectedenvironment>\n"; " <selectedenvironment>default</selectedenvironment>\n"
fout<<" <environments>\n"; " <environments>\n"
fout<<" <default/>\n"; " <default/>\n"
fout<<" </environments>\n"; " </environments>\n"
fout<<" </make>\n"; " </make>\n";
fout<<" <blacklist>\n"; fout<<" <blacklist>\n";
for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin(); for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
dirIt != this->Blacklist.end(); dirIt != this->Blacklist.end();
++dirIt) ++dirIt)
{ {
fout<<" <path>"<<dirIt->c_str()<<"</path>\n"; fout<<" <path>" << dirIt->c_str() << "</path>\n";
} }
fout<<" </blacklist>\n"; fout<<" </blacklist>\n";
fout<<" </kdevcustomproject>\n"; fout<<" </kdevcustomproject>\n"
fout<<" <kdevfilecreate>\n"; " <kdevfilecreate>\n"
fout<<" <filetypes/>\n"; " <filetypes/>\n"
fout<<" <useglobaltypes>\n"; " <useglobaltypes>\n"
fout<<" <type ext=\"ui\" />\n"; " <type ext=\"ui\" />\n"
fout<<" <type ext=\"cpp\" />\n"; " <type ext=\"cpp\" />\n"
fout<<" <type ext=\"h\" />\n"; " <type ext=\"h\" />\n"
fout<<" </useglobaltypes>\n"; " </useglobaltypes>\n"
fout<<" </kdevfilecreate>\n"; " </kdevfilecreate>\n"
fout<<" <kdevdoctreeview>\n"; " <kdevdoctreeview>\n"
fout<<" <projectdoc>\n"; " <projectdoc>\n"
fout<<" <userdocDir>html/</userdocDir>\n"; " <userdocDir>html/</userdocDir>\n"
fout<<" <apidocDir>html/</apidocDir>\n"; " <apidocDir>html/</apidocDir>\n"
fout<<" </projectdoc>\n"; " </projectdoc>\n"
fout<<" <ignoreqt_xml/>\n"; " <ignoreqt_xml/>\n"
fout<<" <ignoredoxygen/>\n"; " <ignoredoxygen/>\n"
fout<<" <ignorekdocs/>\n"; " <ignorekdocs/>\n"
fout<<" <ignoretocs/>\n"; " <ignoretocs/>\n"
fout<<" <ignoredevhelp/>\n"; " <ignoredevhelp/>\n"
fout<<" </kdevdoctreeview>\n"; " </kdevdoctreeview>\n";
fout<<" <cppsupportpart>\n";
fout<<" <filetemplates>\n"; if (enableCxx)
fout<<" <interfacesuffix>.h</interfacesuffix>\n"; {
fout<<" <implementationsuffix>.cpp</implementationsuffix>\n"; fout<<" <cppsupportpart>\n"
fout<<" </filetemplates>\n"; " <filetemplates>\n"
fout<<" </cppsupportpart>\n"; " <interfacesuffix>.h</interfacesuffix>\n"
fout<<" <kdevcppsupport>\n"; " <implementationsuffix>.cpp</implementationsuffix>\n"
fout<<" <codecompletion>\n"; " </filetemplates>\n"
fout<<" <includeGlobalFunctions>true</includeGlobalFunctions>\n"; " </cppsupportpart>\n"
fout<<" <includeTypes>true</includeTypes>\n"; " <kdevcppsupport>\n"
fout<<" <includeEnums>true</includeEnums>\n"; " <codecompletion>\n"
fout<<" <includeTypedefs>false</includeTypedefs>\n"; " <includeGlobalFunctions>true</includeGlobalFunctions>\n"
fout<<" <automaticCodeCompletion>true</automaticCodeCompletion>\n"; " <includeTypes>true</includeTypes>\n"
fout<<" <automaticArgumentsHint>true</automaticArgumentsHint>\n"; " <includeEnums>true</includeEnums>\n"
fout<<" <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"; " <includeTypedefs>false</includeTypedefs>\n"
fout<<" <codeCompletionDelay>250</codeCompletionDelay>\n"; " <automaticCodeCompletion>true</automaticCodeCompletion>\n"
fout<<" <argumentsHintDelay>400</argumentsHintDelay>\n"; " <automaticArgumentsHint>true</automaticArgumentsHint>\n"
fout<<" <headerCompletionDelay>250</headerCompletionDelay>\n"; " <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
fout<<" </codecompletion>\n"; " <codeCompletionDelay>250</codeCompletionDelay>\n"
fout<<" <references/>\n"; " <argumentsHintDelay>400</argumentsHintDelay>\n"
fout<<" </kdevcppsupport>\n"; " <headerCompletionDelay>250</headerCompletionDelay>\n"
fout<<" <kdevfileview>\n"; " </codecompletion>\n"
fout<<" <groups>\n"; " <references/>\n"
fout<<" <group pattern=\""<<cmakeFilePattern.c_str() " </kdevcppsupport>\n";
<<"\" name=\"CMake\" />\n"; }
fout<<" <group pattern=\"*.h;*.hxx\" name=\"Header\" />\n";
fout<<" <group pattern=\"*.cpp;*.c;*.C;*.cxx\" name=\"Sources\" />\n"; if (enableFortran)
fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"; {
fout<<" <hidenonprojectfiles>true</hidenonprojectfiles>\n"; fout<<" <kdevfortransupport>\n"
fout<<" </groups>\n"; " <ftnchek>\n"
fout<<" <tree>\n"; " <division>false</division>\n"
fout<<" <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"; " <extern>false</extern>\n"
fout<<" <hidenonprojectfiles>true</hidenonprojectfiles>\n"; " <declare>false</declare>\n"
fout<<" </tree>\n"; " <pure>false</pure>\n"
fout<<" </kdevfileview>\n"; " <argumentsall>false</argumentsall>\n"
fout<<"</kdevelop>\n"; " <commonall>false</commonall>\n"
" <truncationall>false</truncationall>\n"
" <usageall>false</usageall>\n"
" <f77all>false</f77all>\n"
" <portabilityall>false</portabilityall>\n"
" <argumentsonly/>\n"
" <commononly/>\n"
" <truncationonly/>\n"
" <usageonly/>\n"
" <f77only/>\n"
" <portabilityonly/>\n"
" </ftnchek>\n"
" </kdevfortransupport>\n";
}
// set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
// command
fout<<" <kdevfileview>\n"
" <groups>\n"
" <group pattern=\"" << cmakeFilePattern.c_str() <<
"\" name=\"CMake\" />\n";
if (enableCxx)
{
fout<<" <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
" <group pattern=\"*.c\" name=\"C Sources\" />\n"
" <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
"/>\n";
}
if (enableFortran)
{
fout<<" <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
"*.F95\" name=\"Fortran Sources\" />\n";
}
fout<<" <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
" <hidenonprojectfiles>true</hidenonprojectfiles>\n"
" </groups>\n"
" <tree>\n"
" <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
" <hidenonprojectfiles>true</hidenonprojectfiles>\n"
" </tree>\n"
" </kdevfileview>\n"
"</kdevelop>\n";
if (sessionFilename.empty()) if (sessionFilename.empty())
{ {
@ -547,15 +609,15 @@ void cmGlobalKdevelopGenerator
{ {
return; return;
} }
devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"; devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
devses<<"<!DOCTYPE KDevPrjSession>\n"; "<!DOCTYPE KDevPrjSession>\n"
devses<<"<KDevPrjSession>\n"; "<KDevPrjSession>\n"
devses<<" <DocsAndViews NumberOfDocuments=\"1\" >\n"; " <DocsAndViews NumberOfDocuments=\"1\" >\n"
devses<<" <Doc0 NumberOfViews=\"1\" URL=\"file://" " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
<<fileToOpen.c_str()<<"\" >\n"; "\" >\n"
devses<<" <View0 line=\"0\" Type=\"Source\" />\n"; " <View0 line=\"0\" Type=\"Source\" />\n"
devses<<" </Doc0>\n"; " </Doc0>\n"
devses<<" </DocsAndViews>\n"; " </DocsAndViews>\n"
devses<<"</KDevPrjSession>\n"; "</KDevPrjSession>\n";
} }