diff options
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 57 | ||||
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.h | 6 |
2 files changed, 44 insertions, 19 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index ea15be5..d1ea484 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -117,8 +117,13 @@ void cmExtraSublimeTextGenerator cmSystemTools::RelativePath(lgs[0]->GetMakefile()->GetHomeDirectory(), lgs[0]->GetMakefile()-> GetHomeOutputDirectory()); - fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" << - outputRelativeToSourceRoot << "\"]"; + if ((!outputRelativeToSourceRoot.empty()) && + ((outputRelativeToSourceRoot.length() < 3) || + (outputRelativeToSourceRoot.substr(0, 3) != "../"))) + { + fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" << + outputRelativeToSourceRoot << "\"]"; + } } else { @@ -303,7 +308,32 @@ void cmExtraSublimeTextGenerator:: } } -// Generate the build_system entry for one target +void cmExtraSublimeTextGenerator:: + ExtractDefines(const char* value, bool check, + std::set<std::string> &defines) +{ + std::vector<std::string> defs; + cmSystemTools::ExpandListArgument(value, defs); + for(std::vector<std::string>::const_iterator di = defs.begin(); + di != defs.end(); ++di) + { + cmXMLSafe safedef(di->c_str()); + if (check) + { + std::string safedefString = safedef.str(); + if ((safedefString.length() >= 2) && + (safedefString.substr(0, 2) == "-D")) + { + defines.insert(safedefString.substr(2)); + } + } + else + { + defines.insert(safedef.str()); + } + } +} + void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout, const char* targetName, cmTarget* target, @@ -321,20 +351,13 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout, cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); std::string cdefs = gtgt->GetCompileDefinitions(); - - if(!cdefs.empty()) - { - // Expand the list. - std::vector<std::string> defs; - cmSystemTools::ExpandListArgument(cdefs.c_str(), defs); - for(std::vector<std::string>::const_iterator di = defs.begin(); - di != defs.end(); ++di) - { - cmXMLSafe safedef(di->c_str()); - defines.insert(safedef.str()); - } - } - + ExtractDefines(cdefs.c_str(), false, defines); + // Get compiler definitions from CMAKE_CXX_FLAGS and CMAKE_C_FLAGS as + // well, in case the user set those flags directly + std::string cflags = makefile->GetSafeDefinition("CMAKE_CXX_FLAGS"); + ExtractDefines(cflags.c_str(), true, defines); + cflags = makefile->GetSafeDefinition("CMAKE_C_FLAGS"); + ExtractDefines(cflags.c_str(), true, defines); // the include directories for this target std::vector<std::string> includes; target->GetMakefile()->GetLocalGenerator()-> diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 05ab421..1735b75 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -31,7 +31,7 @@ public: virtual const char* GetName() const { return cmExtraSublimeTextGenerator::GetActualName();} static const char* GetActualName() - { return "SublimeText2";} + { return "Sublime Text 2";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraSublimeTextGenerator; } /** Get the documentation entry for this generator. */ @@ -69,7 +69,9 @@ private: const char* compiler, std::set<std::string>& includeDirs, std::set<std::string>& defines, bool firstTarget); - + /** Extracts -D compile flags from a variable */ + void ExtractDefines(const char* value, bool check, + std::set<std::string> &defines); }; #endif |