summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraSublimeTextGenerator.cxx
diff options
context:
space:
mode:
authorMorné Chamberlain <thefreeman.za@gmail.com>2012-10-18 20:54:19 (GMT)
committerMorné Chamberlain <thefreeman.za@gmail.com>2012-10-18 20:54:19 (GMT)
commit8670cbe1660acbb8abc638e29ed60a2e27c0716a (patch)
tree88de4d15e7fb73e883ff908790844009a5394e03 /Source/cmExtraSublimeTextGenerator.cxx
parentd022d4ec78bcb0d3be93479b514f5275703d9a30 (diff)
downloadCMake-8670cbe1660acbb8abc638e29ed60a2e27c0716a.zip
CMake-8670cbe1660acbb8abc638e29ed60a2e27c0716a.tar.gz
CMake-8670cbe1660acbb8abc638e29ed60a2e27c0716a.tar.bz2
Define flags in CMAKE_C(XX)_FLAGS are now included in SublimeClang settings.
Changed the the SublimeText2 generator name to Sublime Text 2. Fixed a minor issue where if the build directory was outside of the source directory an unnecessary folder_exclude_pattern was generated in the Sublime Text 2 project file.
Diffstat (limited to 'Source/cmExtraSublimeTextGenerator.cxx')
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx57
1 files changed, 40 insertions, 17 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()->