summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorné Chamberlain <thefreeman.za@gmail.com>2012-11-04 14:15:04 (GMT)
committerMorné Chamberlain <thefreeman.za@gmail.com>2012-11-04 14:15:04 (GMT)
commit90bcb77956464b53aaf2ce8d17b2a878f74ce27e (patch)
treef578b78ca7998033c4fa0b029d2f02de7afa26eb
parentcc84072156ffe7e57248d2207dba6d9fd2b57146 (diff)
downloadCMake-90bcb77956464b53aaf2ce8d17b2a878f74ce27e.zip
CMake-90bcb77956464b53aaf2ce8d17b2a878f74ce27e.tar.gz
CMake-90bcb77956464b53aaf2ce8d17b2a878f74ce27e.tar.bz2
SublimeText2 Gen: Improved use of define, include flags from CMAKE_C(XX)_FLAGS
Both define and include flags from CMAKE_C(XX)_FLAGS are now included in SublimeClang options. Include directories are now used with absolute paths instead of relative paths since CMake generated build trees cannot be moved anyway.
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx36
-rw-r--r--Source/cmExtraSublimeTextGenerator.h9
2 files changed, 26 insertions, 19 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index d1ea484..64796c8 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -182,8 +182,9 @@ void cmExtraSublimeTextGenerator
// It appears that a relative path to the sublime-project file doesn't
// always work. So we use ${folder:${project_path:<project_filename>}}
// that SublimeClang will expand to the correct path
- fout << "\t\"-I${folder:${project_path:" << mf->GetProjectName() <<
- ".sublime-project}}/" << relative << "\"";
+ // fout << "\t\"-I${folder:${project_path:" << mf->GetProjectName() <<
+ // ".sublime-project}}/" << relative << "\"";
+ fout << "\t\"-I" << includeDir << "\"";
stringSetIter++;
if ((stringSetIter != includeDirs.end()) || (!defines.empty()))
{
@@ -309,27 +310,28 @@ void cmExtraSublimeTextGenerator::
}
void cmExtraSublimeTextGenerator::
- ExtractDefines(const char* value, bool check,
- std::set<std::string> &defines)
+ ExtractFlags(const char* value, const std::string& flag,
+ std::set<std::string> &defines)
{
+ std::string::size_type flagLength = flag.length();
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 ((flagLength == 0) || ((safedefString.length() >= flagLength) &&
+ (safedefString.substr(0, flagLength) == flag)))
{
- std::string safedefString = safedef.str();
- if ((safedefString.length() >= 2) &&
- (safedefString.substr(0, 2) == "-D"))
+ if (flagLength > 0)
{
- defines.insert(safedefString.substr(2));
+ defines.insert(safedefString.substr(flagLength));
+ }
+ else
+ {
+ defines.insert(safedefString);
}
- }
- else
- {
- defines.insert(safedef.str());
}
}
}
@@ -351,13 +353,15 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
std::string cdefs = gtgt->GetCompileDefinitions();
- ExtractDefines(cdefs.c_str(), false, defines);
+ ExtractFlags(cdefs.c_str(), "", 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);
+ ExtractFlags(cflags.c_str(), "-D", defines);
+ ExtractFlags(cflags.c_str(), "-I", includeDirs);
cflags = makefile->GetSafeDefinition("CMAKE_C_FLAGS");
- ExtractDefines(cflags.c_str(), true, defines);
+ ExtractFlags(cflags.c_str(), "-D", defines);
+ ExtractFlags(cflags.c_str(), "-D", includeDirs);
// 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 1735b75..fe8832f 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -69,9 +69,12 @@ 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);
+ /**
+ * Extracts compile flags from a variable.
+ * flag would typically be "-D" or "-I"
+ */
+ void ExtractFlags(const char* value, const std::string& flag,
+ std::set<std::string> &defines);
};
#endif