/*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf neundorf@kde.org, All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmExtraCodeBlocksGenerator.h" #include "cmGlobalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmake.h" #include "cmSourceFile.h" #include "cmGeneratedFileStream.h" #include "cmTarget.h" #include //---------------------------------------------------------------------------- void cmExtraCodeBlocksGenerator ::GetDocumentation(cmDocumentationEntry& entry, const char*) const { entry.name = this->GetName(); entry.brief = "Generates CodeBlocks project files."; entry.full = "Project files for CodeBlocks will be created in the top directory " "and in every subdirectory which features a CMakeLists.txt file " "containing a PROJECT() call. " "Additionally a hierarchy of makefiles is generated into the " "build tree. The appropriate make program can build the project through " "the default make target. A \"make install\" target is also provided."; } cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() :cmExternalMakefileProjectGenerator() { #if defined(_WIN32) this->SupportedGlobalGenerators.push_back("NMake Makefiles"); this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); // disable MSYS until somebody actually tests it // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); #endif this->SupportedGlobalGenerators.push_back("Unix Makefiles"); } void cmExtraCodeBlocksGenerator::SetGlobalGenerator( cmGlobalGenerator* generator) { cmExternalMakefileProjectGenerator::SetGlobalGenerator(generator); cmGlobalUnixMakefileGenerator3* mf = (cmGlobalUnixMakefileGenerator3*) generator; mf->SetToolSupportsColor(false); mf->SetForceVerboseMakefiles(true); } void cmExtraCodeBlocksGenerator::Generate() { const cmMakefile* topLevelMakefile = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); std::string workspaceName = topLevelMakefile->GetProjectName(); std::string outputDir=topLevelMakefile->GetStartOutputDirectory(); std::string workspaceFilename = outputDir; workspaceFilename += "/"; workspaceFilename += workspaceName; workspaceFilename += ".workspace"; cmGeneratedFileStream fout(workspaceFilename.c_str()); if(!fout) { return; } fout<<"\n" "\n" " \n"; bool firstProject = true; // for each sub project in the project create // a kdevelop project for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) { const cmMakefile* mf=it->second[0]->GetMakefile(); std::string filename=mf->GetStartOutputDirectory(); filename+="/"; filename+=mf->GetProjectName(); filename+=".cbp"; if (firstProject) { fout<<" \n"; } else { fout<<" \n"; } // create a project file this->CreateProjectFile(it->second); } fout<<" \n" "\n"; } /* create the project file, if it already exists, merge it with the existing one, otherwise create a new one */ void cmExtraCodeBlocksGenerator::CreateProjectFile( const std::vector& lgs) { const cmMakefile* mf=lgs[0]->GetMakefile(); std::string outputDir=mf->GetStartOutputDirectory(); std::string projectDir=mf->GetHomeDirectory(); std::string projectName=mf->GetProjectName(); std::string filename=outputDir+"/"; filename+=projectName+".cbp"; std::string sessionFilename=outputDir+"/"; sessionFilename+=projectName+".layout"; /* if (cmSystemTools::FileExists(filename.c_str())) { this->MergeProjectFiles(outputDir, projectDir, filename, cmakeFilePattern, sessionFilename); } else */ { this->CreateNewProjectFile(lgs, filename); } } void cmExtraCodeBlocksGenerator ::CreateNewProjectFile(const std::vector& lgs, const std::string& filename) { const cmMakefile* mf=lgs[0]->GetMakefile(); cmGeneratedFileStream fout(filename.c_str()); if(!fout) { return; } std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); fout<<"\n" "\n" " \n" " \n"; fout<<" \n" "\n"; }