From d338e69c01d7b2cb65a7c34843f564d96be73b26 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Fri, 31 Aug 2007 13:42:21 -0400 Subject: [PATCH] ENH: add support for Fortran to the KDevelop generator -minor optimization for GetLanguageEnabled() Alex --- Source/cmExtraCodeBlocksGenerator.cxx | 3 +- Source/cmGlobalGenerator.cxx | 6 +- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalKdevelopGenerator.cxx | 322 +++++++++++++++----------- 4 files changed, 198 insertions(+), 135 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 0c155964d..02e3bfb5d 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -271,8 +271,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) // figure out which language to use // for now care only for C and C++ std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; - cmGlobalGenerator* gg=const_cast(this->GlobalGenerator); - if (gg->GetLanguageEnabled("CXX") == false) + if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) { compilerIdVar = "CMAKE_C_COMPILER_ID"; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a62a5c37d..d693b14e4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -645,9 +645,11 @@ bool cmGlobalGenerator::IgnoreFile(const char* l) 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::const_iterator langIt + = this->LanguageEnabled.find(l); + return (langIt!= this->LanguageEnabled.end()); } void cmGlobalGenerator::ClearEnabledLanguages() diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c0996b6d5..efc5fab7d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -70,7 +70,7 @@ public: * Set/Get and Clear the enabled languages. */ void SetLanguageEnabled(const char*, cmMakefile* mf); - bool GetLanguageEnabled(const char*); + bool GetLanguageEnabled(const char*) const; void ClearEnabledLanguages(); void GetEnabledLanguages(std::vector& lang); /** diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 7281bcdf9..4490ee60b 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -108,6 +108,7 @@ void cmGlobalKdevelopGenerator::Generate() break; } } + // now create a project file this->CreateProjectFile(outputDir, projectDir, projectName, executable, cmakeFilePattern, fileToOpen); @@ -275,30 +276,7 @@ void cmGlobalKdevelopGenerator const std::string& cmakeFilePattern, const std::string& fileToOpen) { - // add all subdirectories to the kdevelop blacklist - // so they are not monitored for added or removed files - // since this is basically handled by adding files to the - // cmake files this->Blacklist.clear(); - cmsys::Directory d; - if (d.Load(projectDir.c_str())) - { - size_t numf = d.GetNumberOfFiles(); - for (unsigned int i = 0; i < numf; i++) - { - std::string nextFile = d.GetFile(i); - if ((nextFile!=".") && (nextFile!="..")) - { - std::string tmp = projectDir; - tmp += "/"; - tmp += nextFile; - if (cmSystemTools::FileIsDirectory(tmp.c_str())) - { - this->Blacklist.push_back(nextFile); - } - } - } - } std::string filename=outputDir+"/"; filename+=projectname+".kdevelop"; @@ -313,6 +291,28 @@ void cmGlobalKdevelopGenerator } else { + // add all subdirectories to the kdevelop blacklist + // so they are not monitored for added or removed files + // since this is basically handled by adding files to the cmake files + cmsys::Directory d; + if (d.Load(projectDir.c_str())) + { + size_t numf = d.GetNumberOfFiles(); + for (unsigned int i = 0; i < numf; i++) + { + std::string nextFile = d.GetFile(i); + if ((nextFile!=".") && (nextFile!="..")) + { + std::string tmp = projectDir; + tmp += "/"; + tmp += nextFile; + if (cmSystemTools::FileIsDirectory(tmp.c_str())) + { + this->Blacklist.push_back(nextFile); + } + } + } + } this->CreateNewProjectFile(outputDir, projectDir, filename, executable, cmakeFilePattern, fileToOpen, sessionFilename); @@ -415,21 +415,39 @@ void cmGlobalKdevelopGenerator // check for a version control system bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str()); bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str()); - - fout<<"\n"; - fout<<"\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" $VERSION$\n"; - fout<<" KDevCustomProject\n"; - fout<<" C++\n"; - fout<<" \n"; - fout<<" "<\n"; //this one is important + + bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C") + || this->GlobalGenerator->GetLanguageEnabled("CXX")); + bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran"); + std::string primaryLanguage = "C++"; + if (enableFortran && !enableCxx) + { + primaryLanguage="Fortran77"; + } + + fout<<"\n" + "\n" + " \n" + " \n" + " \n" + " $VERSION$\n" + " KDevCustomProject\n" + " " << primaryLanguage << "\n" + " \n" + " " << projectDir.c_str() << + "\n"; //this one is important fout<<" true\n"; //and this one + + // setup additional languages fout<<" \n"; - fout<<" C\n"; + if (enableFortran && enableCxx) + { + fout<<" Fortran\n"; + } + if (enableCxx) + { + fout<<" C\n"; + } fout<<" \n"; if (hasSvn) @@ -441,100 +459,144 @@ void cmGlobalKdevelopGenerator fout << " kdevcvsservice\n"; } - fout<<" \n"; - fout<<" \n"; - fout<<" "<\n"; - fout<<" \n"; - fout<<" "<\n"; - fout<<" custom\n"; - fout<<" "<\n"; - fout<<" \n"; - fout<<" false\n"; - fout<<" true\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" make\n"; //this one is important + fout<<" \n" + " \n" + " " << outputDir.c_str() << + "\n" + " \n" + " " << executable.c_str() << "\n" + " custom\n" + " "<\n" + " \n" + " false\n" + " true\n" + " \n" + " \n" + " \n" + " make\n"; //this one is important fout<<" "<\n"; //and this one - fout<<" \n"; - fout<<" \n"; - fout<<" false\n"; - fout<<" 1\n"; - fout<<" false\n"; - fout<<" \n"; - fout<<" default\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; + fout<<" \n" + " \n" + " false\n" + " 1\n" + " false\n" + " \n" + " default\n" + " \n" + " \n" + " \n" + " \n"; fout<<" \n"; for(std::vector::const_iterator dirIt=this->Blacklist.begin(); dirIt != this->Blacklist.end(); ++dirIt) { - fout<<" "<c_str()<<"\n"; + fout<<" " << dirIt->c_str() << "\n"; } fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" html/\n"; - fout<<" html/\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" .h\n"; - fout<<" .cpp\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" true\n"; - fout<<" true\n"; - fout<<" true\n"; - fout<<" false\n"; - fout<<" true\n"; - fout<<" true\n"; - fout<<" true\n"; - fout<<" 250\n"; - fout<<" 400\n"; - fout<<" 250\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" \n"; - fout<<" true\n"; - fout<<" \n"; - fout<<" \n"; - fout<<" *.o,*.lo,CVS,*~,cmake*\n"; - fout<<" true\n"; - fout<<" \n"; - fout<<" \n"; - fout<<"\n"; - + fout<<" \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " html/\n" + " html/\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + + if (enableCxx) + { + fout<<" \n" + " \n" + " .h\n" + " .cpp\n" + " \n" + " \n" + " \n" + " \n" + " true\n" + " true\n" + " true\n" + " false\n" + " true\n" + " true\n" + " true\n" + " 250\n" + " 400\n" + " 250\n" + " \n" + " \n" + " \n"; + } + + if (enableFortran) + { + fout<<" \n" + " \n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " false\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n"; + } + + // set up file groups. maybe this can be used with the CMake SOURCE_GROUP() + // command + fout<<" \n" + " \n" + " \n"; + + if (enableCxx) + { + fout<<" \n" + " \n" + " \n"; + } + + if (enableFortran) + { + fout<<" \n"; + } + + fout<<" \n" + " true\n" + " \n" + " \n" + " *.o,*.lo,CVS,*~,cmake*\n" + " true\n" + " \n" + " \n" + "\n"; + if (sessionFilename.empty()) { return; @@ -547,15 +609,15 @@ void cmGlobalKdevelopGenerator { return; } - devses<<"\n"; - devses<<"\n"; - devses<<"\n"; - devses<<" \n"; - devses<<" \n"; - devses<<" \n"; - devses<<" \n"; - devses<<" \n"; - devses<<"\n"; + devses<<"\n" + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; }