diff options
author | Morné Chamberlain <thefreeman.za@gmail.com> | 2012-11-04 14:15:04 (GMT) |
---|---|---|
committer | Morné Chamberlain <thefreeman.za@gmail.com> | 2012-11-04 14:15:04 (GMT) |
commit | 90bcb77956464b53aaf2ce8d17b2a878f74ce27e (patch) | |
tree | f578b78ca7998033c4fa0b029d2f02de7afa26eb /Source/cmExtraSublimeTextGenerator.cxx | |
parent | cc84072156ffe7e57248d2207dba6d9fd2b57146 (diff) | |
download | CMake-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.
Diffstat (limited to 'Source/cmExtraSublimeTextGenerator.cxx')
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 36 |
1 files changed, 20 insertions, 16 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()-> |