diff options
Diffstat (limited to 'Source/cmExtraSublimeTextGenerator.cxx')
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 75 |
1 files changed, 30 insertions, 45 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 9b3ea0b..6e81ee1 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -38,24 +38,30 @@ http://www.sublimetext.com/docs/2/projects.html http://sublimetext.info/docs/en/reference/build_systems.html */ -void cmExtraSublimeTextGenerator::GetDocumentation(cmDocumentationEntry& entry, - const std::string&) const +cmExternalMakefileProjectGeneratorFactory* +cmExtraSublimeTextGenerator::GetFactory() { - entry.Name = this->GetName(); - entry.Brief = "Generates Sublime Text 2 project files."; + static cmExternalMakefileProjectGeneratorSimpleFactory< + cmExtraSublimeTextGenerator> + factory("Sublime Text 2", "Generates Sublime Text 2 project files."); + + if (factory.GetSupportedGlobalGenerators().empty()) { +#if defined(_WIN32) + factory.AddSupportedGlobalGenerator("MinGW Makefiles"); + factory.AddSupportedGlobalGenerator("NMake Makefiles"); +// disable until somebody actually tests it: +// factory.AddSupportedGlobalGenerator("MSYS Makefiles"); +#endif + factory.AddSupportedGlobalGenerator("Ninja"); + factory.AddSupportedGlobalGenerator("Unix Makefiles"); + } + + return &factory; } cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator() : cmExternalMakefileProjectGenerator() { -#if defined(_WIN32) - this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); - this->SupportedGlobalGenerators.push_back("NMake Makefiles"); -// disable until somebody actually tests it: -// this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); -#endif - this->SupportedGlobalGenerators.push_back("Ninja"); - this->SupportedGlobalGenerators.push_back("Unix Makefiles"); } void cmExtraSublimeTextGenerator::Generate() @@ -134,9 +140,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler = ""; if (!lgs.empty()) { - this->AppendTarget(fout, "all", lgs[0], 0, make.c_str(), mf, + this->AppendTarget(fout, "all", lgs[0], CM_NULLPTR, make.c_str(), mf, compiler.c_str(), sourceFileFlags, true); - this->AppendTarget(fout, "clean", lgs[0], 0, make.c_str(), mf, + this->AppendTarget(fout, "clean", lgs[0], CM_NULLPTR, make.c_str(), mf, compiler.c_str(), sourceFileFlags, false); } @@ -155,7 +161,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( // not from the subdirs if (strcmp((*lg)->GetCurrentBinaryDirectory(), (*lg)->GetBinaryDirectory()) == 0) { - this->AppendTarget(fout, targetName, *lg, 0, make.c_str(), + this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -172,8 +178,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( break; } - this->AppendTarget(fout, targetName, *lg, 0, make.c_str(), makefile, - compiler.c_str(), sourceFileFlags, false); + this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(), + makefile, compiler.c_str(), sourceFileFlags, + false); break; case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: @@ -199,12 +206,11 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( void cmExtraSublimeTextGenerator::AppendTarget( cmGeneratedFileStream& fout, const std::string& targetName, cmLocalGenerator* lg, cmGeneratorTarget* target, const char* make, - const cmMakefile* makefile, - const char*, // compiler + const cmMakefile* makefile, const char* /*compiler*/, MapSourceFileFlags& sourceFileFlags, bool firstTarget) { - if (target != 0) { + if (target != CM_NULLPTR) { std::vector<cmSourceFile*> sourceFiles; target->GetSourceFiles(sourceFiles, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); @@ -295,7 +301,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( std::string makefileName; if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see - // http://public.kitware.com/Bug/view.php?id=10014 + // https://gitlab.kitware.com/cmake/cmake/issues/10014 makefileName = makefile; } else { makefileName = cmSystemTools::ConvertToOutputPath(makefile); @@ -314,27 +320,14 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt) { std::string flags; - - cmMakefile* makefile = lg->GetMakefile(); std::string language = source->GetLanguage(); if (language.empty()) { language = "C"; } - const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - // Add language-specific flags. - lg->AddLanguageFlags(flags, language, config); - - lg->AddArchitectureFlags(flags, gtgt, language, config); + std::string const& config = + lg->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - // TODO: Fortran support. - // // Fortran-specific flags computed for this target. - // if(*l == "Fortran") - // { - // this->AddFortranFlags(flags); - // } - - // Add shared-library flags if needed. - lg->AddCMP0018Flags(flags, gtgt, language, config); + lg->GetTargetCompileFlags(gtgt, config, language, flags); // Add include directory flags. { @@ -345,17 +338,9 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( lg->AppendFlags(flags, includeFlags); } - // Append old-style preprocessor definition flags. - lg->AppendFlags(flags, makefile->GetDefineFlags()); - - // Add target-specific flags. - lg->AddCompileOptions(flags, gtgt, language, config); - // Add source file specific flags. lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); - // TODO: Handle Apple frameworks. - return flags; } |