From 75b060ff209c02a1d709fa834a853f4750427cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morn=C3=A9=20Chamberlain?= Date: Thu, 11 Oct 2012 22:16:44 +0200 Subject: [PATCH] Changed SublimeClang include path generation to expand to absolute paths. Fixed an issue where compiler definitions for SublimeClang were not written to the project file. --- Source/cmExtraSublimeTextGenerator.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index d9000ca92..486658d3a 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -227,6 +227,13 @@ void cmExtraSublimeTextGenerator fout << "],\n"; fout << "\t\t\t\"file_include_patterns\": [" << fileIncludePatternsStream.str() << "]\n"; + fout << "\t\t},\n\t"; + // In order for SublimeClang's path resolution to work, the directory that + // contains the sublime-project file must be included here. We just ensure + // that no files or subfolders are included + fout << "\t{\n\t\t\t\"path\": \"./\",\n"; + fout << "\t\t\t\"folder_exclude_patterns\": [\"*\"],\n"; + fout << "\t\t\t\"file_exclude_patterns\": [\"*\"]\n"; fout << "\t\t}\n\t"; // End of the folders section fout << "]"; @@ -340,9 +347,13 @@ void cmExtraSublimeTextGenerator const std::string &relative = cmSystemTools::RelativePath( lgs[0]->GetMakefile()->GetHomeOutputDirectory(), includeDir.c_str()); - fout << "\t\"-I" << relative << "\""; + // It appears that a relative path to the sublime-project file doesn't + // always work. So we use ${folder:${project_path:}} + // that SublimeClang will expand to the correct path + fout << "\t\"-I${folder:${project_path:" << mf->GetProjectName() << + ".sublime-project}}/" << relative << "\""; stringSetIter++; - if (stringSetIter != includeDirs.end()) + if ((stringSetIter != includeDirs.end()) || (!defines.empty())) { fout << ","; } @@ -387,7 +398,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); std::string cdefs = gtgt->GetCompileDefinitions(); - if(cdefs.empty()) + if(!cdefs.empty()) { // Expand the list. std::vector defs;