[Cmake-commits] CMake branch, next, updated. v2.8.10.2-2224-g5d5e89a

Brad King brad.king at kitware.com
Tue Feb 19 14:47:38 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  5d5e89a7275ed19ea7eb1990322382956a49358e (commit)
       via  f616ff2c25e9902ed1cffc15f19d9299b83cba5a (commit)
       via  674bd6e7788f9e6ff35c0082c9c85e9aa83b642d (commit)
       via  4760eade425e8e294ac9400785ffce70912d5b43 (commit)
       via  da0898e0a2f01cfbc5f2a1061ea94662fd3e455e (commit)
       via  badb40d0f841dcfc4d098e59c5c570e73767cf68 (commit)
       via  b3ae61f8338fd3b2308de0173c34a329ba46d191 (commit)
       via  089d9ccdce530ebd08dfc4681833cefeff4a7eb9 (commit)
       via  44c2eee8967860499a8b86baccd188799ad25966 (commit)
       via  304b885d365b5814838e3c595bc17342553d3b68 (commit)
       via  5b2aa3dd9af903e7aae0a252d2119847ceac4aa0 (commit)
       via  90bcb77956464b53aaf2ce8d17b2a878f74ce27e (commit)
       via  cc84072156ffe7e57248d2207dba6d9fd2b57146 (commit)
       via  8670cbe1660acbb8abc638e29ed60a2e27c0716a (commit)
       via  d022d4ec78bcb0d3be93479b514f5275703d9a30 (commit)
       via  9cd3e7071f1769eb6bd751a501d36c6130019a1a (commit)
       via  44f35f7824c0d97d575ab566a1f9fd1c83be8fc8 (commit)
       via  9657acb55a62f2e37a0378d01e93ab2ee4d151be (commit)
       via  6742ee747f5d55bef73bed2c70611e8542f28f43 (commit)
       via  cd76ec3e22f299f03e34db3deee5e835613af315 (commit)
       via  ef8aa081a164817d1d78b6df8ebcf23e421d422f (commit)
       via  4d585b109d5f5984d285a82c5582f9b585e9792b (commit)
       via  75b060ff209c02a1d709fa834a853f4750427cb1 (commit)
       via  32f79024ba18df5016eb34c9f5fcc8708eaca83a (commit)
       via  b8457ad18b7eac2998fdd29fbc295c1dadbbba42 (commit)
      from  f38ae075ff8d2908bf3747f313c44fb47aa673df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d5e89a7275ed19ea7eb1990322382956a49358e
commit 5d5e89a7275ed19ea7eb1990322382956a49358e
Merge: f38ae07 f616ff2
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Feb 19 14:47:32 2013 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Feb 19 14:47:32 2013 -0500

    Merge topic 'sublime-text-2-generator' into next
    
    f616ff2 Update generator to use new cmGeneratorTarget api.
    674bd6e Merge branch 'master' into sublime-text-2-generator
    4760ead Remove ability to generate sublime clang files.
    da0898e Correct missing parameter to CMP0018Flags call.
    badb40d Merge branch 'master' into sublime-text-2-generator
    b3ae61f Merge branch 'master' into sublime-text-2-generator
    089d9cc SublimeText 2 Gen: Set the sublimeclang_options_script property.
    44c2eee Merge branch 'master' into sublime-text-2-generator
    304b885 Sublime Text 2 Gen: Per-source Compile flags are now saved in a separate file.
    5b2aa3d SublimeText2 Gen: Fixed the issue where include directory flags used -D
    90bcb77 SublimeText2 Gen: Improved use of define, include flags from CMAKE_C(XX)_FLAGS
    cc84072 Merge branch 'master' into sublime-text-2-generator
    8670cbe Define flags in CMAKE_C(XX)_FLAGS are now included in SublimeClang settings.
    d022d4e Merge branch 'master' into sublime-text-2-generator
    9cd3e70 Fixed Sublime Text project generation for in-source builds
    44f35f7 Added a CMAKE_SUBLIMECLANG_DISABLED variable that disables SublimeClang.
    ...


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f616ff2c25e9902ed1cffc15f19d9299b83cba5a
commit f616ff2c25e9902ed1cffc15f19d9299b83cba5a
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Mon Feb 11 17:23:02 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 19 14:45:18 2013 -0500

    Update generator to use new cmGeneratorTarget api.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index ef29329..5431401 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -11,14 +11,16 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraSublimeTextGenerator.h"
+#include "cmake.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmLocalGenerator.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmake.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmTarget.h"
 #include "cmSystemTools.h"
+#include "cmTarget.h"
 #include "cmXMLSafe.h"
 
 #include <cmsys/SystemTools.hxx>
@@ -253,10 +255,11 @@ void cmExtraSublimeTextGenerator::
                cmTarget* target,
                const char* make,
                const cmMakefile* makefile,
-               const char* compiler,
+               const char*, //compiler
                MapSourceFileFlags& sourceFileFlags,
                bool firstTarget)
 {
+
   if (target != 0)
     {
       cmGeneratorTarget *gtgt = this->GlobalGenerator
@@ -426,7 +429,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
   lg->AppendFlags(flags, makefile->GetDefineFlags());
 
   // Add target-specific flags.
-  if(gtgt->GetProperty("COMPILE_FLAGS"))
+  if(target->GetProperty("COMPILE_FLAGS"))
     {
     std::string langIncludeExpr = "CMAKE_";
     langIncludeExpr += language;
@@ -437,7 +440,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
       cmsys::RegularExpression r(regex);
       std::vector<std::string> args;
       cmSystemTools::
-        ParseWindowsCommandLine(gtgt->GetProperty("COMPILE_FLAGS"), args);
+        ParseWindowsCommandLine(target->GetProperty("COMPILE_FLAGS"), args);
       for(std::vector<std::string>::iterator i = args.begin();
           i != args.end(); ++i)
         {
@@ -449,12 +452,12 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
       }
     else
       {
-      lg->AppendFlags(flags, gtgt->GetProperty("COMPILE_FLAGS"));
+      lg->AppendFlags(flags, target->GetProperty("COMPILE_FLAGS"));
       }
     }
 
   // Add source file specific flags.
-  lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
+  lg->AppendFlags(flags, target->GetProperty("COMPILE_FLAGS"));
 
   // TODO: Handle Apple frameworks.
 
@@ -466,7 +469,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
 std::string
 cmExtraSublimeTextGenerator::
 ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
-               cmGeneratorTarget* gtgt)
+               cmGeneratorTarget*)
 
 {
   std::set<std::string> defines;
@@ -485,12 +488,12 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
     }
 
   // Add preprocessor definitions for this target and configuration.
-  lg->AppendDefines(defines, gtgt->GetCompileDefinitions());
+  lg->AppendDefines(defines, target->GetCompileDefinitions());
   lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
   {
   std::string defPropName = "COMPILE_DEFINITIONS_";
   defPropName += cmSystemTools::UpperCase(config);
-  lg->AppendDefines(defines, gtgt->GetCompileDefinitions(config));
+  lg->AppendDefines(defines, target->GetCompileDefinitions(config));
   lg->AppendDefines(defines, source->GetProperty(defPropName.c_str()));
   }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=674bd6e7788f9e6ff35c0082c9c85e9aa83b642d
commit 674bd6e7788f9e6ff35c0082c9c85e9aa83b642d
Merge: 4760ead 3e7bba3
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Mon Feb 11 17:20:00 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 19 14:44:57 2013 -0500

    Merge branch 'master' into sublime-text-2-generator


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4760eade425e8e294ac9400785ffce70912d5b43
commit 4760eade425e8e294ac9400785ffce70912d5b43
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Feb 6 13:31:44 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 19 14:43:20 2013 -0500

    Remove ability to generate sublime clang files.
    
    SublimeClang is a optional plugin to SublimeText and I felt it
    shouldn't be part of the generator for the following reasons:
    
    1. Reduces the amount of sublime and sublimeClang specific
       code we have to maintain inside CMake.
    2. In testing the SublimeClang commands generated did not work
       for the VTK project.
    
    For people that do want this feature I recommend that they
    looking into https://gist.github.com/robertmaynard/4724705 for a
    way to use CMAKE_EXPORT_COMPILE_COMMANDS to generate JSON files
    that can be used by SublimeClang.

diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 579f77f..08b3ef1 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -904,14 +904,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      "only be used when evaluating the INCLUDE_DIRECTORIES target property.  "
      "In that case, it outputs a backtrace for each include directory in "
      "the build.  Default is unset.",false,"Variables That Change Behavior");
-  cm->DefineProperty
-    ("CMAKE_SUBLIMECLANG_DISABLED", cmProperty::VARIABLE,
-     "Used by the Sublime Text 2 generator to disable SublimeClang in "
-     "generated project files.",
-     "For very large projects SublimeClang might run slowly. Set this variable"
-     " to TRUE to instruct the Sublime Text 2 generator to disable "
-     " SublimeClang in the generated project files.", false,
-     "Variables That Change Behavior");
 
   // Variables defined by CMake that describe the system
 
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index d10179e..ef29329 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -87,8 +87,8 @@ void cmExtraSublimeTextGenerator::CreateProjectFile(
   std::string outputDir=mf->GetStartOutputDirectory();
   std::string projectName=mf->GetProjectName();
 
-  std::string filename=outputDir+"/";
-  filename+=projectName+".sublime-project";
+  const std::string filename =
+                     outputDir + "/" + projectName + ".sublime-project";
 
   this->CreateNewProjectFile(lgs, filename);
 }
@@ -140,108 +140,14 @@ void cmExtraSublimeTextGenerator
   // wide
   MapSourceFileFlags sourceFileFlags;
   AppendAllTargets(lgs, mf, fout, sourceFileFlags);
+
   // End of build_systems
   fout << "\n\t]";
-
-  // Write the settings section with sublimeclang options
-  fout << ",\n\t\"settings\":\n\t{\n\t";
-  // Check if the CMAKE_SUBLIMECLANG_DISABLED flag has been set. If it has
-  // disable sublimeclang for this project.
-  const char* sublimeclangDisabledValue =
-    mf->GetSafeDefinition("CMAKE_SUBLIMECLANG_DISABLED");
-  bool sublimeclangEnabled = cmSystemTools::IsOff(sublimeclangDisabledValue);
-  // Per project sublimeclang settings override default and user settings,
-  // so we only write the sublimeclang_enabled setting to the project file
-  // if it is set to be disabled.
-  if (!sublimeclangEnabled)
-    {
-      fout << "\t\"sublimeclang_enabled\": false,\n\t";
-    }
-  std::string outputDir = mf->GetStartOutputDirectory();
-  std::string projectName = mf->GetProjectName();
-  std::string sublimeClangOptionsFilename = outputDir+"/";
-  sublimeClangOptionsFilename += projectName + ".sublimeclang-options";
-  std::string sublimeClangOptionsScriptFilename = outputDir + "/"
-    + projectName + "_sublimeclang_options_script.py";
-  fout << "\t\"sublimeclang_options_script\": \"python "
-       << sublimeClangOptionsScriptFilename << " "
-       << sublimeClangOptionsFilename
-       << "\"\n\t";
-  // End of the settings section
-  fout << "}\n";
-
-  // End of file
-  fout << "}";
-
-  this->WriteSublimeClangOptionsFile(sourceFileFlags,
-    sublimeClangOptionsFilename);
-  this->WriteSublimeClangOptionsScript(sublimeClangOptionsScriptFilename);
-}
-
-void cmExtraSublimeTextGenerator::
-  WriteSublimeClangOptionsScript(const std::string& filename)
-{
-  cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
-    return;
-    }
-  fout << "import json\n";
-  fout << "import sys\n\n\n";
-  fout << "if len(sys.argv) < 2:\n";
-  fout << "    sys.exit(1)\n";
-  fout << "data = None\n";
-  fout << "with open(sys.argv[1]) as f:\n";
-  fout << "    data = json.load(f)\n";
-  fout << "if data is not None:\n";
-  fout << "    for arg in data.get(sys.argv[2], []):\n";
-  fout << "        print arg\n";
+  fout << "\n\t}";
 }
 
 
 void cmExtraSublimeTextGenerator::
-  WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
-                               const std::string& filename)
-{
-  cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
-    return;
-    }
-  fout << "{\n";
-  MapSourceFileFlags::const_iterator sourceFileFlagsEnd =
-    sourceFileFlags.end();
-  int totalFiles = sourceFileFlags.size();
-  int fileIndex = 0;
-  for (MapSourceFileFlags::const_iterator iter = sourceFileFlags.begin();
-    iter != sourceFileFlagsEnd; ++iter)
-    {
-    const std::string& sourceFilePath = iter->first;
-    const std::vector<std::string>& flags = iter->second;
-    fout << "\t\"" << sourceFilePath << "\":\n\t[\n\t";
-    std::vector<std::string>::const_iterator flagsEnd = flags.end();
-    for (std::vector<std::string>::const_iterator flagsIter = flags.begin();
-      flagsIter != flagsEnd; ++flagsIter)
-      {
-      fout << "\t\"" << *flagsIter << "\"";
-      if (flagsIter + 1 != flagsEnd)
-        {
-        fout << ",";
-        }
-      fout << "\n\t";
-      }
-      fout << "]";
-      if (fileIndex < totalFiles - 1)
-        {
-        fout << ",";
-        }
-      fout << "\n";
-      fileIndex++;
-    }
-  fout << "}\n";
-}
-
-void cmExtraSublimeTextGenerator::
   AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
                    const cmMakefile* mf,
                    cmGeneratedFileStream& fout,
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 8c0c1f3..7902593 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -48,9 +48,7 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
-  void WriteSublimeClangOptionsScript(const std::string& filename);
-  void WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
-                                    const std::string& filename);
+
   /** Appends all targets as build systems to the project file and get all
    * include directories and compiler definitions used.
    */

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da0898e0a2f01cfbc5f2a1061ea94662fd3e455e
commit da0898e0a2f01cfbc5f2a1061ea94662fd3e455e
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Jan 23 17:26:35 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 19 14:42:43 2013 -0500

    Correct missing parameter to CMP0018Flags call.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index b174125..d10179e 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -505,7 +505,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
   //   }
 
   // Add shared-library flags if needed.
-  lg->AddCMP0018Flags(flags, target, language);
+  lg->AddCMP0018Flags(flags, target, language, config);
 
   // Add include directory flags.
   {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=badb40d0f841dcfc4d098e59c5c570e73767cf68
commit badb40d0f841dcfc4d098e59c5c570e73767cf68
Merge: b3ae61f 378899c
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Jan 23 14:50:00 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 19 14:42:00 2013 -0500

    Merge branch 'master' into sublime-text-2-generator
    
    Resolve conflict in Source/cmDocumentVariables.cxx by adding both
    variables.

diff --cc Source/cmDocumentVariables.cxx
index d855bd2,08b3ef1..579f77f
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@@ -897,13 -897,13 +897,21 @@@ void cmDocumentVariables::DefineVariabl
        "Variables That Change Behavior");
  
    cm->DefineProperty
+     ("CMAKE_DEBUG_TARGET_PROPERTIES", cmProperty::VARIABLE,
+      "Enables tracing output for target properties.",
+      "This variable can be populated with a list of properties to generate "
+      "debug output for when evaluating target properties.  Currently it can "
+      "only be used when evaluating the INCLUDE_DIRECTORIES target property.  "
+      "In that case, it outputs a backtrace for each include directory in "
+      "the build.  Default is unset.",false,"Variables That Change Behavior");
++  cm->DefineProperty
 +    ("CMAKE_SUBLIMECLANG_DISABLED", cmProperty::VARIABLE,
 +     "Used by the Sublime Text 2 generator to disable SublimeClang in "
 +     "generated project files.",
 +     "For very large projects SublimeClang might run slowly. Set this variable"
 +     " to TRUE to instruct the Sublime Text 2 generator to disable "
 +     " SublimeClang in the generated project files.", false,
 +     "Variables That Change Behavior");
  
    // Variables defined by CMake that describe the system
  

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3ae61f8338fd3b2308de0173c34a329ba46d191
commit b3ae61f8338fd3b2308de0173c34a329ba46d191
Merge: 089d9cc 7935744
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sat Nov 24 20:23:55 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Nov 24 20:23:55 2012 +0200

    Merge branch 'master' into sublime-text-2-generator


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=089d9ccdce530ebd08dfc4681833cefeff4a7eb9
commit 089d9ccdce530ebd08dfc4681833cefeff4a7eb9
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sat Nov 24 20:19:35 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Nov 24 20:19:35 2012 +0200

    SublimeText 2 Gen: Set the sublimeclang_options_script property.
    
    The sublimeclang_options_script property is now set in the project
    file. It is set to execute a python script that reads the JSON options
    file to get options per source file. Python must be installed and in the
    path for this feature to work from Sublime Text.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 03e2e1d..b174125 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -161,7 +161,11 @@ void cmExtraSublimeTextGenerator
   std::string projectName = mf->GetProjectName();
   std::string sublimeClangOptionsFilename = outputDir+"/";
   sublimeClangOptionsFilename += projectName + ".sublimeclang-options";
-  fout << "\t\"sublimeclang_options_file\": \"" << sublimeClangOptionsFilename
+  std::string sublimeClangOptionsScriptFilename = outputDir + "/"
+    + projectName + "_sublimeclang_options_script.py";
+  fout << "\t\"sublimeclang_options_script\": \"python "
+       << sublimeClangOptionsScriptFilename << " "
+       << sublimeClangOptionsFilename
        << "\"\n\t";
   // End of the settings section
   fout << "}\n";
@@ -171,9 +175,31 @@ void cmExtraSublimeTextGenerator
 
   this->WriteSublimeClangOptionsFile(sourceFileFlags,
     sublimeClangOptionsFilename);
+  this->WriteSublimeClangOptionsScript(sublimeClangOptionsScriptFilename);
 }
 
 void cmExtraSublimeTextGenerator::
+  WriteSublimeClangOptionsScript(const std::string& filename)
+{
+  cmGeneratedFileStream fout(filename.c_str());
+  if(!fout)
+    {
+    return;
+    }
+  fout << "import json\n";
+  fout << "import sys\n\n\n";
+  fout << "if len(sys.argv) < 2:\n";
+  fout << "    sys.exit(1)\n";
+  fout << "data = None\n";
+  fout << "with open(sys.argv[1]) as f:\n";
+  fout << "    data = json.load(f)\n";
+  fout << "if data is not None:\n";
+  fout << "    for arg in data.get(sys.argv[2], []):\n";
+  fout << "        print arg\n";
+}
+
+
+void cmExtraSublimeTextGenerator::
   WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
                                const std::string& filename)
 {
@@ -351,6 +377,7 @@ void cmExtraSublimeTextGenerator::
             this->ComputeDefines(*iter, lg, target, gtgt);
           flags.clear();
           cmsys::RegularExpression flagRegex;
+          // Regular expression to extract compiler flags from a string
           // https://gist.github.com/3944250
           const char* regexString =
             "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 26e09a6..8c0c1f3 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -48,6 +48,7 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
+  void WriteSublimeClangOptionsScript(const std::string& filename);
   void WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
                                     const std::string& filename);
   /** Appends all targets as build systems to the project file and get all

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44c2eee8967860499a8b86baccd188799ad25966
commit 44c2eee8967860499a8b86baccd188799ad25966
Merge: 304b885 a23ac6b
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Nov 11 22:10:21 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Nov 11 22:10:21 2012 +0200

    Merge branch 'master' into sublime-text-2-generator


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=304b885d365b5814838e3c595bc17342553d3b68
commit 304b885d365b5814838e3c595bc17342553d3b68
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Nov 11 22:07:49 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Nov 11 22:07:49 2012 +0200

    Sublime Text 2 Gen: Per-source Compile flags are now saved in a separate file.
    
    We no longer write sublimeclang_options to the project file, but instead
    write a separate .sublimeclang-options JSON file that contains a map
    of source file paths to compile flags for that file.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 279d9f4..03e2e1d 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -105,8 +105,8 @@ void cmExtraSublimeTextGenerator
     }
 
   const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
-                     lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
-                     lgs[0]->GetMakefile()->GetHomeDirectory());
+                     mf->GetHomeOutputDirectory(),
+                     mf->GetHomeDirectory());
   // Write the folder entries to the project file
   fout << "{\n";
   fout << "\t\"folders\":\n\t[\n\t";
@@ -114,9 +114,8 @@ void cmExtraSublimeTextGenerator
     {
       fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
       const std::string &outputRelativeToSourceRoot =
-        cmSystemTools::RelativePath(lgs[0]->GetMakefile()->GetHomeDirectory(),
-                                    lgs[0]->GetMakefile()->
-                                      GetHomeOutputDirectory());
+        cmSystemTools::RelativePath(mf->GetHomeDirectory(),
+                                    mf->GetHomeOutputDirectory());
       if ((!outputRelativeToSourceRoot.empty()) &&
         ((outputRelativeToSourceRoot.length() < 3) ||
           (outputRelativeToSourceRoot.substr(0, 3) != "../")))
@@ -130,18 +129,6 @@ void cmExtraSublimeTextGenerator
       fout << "\t{\n\t\t\t\"path\": \"./\"";
     }
   fout << "\n\t\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.
-  // In the case of an in-source build, however, this must not be used, since
-  // it'll end up excluding the source directory.
-  if (!sourceRootRelativeToOutput.empty())
-  {
-    fout << ",\n\t\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}";
-  }
   // End of the folders section
   fout << "\n\t]";
 
@@ -151,9 +138,8 @@ void cmExtraSublimeTextGenerator
   // Set of include directories over all targets (sublime text/sublimeclang
   // doesn't currently support these settings per build system, only project
   // wide
-  std::set<std::string> includeDirs;
-  std::set<std::string> defines;
-  AppendAllTargets(lgs, mf, fout, includeDirs, defines);
+  MapSourceFileFlags sourceFileFlags;
+  AppendAllTargets(lgs, mf, fout, sourceFileFlags);
   // End of build_systems
   fout << "\n\t]";
 
@@ -162,7 +148,7 @@ void cmExtraSublimeTextGenerator
   // Check if the CMAKE_SUBLIMECLANG_DISABLED flag has been set. If it has
   // disable sublimeclang for this project.
   const char* sublimeclangDisabledValue =
-    lgs[0]->GetMakefile()->GetSafeDefinition("CMAKE_SUBLIMECLANG_DISABLED");
+    mf->GetSafeDefinition("CMAKE_SUBLIMECLANG_DISABLED");
   bool sublimeclangEnabled = cmSystemTools::IsOff(sublimeclangDisabledValue);
   // Per project sublimeclang settings override default and user settings,
   // so we only write the sublimeclang_enabled setting to the project file
@@ -171,60 +157,79 @@ void cmExtraSublimeTextGenerator
     {
       fout << "\t\"sublimeclang_enabled\": false,\n\t";
     }
-  fout << "\t\"sublimeclang_options\":\n\t\t[\n\t\t";
-  std::set<std::string>::const_iterator stringSetIter = includeDirs.begin();
-  while (stringSetIter != includeDirs.end())
-    {
-    const std::string &includeDir = *stringSetIter;
-    const std::string &relative = cmSystemTools::RelativePath(
-                       lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
-                       includeDir.c_str());
-    // 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" << includeDir << "\"";
-    stringSetIter++;
-    if ((stringSetIter != includeDirs.end()) || (!defines.empty()))
-      {
-      fout << ",";
-      }
-    fout << "\n\t\t";
-  }
-  stringSetIter = defines.begin();
-  while (stringSetIter != defines.end())
-    {
-    fout << "\t\"-D" << *stringSetIter << "\"";
-    stringSetIter++;
-    if (stringSetIter != defines.end())
-      {
-      fout << ",";
-      }
-    fout << "\n\t\t";
-  }
-  // End of the sublimeclang_options section
-  fout << "]\n\t";
+  std::string outputDir = mf->GetStartOutputDirectory();
+  std::string projectName = mf->GetProjectName();
+  std::string sublimeClangOptionsFilename = outputDir+"/";
+  sublimeClangOptionsFilename += projectName + ".sublimeclang-options";
+  fout << "\t\"sublimeclang_options_file\": \"" << sublimeClangOptionsFilename
+       << "\"\n\t";
   // End of the settings section
   fout << "}\n";
 
   // End of file
   fout << "}";
+
+  this->WriteSublimeClangOptionsFile(sourceFileFlags,
+    sublimeClangOptionsFilename);
+}
+
+void cmExtraSublimeTextGenerator::
+  WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
+                               const std::string& filename)
+{
+  cmGeneratedFileStream fout(filename.c_str());
+  if(!fout)
+    {
+    return;
+    }
+  fout << "{\n";
+  MapSourceFileFlags::const_iterator sourceFileFlagsEnd =
+    sourceFileFlags.end();
+  int totalFiles = sourceFileFlags.size();
+  int fileIndex = 0;
+  for (MapSourceFileFlags::const_iterator iter = sourceFileFlags.begin();
+    iter != sourceFileFlagsEnd; ++iter)
+    {
+    const std::string& sourceFilePath = iter->first;
+    const std::vector<std::string>& flags = iter->second;
+    fout << "\t\"" << sourceFilePath << "\":\n\t[\n\t";
+    std::vector<std::string>::const_iterator flagsEnd = flags.end();
+    for (std::vector<std::string>::const_iterator flagsIter = flags.begin();
+      flagsIter != flagsEnd; ++flagsIter)
+      {
+      fout << "\t\"" << *flagsIter << "\"";
+      if (flagsIter + 1 != flagsEnd)
+        {
+        fout << ",";
+        }
+      fout << "\n\t";
+      }
+      fout << "]";
+      if (fileIndex < totalFiles - 1)
+        {
+        fout << ",";
+        }
+      fout << "\n";
+      fileIndex++;
+    }
+  fout << "}\n";
 }
 
 void cmExtraSublimeTextGenerator::
   AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
                    const cmMakefile* mf,
                    cmGeneratedFileStream& fout,
-                   std::set<std::string>& includeDirs,
-                   std::set<std::string>& defines)
+                   MapSourceFileFlags& sourceFileFlags)
 {
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string compiler = "";
-  this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str(),
-                     includeDirs, defines, true);
-  this->AppendTarget(fout, "clean", 0, make.c_str(), mf, compiler.c_str(),
-                     includeDirs, defines, false);
+  if (!lgs.empty())
+    {
+      this->AppendTarget(fout, "all", lgs[0], 0, make.c_str(), mf,
+                         compiler.c_str(), sourceFileFlags, true);
+      this->AppendTarget(fout, "clean", lgs[0], 0, make.c_str(), mf,
+                         compiler.c_str(), sourceFileFlags, false);
+    }
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
@@ -265,9 +270,9 @@ void cmExtraSublimeTextGenerator::
             }
           if (insertTarget)
             {
-            this->AppendTarget(fout, ti->first.c_str(), 0,
+            this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
                                make.c_str(), makefile, compiler.c_str(),
-                               includeDirs, defines, false);
+                               sourceFileFlags, false);
             }
           }
           break;
@@ -282,9 +287,9 @@ void cmExtraSublimeTextGenerator::
             break;
             }
 
-          this->AppendTarget(fout, ti->first.c_str(), 0,
+          this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
                              make.c_str(), makefile, compiler.c_str(),
-                             includeDirs, defines, false);
+                             sourceFileFlags, false);
           break;
         case cmTarget::EXECUTABLE:
         case cmTarget::STATIC_LIBRARY:
@@ -292,14 +297,14 @@ void cmExtraSublimeTextGenerator::
         case cmTarget::MODULE_LIBRARY:
         case cmTarget::OBJECT_LIBRARY:
           {
-          this->AppendTarget(fout, ti->first.c_str(), &ti->second,
+          this->AppendTarget(fout, ti->first.c_str(), *lg, &ti->second,
                              make.c_str(), makefile, compiler.c_str(),
-                             includeDirs, defines, false);
+                             sourceFileFlags, false);
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
+          this->AppendTarget(fout, fastTarget.c_str(), *lg, &ti->second,
                              make.c_str(), makefile, compiler.c_str(),
-                             includeDirs, defines, false);
+                             sourceFileFlags, false);
           }
           break;
         default:
@@ -310,95 +315,65 @@ void cmExtraSublimeTextGenerator::
 }
 
 void cmExtraSublimeTextGenerator::
-  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());
-    std::string safedefString = safedef.str();
-    if ((flagLength == 0) || ((safedefString.length() >= flagLength) &&
-      (safedefString.substr(0, flagLength) == flag)))
-      {
-        if (flagLength > 0)
-          {
-          defines.insert(safedefString.substr(flagLength));
-          }
-        else
-          {
-          defines.insert(safedefString);
-          }
-      }
-    }
-}
-
-void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
-                                              const char* targetName,
-                                              cmTarget* target,
-                                              const char* make,
-                                              const cmMakefile* makefile,
-                                              const char* compiler,
-                                              std::set<std::string>&
-                                                              includeDirs,
-                                              std::set<std::string>& defines,
-                                              bool firstTarget)
+  AppendTarget(cmGeneratedFileStream& fout,
+               const char* targetName,
+               cmLocalGenerator* lg,
+               cmTarget* target,
+               const char* make,
+               const cmMakefile* makefile,
+               const char* compiler,
+               MapSourceFileFlags& sourceFileFlags,
+               bool firstTarget)
 {
   if (target != 0)
     {
-      // the compilerdefines for this target
       cmGeneratorTarget *gtgt = this->GlobalGenerator
                                     ->GetGeneratorTarget(target);
-      std::string cdefs = gtgt->GetCompileDefinitions();
-      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");
-      ExtractFlags(cflags.c_str(), "-D", defines);
-      ExtractFlags(cflags.c_str(), "-I", includeDirs);
-      cflags = makefile->GetSafeDefinition("CMAKE_C_FLAGS");
-      ExtractFlags(cflags.c_str(), "-D", defines);
-      ExtractFlags(cflags.c_str(), "-I", includeDirs);
-      // the include directories for this target
-      std::vector<std::string> includes;
-      target->GetMakefile()->GetLocalGenerator()->
-        GetIncludeDirectories(includes, gtgt);
-      for(std::vector<std::string>::const_iterator dirIt=includes.begin();
-          dirIt != includes.end();
-          ++dirIt)
-        {
-        includeDirs.insert(*dirIt);
-        }
-
-      std::string systemIncludeDirs = makefile->GetSafeDefinition(
-                                "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
-      if (!systemIncludeDirs.empty())
-        {
-        std::vector<std::string> dirs;
-        cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
-        for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
-            dirIt != dirs.end();
-            ++dirIt)
-          {
-          includeDirs.insert(*dirIt);
-          }
-        }
-
-      systemIncludeDirs = makefile->GetSafeDefinition(
-                            "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
-      if (!systemIncludeDirs.empty())
+      std::vector<cmSourceFile*> const& sourceFiles = target->GetSourceFiles();
+      std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
+        sourceFiles.end();
+      for (std::vector<cmSourceFile*>::const_iterator iter =
+        sourceFiles.begin(); iter != sourceFilesEnd; ++iter)
         {
-        std::vector<std::string> dirs;
-        cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
-        for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
-            dirIt != dirs.end();
-            ++dirIt)
-          {
-          includeDirs.insert(*dirIt);
-          }
+          cmSourceFile* sourceFile = *iter;
+          MapSourceFileFlags::iterator sourceFileFlagsIter =
+            sourceFileFlags.find(sourceFile->GetFullPath());
+          if (sourceFileFlagsIter == sourceFileFlags.end())
+            {
+            sourceFileFlagsIter =
+              sourceFileFlags.insert(MapSourceFileFlags::value_type(
+                sourceFile->GetFullPath(), std::vector<std::string>())).first;
+            }
+          std::vector<std::string>& flags = sourceFileFlagsIter->second;
+          std::string flagsString =
+            this->ComputeFlagsForObject(*iter, lg, target, gtgt);
+          std::string definesString =
+            this->ComputeDefines(*iter, lg, target, gtgt);
+          flags.clear();
+          cmsys::RegularExpression flagRegex;
+          // https://gist.github.com/3944250
+          const char* regexString =
+            "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
+          flagRegex.compile(regexString);
+          std::string workString = flagsString + " " + definesString;
+          while (flagRegex.find(workString))
+            {
+              std::string::size_type start = flagRegex.start();
+              if (workString[start] == ' ')
+                {
+                  start++;
+                }
+              flags.push_back(workString.substr(start,
+                flagRegex.end() - start));
+              if (flagRegex.end() < workString.size())
+                {
+                workString = workString.substr(flagRegex.end());
+                }
+                else
+                {
+                workString = "";
+                }
+            }
         }
     }
 
@@ -473,3 +448,121 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
     }
   return command;
 }
+
+// TODO: Most of the code is picked up from the Ninja generator, refactor it.
+std::string
+cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
+                                                   cmLocalGenerator* lg,
+                                                   cmTarget *target,
+                                                   cmGeneratorTarget* gtgt)
+{
+  std::string flags;
+
+  cmMakefile *makefile = lg->GetMakefile();
+  const char* language = source->GetLanguage();
+  if (language == NULL)
+   {
+   language = "C";
+   }
+  const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  // Add language-specific flags.
+  lg->AddLanguageFlags(flags, language, config);
+
+  lg->AddArchitectureFlags(flags, gtgt, language, config);
+
+  // TODO: Fortran support.
+  // // Fortran-specific flags computed for this target.
+  // if(*l == "Fortran")
+  //   {
+  //   this->AddFortranFlags(flags);
+  //   }
+
+  // Add shared-library flags if needed.
+  lg->AddCMP0018Flags(flags, target, language);
+
+  // Add include directory flags.
+  {
+  std::vector<std::string> includes;
+  lg->GetIncludeDirectories(includes, gtgt, language, config);
+  std::string includeFlags =
+    lg->GetIncludeFlags(includes, language, true); // full include paths
+  lg->AppendFlags(flags, includeFlags.c_str());
+  }
+
+  // Append old-style preprocessor definition flags.
+  lg->AppendFlags(flags, makefile->GetDefineFlags());
+
+  // Add target-specific flags.
+  if(gtgt->GetProperty("COMPILE_FLAGS"))
+    {
+    std::string langIncludeExpr = "CMAKE_";
+    langIncludeExpr += language;
+    langIncludeExpr += "_FLAG_REGEX";
+    const char* regex = makefile->GetDefinition(langIncludeExpr.c_str());
+    if(regex)
+      {
+      cmsys::RegularExpression r(regex);
+      std::vector<std::string> args;
+      cmSystemTools::
+        ParseWindowsCommandLine(gtgt->GetProperty("COMPILE_FLAGS"), args);
+      for(std::vector<std::string>::iterator i = args.begin();
+          i != args.end(); ++i)
+        {
+        if(r.find(i->c_str()))
+          {
+          lg->AppendFlags(flags, i->c_str());
+          }
+        }
+      }
+    else
+      {
+      lg->AppendFlags(flags, gtgt->GetProperty("COMPILE_FLAGS"));
+      }
+    }
+
+  // Add source file specific flags.
+  lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
+
+  // TODO: Handle Apple frameworks.
+
+  return flags;
+}
+
+// TODO: Refactor with
+// void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
+std::string
+cmExtraSublimeTextGenerator::
+ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
+               cmGeneratorTarget* gtgt)
+
+{
+  std::set<std::string> defines;
+  cmMakefile *makefile = lg->GetMakefile();
+  const char* language = source->GetLanguage();
+  if (language == NULL)
+   {
+   language = "";
+   }
+  const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+
+  // Add the export symbol definition for shared library objects.
+  if(const char* exportMacro = target->GetExportMacro())
+    {
+    lg->AppendDefines(defines, exportMacro);
+    }
+
+  // Add preprocessor definitions for this target and configuration.
+  lg->AppendDefines(defines, gtgt->GetCompileDefinitions());
+  lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
+  {
+  std::string defPropName = "COMPILE_DEFINITIONS_";
+  defPropName += cmSystemTools::UpperCase(config);
+  lg->AppendDefines(defines, gtgt->GetCompileDefinitions(config));
+  lg->AppendDefines(defines, source->GetProperty(defPropName.c_str()));
+  }
+
+  std::string definesString;
+  lg->JoinDefines(defines, definesString, language);
+
+  return definesString;
+}
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index fe8832f..26e09a6 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -14,11 +14,13 @@
 #define cmExtraSublimeTextGenerator_h
 
 #include "cmExternalMakefileProjectGenerator.h"
+#include "cmSourceFile.h"
 
 class cmLocalGenerator;
 class cmMakefile;
 class cmTarget;
 class cmGeneratedFileStream;
+class cmGeneratorTarget;
 
 /** \class cmExtraSublimeTextGenerator
  * \brief Write Sublime Text 2 project files for Makefile based projects
@@ -26,6 +28,7 @@ class cmGeneratedFileStream;
 class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
 {
 public:
+  typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
   cmExtraSublimeTextGenerator();
 
   virtual const char* GetName() const
@@ -45,14 +48,15 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
+  void WriteSublimeClangOptionsFile(const MapSourceFileFlags& sourceFileFlags,
+                                    const std::string& filename);
   /** Appends all targets as build systems to the project file and get all
    * include directories and compiler definitions used.
    */
   void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
                         const cmMakefile* mf,
                         cmGeneratedFileStream& fout,
-                        std::set<std::string>& includeDirs,
-                        std::set<std::string>& defines);
+                        MapSourceFileFlags& sourceFileFlags);
   /** Returns the build command that needs to be executed to build the
    *  specified target.
    */
@@ -63,18 +67,24 @@ private:
    */
   void AppendTarget(cmGeneratedFileStream& fout,
                     const char* targetName,
+                    cmLocalGenerator* lg,
                     cmTarget* target,
                     const char* make,
                     const cmMakefile* makefile,
                     const char* compiler,
-                    std::set<std::string>& includeDirs,
-                    std::set<std::string>& defines, bool firstTarget);
+                    MapSourceFileFlags& sourceFileFlags, bool firstTarget);
   /**
-   * Extracts compile flags from a variable.
-   * flag would typically be "-D" or "-I"
+   * Compute the flags for compilation of object files for a given @a language.
+   * @note Generally it is the value of the variable whose name is computed
+   *       by LanguageFlagsVarName().
    */
-  void ExtractFlags(const char* value, const std::string& flag,
-                    std::set<std::string> &defines);
+  std::string ComputeFlagsForObject(cmSourceFile *source,
+                                    cmLocalGenerator* lg,
+                                    cmTarget *target,
+                                    cmGeneratorTarget* gtgt);
+
+  std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
+                             cmTarget *target, cmGeneratorTarget* gtgt);
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b2aa3dd9af903e7aae0a252d2119847ceac4aa0
commit 5b2aa3dd9af903e7aae0a252d2119847ceac4aa0
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Wed Nov 7 21:45:07 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Wed Nov 7 21:45:07 2012 +0200

    SublimeText2 Gen: Fixed the issue where include directory flags used -D

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 64796c8..279d9f4 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -361,7 +361,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
       ExtractFlags(cflags.c_str(), "-I", includeDirs);
       cflags = makefile->GetSafeDefinition("CMAKE_C_FLAGS");
       ExtractFlags(cflags.c_str(), "-D", defines);
-      ExtractFlags(cflags.c_str(), "-D", includeDirs);
+      ExtractFlags(cflags.c_str(), "-I", includeDirs);
       // the include directories for this target
       std::vector<std::string> includes;
       target->GetMakefile()->GetLocalGenerator()->

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90bcb77956464b53aaf2ce8d17b2a878f74ce27e
commit 90bcb77956464b53aaf2ce8d17b2a878f74ce27e
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Nov 4 16:15:04 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Nov 4 16:15:04 2012 +0200

    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.

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

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc84072156ffe7e57248d2207dba6d9fd2b57146
commit cc84072156ffe7e57248d2207dba6d9fd2b57146
Merge: 8670cbe 314e7fb
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Nov 4 14:15:52 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Nov 4 14:15:52 2012 +0200

    Merge branch 'master' into sublime-text-2-generator


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8670cbe1660acbb8abc638e29ed60a2e27c0716a
commit 8670cbe1660acbb8abc638e29ed60a2e27c0716a
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Thu Oct 18 22:54:19 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Thu Oct 18 22:54:19 2012 +0200

    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.

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

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d022d4ec78bcb0d3be93479b514f5275703d9a30
commit d022d4ec78bcb0d3be93479b514f5275703d9a30
Merge: 9cd3e70 7ded904
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Wed Oct 17 23:29:53 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Wed Oct 17 23:29:53 2012 +0200

    Merge branch 'master' into sublime-text-2-generator


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cd3e7071f1769eb6bd751a501d36c6130019a1a
commit 9cd3e7071f1769eb6bd751a501d36c6130019a1a
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Oct 14 17:37:51 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Oct 14 17:37:51 2012 +0200

    Fixed Sublime Text project generation for in-source builds
    
    Fixed the issue where for in-source builds the source directory
    (which is also the build directory) was excluded from the project file.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 5c20ef9..ea15be5 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -107,26 +107,38 @@ void cmExtraSublimeTextGenerator
   const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
                      lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
                      lgs[0]->GetMakefile()->GetHomeDirectory());
-  const std::string &outputRelativeToSourceRoot = cmSystemTools::RelativePath(
-                     lgs[0]->GetMakefile()->GetHomeDirectory(),
-                     lgs[0]->GetMakefile()->GetHomeOutputDirectory());
   // Write the folder entries to the project file
   fout << "{\n";
   fout << "\t\"folders\":\n\t[\n\t";
-  fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\",\n";
-  fout << "\t\t\t\"folder_exclude_patterns\": [\"" <<
-          outputRelativeToSourceRoot << "\"],\n";
-  fout << "\t\t\t\"file_exclude_patterns\": []\n";
-  fout << "\t\t},\n\t";
+  if (!sourceRootRelativeToOutput.empty())
+    {
+      fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
+      const std::string &outputRelativeToSourceRoot =
+        cmSystemTools::RelativePath(lgs[0]->GetMakefile()->GetHomeDirectory(),
+                                    lgs[0]->GetMakefile()->
+                                      GetHomeOutputDirectory());
+      fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" <<
+              outputRelativeToSourceRoot << "\"]";
+    }
+  else
+    {
+      fout << "\t{\n\t\t\t\"path\": \"./\"";
+    }
+  fout << "\n\t\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";
+  // that no files or subfolders are included.
+  // In the case of an in-source build, however, this must not be used, since
+  // it'll end up excluding the source directory.
+  if (!sourceRootRelativeToOutput.empty())
+  {
+    fout << ",\n\t\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}";
+  }
   // End of the folders section
-  fout << "]";
+  fout << "\n\t]";
 
   // Write the beginning of the build systems section to the project file
   fout << ",\n\t\"build_systems\":\n\t[\n\t";

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44f35f7824c0d97d575ab566a1f9fd1c83be8fc8
commit 44f35f7824c0d97d575ab566a1f9fd1c83be8fc8
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Oct 14 14:06:20 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Oct 14 14:06:20 2012 +0200

    Added a CMAKE_SUBLIMECLANG_DISABLED variable that disables SublimeClang.
    
    If the CMAKE_SUBLIMECLANG_DISABLED variable is on then SublimeClang
    is disabled in the generated project file. This is useful in large
    projects where SublimeClang might run slowly or perform poorly.

diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 8db0e8f..6232162 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -896,6 +896,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
       " script, it may get fatal error messages from the script.",false,
       "Variables That Change Behavior");
 
+  cm->DefineProperty
+    ("CMAKE_SUBLIMECLANG_DISABLED", cmProperty::VARIABLE,
+     "Used by the Sublime Text 2 generator to disable SublimeClang in "
+     "generated project files.",
+     "For very large projects SublimeClang might run slowly. Set this variable"
+     " to TRUE to instruct the Sublime Text 2 generator to disable "
+     " SublimeClang in the generated project files.", false,
+     "Variables That Change Behavior");
+
   // Variables defined by CMake that describe the system
 
   cm->DefineProperty
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index af26965..5c20ef9 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -47,7 +47,7 @@ void cmExtraSublimeTextGenerator
     "Project files for Sublime Text 2 will be created in the top directory "
     "and in every subdirectory which features a CMakeLists.txt file "
     "containing a PROJECT() call. "
-    "Additionally a hierarchy of makefiles is generated into the "
+    "Additionally Makefiles (or build.ninja files) are generated into the "
     "build tree.  The appropriate make program can build the project through "
     "the default make target.  A \"make install\" target is also provided.";
 }
@@ -142,6 +142,18 @@ void cmExtraSublimeTextGenerator
 
   // Write the settings section with sublimeclang options
   fout << ",\n\t\"settings\":\n\t{\n\t";
+  // Check if the CMAKE_SUBLIMECLANG_DISABLED flag has been set. If it has
+  // disable sublimeclang for this project.
+  const char* sublimeclangDisabledValue =
+    lgs[0]->GetMakefile()->GetSafeDefinition("CMAKE_SUBLIMECLANG_DISABLED");
+  bool sublimeclangEnabled = cmSystemTools::IsOff(sublimeclangDisabledValue);
+  // Per project sublimeclang settings override default and user settings,
+  // so we only write the sublimeclang_enabled setting to the project file
+  // if it is set to be disabled.
+  if (!sublimeclangEnabled)
+    {
+      fout << "\t\"sublimeclang_enabled\": false,\n\t";
+    }
   fout << "\t\"sublimeclang_options\":\n\t\t[\n\t\t";
   std::set<std::string>::const_iterator stringSetIter = includeDirs.begin();
   while (stringSetIter != includeDirs.end())

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9657acb55a62f2e37a0378d01e93ab2ee4d151be
commit 9657acb55a62f2e37a0378d01e93ab2ee4d151be
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Oct 14 12:11:32 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Oct 14 12:11:32 2012 +0200

    The generator no longer generates absolute paths to the ninja.build/Makefiles.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index ab8af7e..af26965 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -351,17 +351,16 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
         }
     }
 
-  // Write out the build_system data for this target
-  std::string makefileName = makefile->GetHomeOutputDirectory();
   // Ninja uses ninja.build files (look for a way to get the output file name
-  // from cmMakefile)
+  // from cmMakefile or something)
+  std::string makefileName;
   if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
     {
-      makefileName += "/build.ninja";
+      makefileName = "build.ninja";
     }
     else
     {
-      makefileName += "/Makefile";
+      makefileName = "Makefile";
     }
   if (!firstTarget)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6742ee747f5d55bef73bed2c70611e8542f28f43
commit 6742ee747f5d55bef73bed2c70611e8542f28f43
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sun Oct 14 10:46:29 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sun Oct 14 10:46:29 2012 +0200

    The generator no longer generates an explicit list of source files.
    
    Now the source directory is simply added to the project file,
    with the output/build directory excluded.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index f116088..ab8af7e 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -23,12 +23,6 @@
 
 #include <cmsys/SystemTools.hxx>
 
-#if defined(_WIN32)
-#  define PATH_SEP "\\"
-#else
-#  define PATH_SEP "/"
-#endif
-
 /*
 Sublime Text 2 Generator
 Author: Morné Chamberlain
@@ -110,36 +104,19 @@ void cmExtraSublimeTextGenerator
     return;
     }
 
-  // Collect all files, this includes source files and list files
-  std::vector<std::string> allFiles;
-  GetFileList(lgs, allFiles);
-  // A set of folders to include in the project
-  std::set<std::string> folderIncludePatternsSet;
-  std::stringstream fileIncludePatternsStream;
-  GetFileStringAndFolderSet(lgs, mf, allFiles, fileIncludePatternsStream,
-                            folderIncludePatternsSet);
-  // Write the folder entries to the project file
-  const std::string &homeRelative = cmSystemTools::RelativePath(
+  const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
                      lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
                      lgs[0]->GetMakefile()->GetHomeDirectory());
+  const std::string &outputRelativeToSourceRoot = cmSystemTools::RelativePath(
+                     lgs[0]->GetMakefile()->GetHomeDirectory(),
+                     lgs[0]->GetMakefile()->GetHomeOutputDirectory());
+  // Write the folder entries to the project file
   fout << "{\n";
   fout << "\t\"folders\":\n\t[\n\t";
-  fout << "\t{\n\t\t\t\"path\": \"" << homeRelative << "\",\n";
-  fout << "\t\t\t\"folder_include_patterns\": [";
-  std::set<std::string>::const_iterator folderIter =
-          folderIncludePatternsSet.begin();
-  while (folderIter != folderIncludePatternsSet.end())
-    {
-    fout << "\"" << *folderIter << "\"";
-    folderIter++;
-    if (folderIter != folderIncludePatternsSet.end())
-      {
-        fout << ", ";
-      }
-    }
-  fout << "],\n";
-  fout << "\t\t\t\"file_include_patterns\": [" <<
-          fileIncludePatternsStream.str() << "]\n";
+  fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\",\n";
+  fout << "\t\t\t\"folder_exclude_patterns\": [\"" <<
+          outputRelativeToSourceRoot << "\"],\n";
+  fout << "\t\t\t\"file_exclude_patterns\": []\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
@@ -205,113 +182,6 @@ void cmExtraSublimeTextGenerator
   fout << "}";
 }
 
-void cmExtraSublimeTextGenerator
-  ::GetFileList(const std::vector<cmLocalGenerator*>& lgs,
-                std::vector<std::string>& allFiles)
-{
-  for (std::vector<cmLocalGenerator *>::const_iterator
-       it = lgs.begin();
-       it != lgs.end();
-       ++it)
-    {
-    cmMakefile* makefile=(*it)->GetMakefile();
-    // Add list files
-    const std::vector<std::string> & listFiles =
-                                            makefile->GetListFiles();
-    allFiles.insert(allFiles.end(), listFiles.begin(), listFiles.end());
-    // Add source files
-    cmTargets& targets=makefile->GetTargets();
-    for (cmTargets::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
-      switch(ti->second.GetType())
-        {
-        case cmTarget::EXECUTABLE:
-        case cmTarget::STATIC_LIBRARY:
-        case cmTarget::SHARED_LIBRARY:
-        case cmTarget::MODULE_LIBRARY:
-        case cmTarget::OBJECT_LIBRARY:
-        case cmTarget::UTILITY: // can have sources since 2.6.3
-          {
-          const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles();
-          for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
-               si!=sources.end(); si++)
-            {
-            // don't add source files which have the GENERATED property set:
-            if ((*si)->GetPropertyAsBool("GENERATED"))
-              {
-              continue;
-              }
-              allFiles.push_back((*si)->GetFullPath());
-            }
-          }
-        default:  // intended fallthrough
-           break;
-        }
-      }
-    }
-}
-
-void cmExtraSublimeTextGenerator::
-  GetFileStringAndFolderSet(const std::vector<cmLocalGenerator*>& lgs,
-                            const cmMakefile* mf,
-                            const std::vector<std::string>& allFiles,
-                            std::stringstream& fileIncludePatternsStream,
-                            std::set<std::string>& folderIncludePatternsSet)
-{
-  const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
-  for (std::vector<std::string>::const_iterator jt = allFiles.begin();
-       jt != allFiles.end();
-       ++jt)
-    {
-    // don't put cmake's own files into the project (#12110):
-    if (jt->find(cmakeRoot) == 0)
-      {
-      continue;
-      }
-
-    const std::string &relative = cmSystemTools::RelativePath(
-                       lgs[0]->GetMakefile()->GetHomeDirectory(),
-                       jt->c_str());
-    // Split filename from path
-    std::string fileName = cmSystemTools::GetFilenameName(relative);
-    std::string path = "";
-    if (fileName.length() < relative.length())
-      {
-      path = relative.substr(0, relative.length() - fileName.length() - 1);
-      }
-
-    // We don't want paths with CMakeFiles in them
-    if (relative.find("CMakeFiles") == std::string::npos)
-      {
-      if (fileIncludePatternsStream.tellp() > 0)
-        {
-          fileIncludePatternsStream << ", ";
-        }
-      fileIncludePatternsStream << "\"" << relative << "\"";
-      if ((!path.empty()) && (folderIncludePatternsSet.find(path) ==
-                              folderIncludePatternsSet.end()))
-        {
-        folderIncludePatternsSet.insert(path);
-        std::string::size_type splitIndex = path.rfind(PATH_SEP);
-        std::string splitPath = path;
-        while (splitIndex != std::string::npos)
-          {
-          splitPath = splitPath.substr(0, splitIndex);
-          if ((splitPath.empty()) ||
-                  (folderIncludePatternsSet.insert(splitPath).second == false))
-            {
-            // If the path is already in the set then all of its
-            // parents are as well
-            break;
-            }
-          splitIndex = splitPath.rfind(PATH_SEP);
-          }
-        }
-      }
-    }
-}
-
 void cmExtraSublimeTextGenerator::
   AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
                    const cmMakefile* mf,
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 05d3526..05ab421 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -45,21 +45,6 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
-  /** Populates allFiles with the full paths to all of the source files
-   *  from the local generators in lgs.
-   */
-  void GetFileList(const std::vector<cmLocalGenerator*>& lgs,
-                   std::vector<std::string>& allFiles);
-  /** Sends comma seperated source files paths to fileIncludePatternsStream
-   *  and builds a set of all directories and subdirectories containing
-   *  source files.
-   */
-  void GetFileStringAndFolderSet(const std::vector<cmLocalGenerator*>& lgs,
-                                 const cmMakefile* mf,
-                                 const std::vector<std::string>& allFiles,
-                                 std::stringstream& fileIncludePatternsStream,
-                                 std::set<std::string>&
-                                   folderIncludePatternsSet);
   /** Appends all targets as build systems to the project file and get all
    * include directories and compiler definitions used.
    */

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd76ec3e22f299f03e34db3deee5e835613af315
commit cd76ec3e22f299f03e34db3deee5e835613af315
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sat Oct 13 12:54:51 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 12:54:51 2012 +0200

    Added and cleaned up some comments.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 1338241..f116088 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -86,7 +86,6 @@ void cmExtraSublimeTextGenerator::Generate()
 }
 
 
-/* create the project file */
 void cmExtraSublimeTextGenerator::CreateProjectFile(
                                      const std::vector<cmLocalGenerator*>& lgs)
 {
@@ -206,8 +205,6 @@ void cmExtraSublimeTextGenerator
   fout << "}";
 }
 
-// Get a list of all files and a set of all directories and subdirectories
-// with source files
 void cmExtraSublimeTextGenerator
   ::GetFileList(const std::vector<cmLocalGenerator*>& lgs,
                 std::vector<std::string>& allFiles)
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index e23e472..05d3526 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -45,8 +45,15 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
+  /** Populates allFiles with the full paths to all of the source files
+   *  from the local generators in lgs.
+   */
   void GetFileList(const std::vector<cmLocalGenerator*>& lgs,
                    std::vector<std::string>& allFiles);
+  /** Sends comma seperated source files paths to fileIncludePatternsStream
+   *  and builds a set of all directories and subdirectories containing
+   *  source files.
+   */
   void GetFileStringAndFolderSet(const std::vector<cmLocalGenerator*>& lgs,
                                  const cmMakefile* mf,
                                  const std::vector<std::string>& allFiles,
@@ -61,8 +68,14 @@ private:
                         cmGeneratedFileStream& fout,
                         std::set<std::string>& includeDirs,
                         std::set<std::string>& defines);
+  /** Returns the build command that needs to be executed to build the
+   *  specified target.
+   */
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
                                const char* target);
+  /** Appends the specified target to the generated project file as a Sublime
+   *  Text build system.
+   */
   void AppendTarget(cmGeneratedFileStream& fout,
                     const char* targetName,
                     cmTarget* target,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef8aa081a164817d1d78b6df8ebcf23e421d422f
commit ef8aa081a164817d1d78b6df8ebcf23e421d422f
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Sat Oct 13 11:20:09 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 11:20:09 2012 +0200

    Fixed support for the Ninja build system.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 6a95aa3..1338241 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -29,7 +29,12 @@
 #  define PATH_SEP "/"
 #endif
 
-/* Some useful URLs:
+/*
+Sublime Text 2 Generator
+Author: Morné Chamberlain
+This generator was initially based off of the CodeBlocks generator.
+
+Some useful URLs:
 Homepage:
 http://www.sublimetext.com/
 
@@ -257,7 +262,6 @@ void cmExtraSublimeTextGenerator::
                             std::stringstream& fileIncludePatternsStream,
                             std::set<std::string>& folderIncludePatternsSet)
 {
-  // Convert
   const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
   for (std::vector<std::string>::const_iterator jt = allFiles.begin();
        jt != allFiles.end();
@@ -481,8 +485,17 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
     }
 
   // Write out the build_system data for this target
-  std::string makefileName = makefile->GetStartOutputDirectory();
-  makefileName += "/Makefile";
+  std::string makefileName = makefile->GetHomeOutputDirectory();
+  // Ninja uses ninja.build files (look for a way to get the output file name
+  // from cmMakefile)
+  if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+    {
+      makefileName += "/build.ninja";
+    }
+    else
+    {
+      makefileName += "/Makefile";
+    }
   if (!firstTarget)
     {
     fout << ",\n\t";
@@ -513,20 +526,28 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
     command += target;
     command += "\"";
     }
-  else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+  else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
     {
-    // no escaping of spaces in this case, see
-    // http://public.kitware.com/Bug/view.php?id=10014
-    std::string makefileName = makefile;
+    std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += ", \"-f\", \"";
     command += makefileName + "\"";
-    command += ", \"VERBOSE=1\", \"";
+    command += ", \"-v\", \"";
     command += target;
     command += "\"";
     }
   else
     {
-    std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
+    std::string makefileName;
+    if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+      {
+        // no escaping of spaces in this case, see
+        // http://public.kitware.com/Bug/view.php?id=10014
+        makefileName = makefile;
+      }
+      else
+      {
+        makefileName = cmSystemTools::ConvertToOutputPath(makefile);
+      }
     command += ", \"-f\", \"";
     command += makefileName + "\"";
     command += ", \"VERBOSE=1\", \"";

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d585b109d5f5984d285a82c5582f9b585e9792b
commit 4d585b109d5f5984d285a82c5582f9b585e9792b
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Thu Oct 11 22:53:40 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 09:47:50 2012 +0200

    Cleaned up the Sublime Text 2 Generator code a bit.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 486658d..6a95aa3 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -106,11 +106,107 @@ void cmExtraSublimeTextGenerator
     return;
     }
 
-  // A set of folders to include in the project
-  std::set<std::string> folderIncludePatternsSet;
   // Collect all files, this includes source files and list files
   std::vector<std::string> allFiles;
+  GetFileList(lgs, allFiles);
+  // A set of folders to include in the project
+  std::set<std::string> folderIncludePatternsSet;
   std::stringstream fileIncludePatternsStream;
+  GetFileStringAndFolderSet(lgs, mf, allFiles, fileIncludePatternsStream,
+                            folderIncludePatternsSet);
+  // Write the folder entries to the project file
+  const std::string &homeRelative = cmSystemTools::RelativePath(
+                     lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
+                     lgs[0]->GetMakefile()->GetHomeDirectory());
+  fout << "{\n";
+  fout << "\t\"folders\":\n\t[\n\t";
+  fout << "\t{\n\t\t\t\"path\": \"" << homeRelative << "\",\n";
+  fout << "\t\t\t\"folder_include_patterns\": [";
+  std::set<std::string>::const_iterator folderIter =
+          folderIncludePatternsSet.begin();
+  while (folderIter != folderIncludePatternsSet.end())
+    {
+    fout << "\"" << *folderIter << "\"";
+    folderIter++;
+    if (folderIter != folderIncludePatternsSet.end())
+      {
+        fout << ", ";
+      }
+    }
+  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 << "]";
+
+  // Write the beginning of the build systems section to the project file
+  fout << ",\n\t\"build_systems\":\n\t[\n\t";
+
+  // Set of include directories over all targets (sublime text/sublimeclang
+  // doesn't currently support these settings per build system, only project
+  // wide
+  std::set<std::string> includeDirs;
+  std::set<std::string> defines;
+  AppendAllTargets(lgs, mf, fout, includeDirs, defines);
+  // End of build_systems
+  fout << "\n\t]";
+
+  // Write the settings section with sublimeclang options
+  fout << ",\n\t\"settings\":\n\t{\n\t";
+  fout << "\t\"sublimeclang_options\":\n\t\t[\n\t\t";
+  std::set<std::string>::const_iterator stringSetIter = includeDirs.begin();
+  while (stringSetIter != includeDirs.end())
+    {
+    const std::string &includeDir = *stringSetIter;
+    const std::string &relative = cmSystemTools::RelativePath(
+                       lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
+                       includeDir.c_str());
+    // 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 << "\"";
+    stringSetIter++;
+    if ((stringSetIter != includeDirs.end()) || (!defines.empty()))
+      {
+      fout << ",";
+      }
+    fout << "\n\t\t";
+  }
+  stringSetIter = defines.begin();
+  while (stringSetIter != defines.end())
+    {
+    fout << "\t\"-D" << *stringSetIter << "\"";
+    stringSetIter++;
+    if (stringSetIter != defines.end())
+      {
+      fout << ",";
+      }
+    fout << "\n\t\t";
+  }
+  // End of the sublimeclang_options section
+  fout << "]\n\t";
+  // End of the settings section
+  fout << "}\n";
+
+  // End of file
+  fout << "}";
+}
+
+// Get a list of all files and a set of all directories and subdirectories
+// with source files
+void cmExtraSublimeTextGenerator
+  ::GetFileList(const std::vector<cmLocalGenerator*>& lgs,
+                std::vector<std::string>& allFiles)
+{
   for (std::vector<cmLocalGenerator *>::const_iterator
        it = lgs.begin();
        it != lgs.end();
@@ -152,7 +248,15 @@ void cmExtraSublimeTextGenerator
         }
       }
     }
+}
 
+void cmExtraSublimeTextGenerator::
+  GetFileStringAndFolderSet(const std::vector<cmLocalGenerator*>& lgs,
+                            const cmMakefile* mf,
+                            const std::vector<std::string>& allFiles,
+                            std::stringstream& fileIncludePatternsStream,
+                            std::set<std::string>& folderIncludePatternsSet)
+{
   // Convert
   const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
   for (std::vector<std::string>::const_iterator jt = allFiles.begin();
@@ -205,47 +309,15 @@ void cmExtraSublimeTextGenerator
         }
       }
     }
-  // Write the folder entries to the project file
-  const std::string &homeRelative = cmSystemTools::RelativePath(
-                     lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
-                     lgs[0]->GetMakefile()->GetHomeDirectory());
-  fout << "{\n";
-  fout << "\t\"folders\":\n\t[\n\t";
-  fout << "\t{\n\t\t\t\"path\": \"" << homeRelative << "\",\n";
-  fout << "\t\t\t\"folder_include_patterns\": [";
-  std::set<std::string>::const_iterator folderIter =
-          folderIncludePatternsSet.begin();
-  while (folderIter != folderIncludePatternsSet.end())
-    {
-    fout << "\"" << *folderIter << "\"";
-    folderIter++;
-    if (folderIter != folderIncludePatternsSet.end())
-      {
-        fout << ", ";
-      }
-    }
-  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 << "]";
-
-  // Write the beginning of the build systems section to the project file
-  fout << ",\n\t\"build_systems\":\n\t[\n\t";
+}
 
-  // Set of include directories over all targets (sublime text/sublimeclang
-  // doesn't currently support these settings per build system, only project
-  // wide
-  std::set<std::string> includeDirs;
-  std::set<std::string> defines;
+void cmExtraSublimeTextGenerator::
+  AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
+                   const cmMakefile* mf,
+                   cmGeneratedFileStream& fout,
+                   std::set<std::string>& includeDirs,
+                   std::set<std::string>& defines)
+{
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string compiler = "";
   this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str(),
@@ -334,49 +406,6 @@ void cmExtraSublimeTextGenerator
         }
       }
     }
-  // End of build_systems
-  fout << "\n\t]";
-
-  // Write the settings section with sublimeclang options
-  fout << ",\n\t\"settings\":\n\t{\n\t";
-  fout << "\t\"sublimeclang_options\":\n\t\t[\n\t\t";
-  std::set<std::string>::const_iterator stringSetIter = includeDirs.begin();
-  while (stringSetIter != includeDirs.end())
-    {
-    const std::string &includeDir = *stringSetIter;
-    const std::string &relative = cmSystemTools::RelativePath(
-                       lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
-                       includeDir.c_str());
-    // 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 << "\"";
-    stringSetIter++;
-    if ((stringSetIter != includeDirs.end()) || (!defines.empty()))
-      {
-      fout << ",";
-      }
-    fout << "\n\t\t";
-  }
-  stringSetIter = defines.begin();
-  while (stringSetIter != defines.end())
-    {
-    fout << "\t\"-D" << *stringSetIter << "\"";
-    stringSetIter++;
-    if (stringSetIter != defines.end())
-      {
-      fout << ",";
-      }
-    fout << "\n\t\t";
-  }
-  // End of the sublimeclang_options section
-  fout << "]\n\t";
-  // End of the settings section
-  fout << "}\n";
-
-  // End of file
-  fout << "}";
 }
 
 // Generate the build_system entry for one target
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index b2d47d9..e23e472 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -45,7 +45,22 @@ private:
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
                                 const std::string& filename);
-
+  void GetFileList(const std::vector<cmLocalGenerator*>& lgs,
+                   std::vector<std::string>& allFiles);
+  void GetFileStringAndFolderSet(const std::vector<cmLocalGenerator*>& lgs,
+                                 const cmMakefile* mf,
+                                 const std::vector<std::string>& allFiles,
+                                 std::stringstream& fileIncludePatternsStream,
+                                 std::set<std::string>&
+                                   folderIncludePatternsSet);
+  /** Appends all targets as build systems to the project file and get all
+   * include directories and compiler definitions used.
+   */
+  void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
+                        const cmMakefile* mf,
+                        cmGeneratedFileStream& fout,
+                        std::set<std::string>& includeDirs,
+                        std::set<std::string>& defines);
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
                                const char* target);
   void AppendTarget(cmGeneratedFileStream& fout,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75b060ff209c02a1d709fa834a853f4750427cb1
commit 75b060ff209c02a1d709fa834a853f4750427cb1
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Thu Oct 11 22:16:44 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 09:47:50 2012 +0200

    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.

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index d9000ca..486658d 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:<project_filename>}}
+    // 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<std::string> defs;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=32f79024ba18df5016eb34c9f5fcc8708eaca83a
commit 32f79024ba18df5016eb34c9f5fcc8708eaca83a
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Thu Oct 11 01:01:13 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 09:47:50 2012 +0200

    Added some support for sublimeclang_options in the generated project file.
    
    This adds -I include path flags and -D define flags for sublimeclang.
    The current problem with this is that these flags cannot be set per
    target (build_system in sublime text), it can only be set project
    wide. Currently all of the include paths and compiler definitions from
    ALL of the targets are used (with duplicates removed). This could be
    problematic in some cases (conflicting compiler definitions among targets).

diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 5cd7179..d9000ca 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -234,11 +234,17 @@ void cmExtraSublimeTextGenerator
   // Write the beginning of the build systems section to the project file
   fout << ",\n\t\"build_systems\":\n\t[\n\t";
 
+  // Set of include directories over all targets (sublime text/sublimeclang
+  // doesn't currently support these settings per build system, only project
+  // wide
+  std::set<std::string> includeDirs;
+  std::set<std::string> defines;
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string compiler = "";
-  this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str(), true);
+  this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str(),
+                     includeDirs, defines, true);
   this->AppendTarget(fout, "clean", 0, make.c_str(), mf, compiler.c_str(),
-                     false);
+                     includeDirs, defines, false);
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
@@ -281,7 +287,7 @@ void cmExtraSublimeTextGenerator
             {
             this->AppendTarget(fout, ti->first.c_str(), 0,
                                make.c_str(), makefile, compiler.c_str(),
-                               false);
+                               includeDirs, defines, false);
             }
           }
           break;
@@ -297,7 +303,8 @@ void cmExtraSublimeTextGenerator
             }
 
           this->AppendTarget(fout, ti->first.c_str(), 0,
-                             make.c_str(), makefile, compiler.c_str(), false);
+                             make.c_str(), makefile, compiler.c_str(),
+                             includeDirs, defines, false);
           break;
         case cmTarget::EXECUTABLE:
         case cmTarget::STATIC_LIBRARY:
@@ -306,11 +313,13 @@ void cmExtraSublimeTextGenerator
         case cmTarget::OBJECT_LIBRARY:
           {
           this->AppendTarget(fout, ti->first.c_str(), &ti->second,
-                             make.c_str(), makefile, compiler.c_str(), false);
+                             make.c_str(), makefile, compiler.c_str(),
+                             includeDirs, defines, false);
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
           this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
-                             make.c_str(), makefile, compiler.c_str(), false);
+                             make.c_str(), makefile, compiler.c_str(),
+                             includeDirs, defines, false);
           }
           break;
         default:
@@ -319,7 +328,41 @@ void cmExtraSublimeTextGenerator
       }
     }
   // End of build_systems
-  fout << "\n\t]\n";
+  fout << "\n\t]";
+
+  // Write the settings section with sublimeclang options
+  fout << ",\n\t\"settings\":\n\t{\n\t";
+  fout << "\t\"sublimeclang_options\":\n\t\t[\n\t\t";
+  std::set<std::string>::const_iterator stringSetIter = includeDirs.begin();
+  while (stringSetIter != includeDirs.end())
+    {
+    const std::string &includeDir = *stringSetIter;
+    const std::string &relative = cmSystemTools::RelativePath(
+                       lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
+                       includeDir.c_str());
+    fout << "\t\"-I" << relative << "\"";
+    stringSetIter++;
+    if (stringSetIter != includeDirs.end())
+      {
+      fout << ",";
+      }
+    fout << "\n\t\t";
+  }
+  stringSetIter = defines.begin();
+  while (stringSetIter != defines.end())
+    {
+    fout << "\t\"-D" << *stringSetIter << "\"";
+    stringSetIter++;
+    if (stringSetIter != defines.end())
+      {
+      fout << ",";
+      }
+    fout << "\n\t\t";
+  }
+  // End of the sublimeclang_options section
+  fout << "]\n\t";
+  // End of the settings section
+  fout << "}\n";
 
   // End of file
   fout << "}";
@@ -332,8 +375,72 @@ void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
                                               const char* make,
                                               const cmMakefile* makefile,
                                               const char* compiler,
+                                              std::set<std::string>&
+                                                              includeDirs,
+                                              std::set<std::string>& defines,
                                               bool firstTarget)
 {
+  if (target != 0)
+    {
+      // the compilerdefines for this target
+      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());
+          }
+        }
+
+      // the include directories for this target
+      std::vector<std::string> includes;
+      target->GetMakefile()->GetLocalGenerator()->
+        GetIncludeDirectories(includes, gtgt);
+      for(std::vector<std::string>::const_iterator dirIt=includes.begin();
+          dirIt != includes.end();
+          ++dirIt)
+        {
+        includeDirs.insert(*dirIt);
+        }
+
+      std::string systemIncludeDirs = makefile->GetSafeDefinition(
+                                "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
+      if (!systemIncludeDirs.empty())
+        {
+        std::vector<std::string> dirs;
+        cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+        for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
+            dirIt != dirs.end();
+            ++dirIt)
+          {
+          includeDirs.insert(*dirIt);
+          }
+        }
+
+      systemIncludeDirs = makefile->GetSafeDefinition(
+                            "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
+      if (!systemIncludeDirs.empty())
+        {
+        std::vector<std::string> dirs;
+        cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+        for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
+            dirIt != dirs.end();
+            ++dirIt)
+          {
+          includeDirs.insert(*dirIt);
+          }
+        }
+    }
+
+  // Write out the build_system data for this target
   std::string makefileName = makefile->GetStartOutputDirectory();
   makefileName += "/Makefile";
   if (!firstTarget)
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 231cc90..b2d47d9 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -54,7 +54,8 @@ private:
                     const char* make,
                     const cmMakefile* makefile,
                     const char* compiler,
-                    bool firstTarget = true);
+                    std::set<std::string>& includeDirs,
+                    std::set<std::string>& defines, bool firstTarget);
 
 };
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b8457ad18b7eac2998fdd29fbc295c1dadbbba42
commit b8457ad18b7eac2998fdd29fbc295c1dadbbba42
Author:     Morné Chamberlain <thefreeman.za at gmail.com>
AuthorDate: Thu Oct 11 00:01:48 2012 +0200
Commit:     Morné Chamberlain <thefreeman.za at gmail.com>
CommitDate: Sat Oct 13 09:47:50 2012 +0200

    Added a generator for Sublime Text 2 project files.
    
    The generator adds all list and source files for each defined
    project. The generated project files also include build_system
    entries that run the platform-specific make on the generated
    Makefiles. A build_system entry is created for each target
    that was defined in the CMakeLists.txt files.
    
    At the moment this has only been tested with C/C++ projects.

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 8bf6c40..8e842a9 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -184,6 +184,8 @@ set(SRCS
   cmExtraCodeBlocksGenerator.h
   cmExtraEclipseCDT4Generator.cxx
   cmExtraEclipseCDT4Generator.h
+  cmExtraSublimeTextGenerator.cxx
+  cmExtraSublimeTextGenerator.h
   cmFileTimeComparison.cxx
   cmFileTimeComparison.h
   cmGeneratedFileStream.cxx
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
new file mode 100644
index 0000000..5cd7179
--- /dev/null
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -0,0 +1,390 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2009 Kitware, Inc.
+  Copyright 2004 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#include "cmExtraSublimeTextGenerator.h"
+#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmLocalUnixMakefileGenerator3.h"
+#include "cmMakefile.h"
+#include "cmake.h"
+#include "cmSourceFile.h"
+#include "cmGeneratedFileStream.h"
+#include "cmTarget.h"
+#include "cmSystemTools.h"
+#include "cmXMLSafe.h"
+
+#include <cmsys/SystemTools.hxx>
+
+#if defined(_WIN32)
+#  define PATH_SEP "\\"
+#else
+#  define PATH_SEP "/"
+#endif
+
+/* Some useful URLs:
+Homepage:
+http://www.sublimetext.com/
+
+File format docs:
+http://www.sublimetext.com/docs/2/projects.html
+http://sublimetext.info/docs/en/reference/build_systems.html
+*/
+
+//----------------------------------------------------------------------------
+void cmExtraSublimeTextGenerator
+::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+{
+  entry.Name = this->GetName();
+  entry.Brief = "Generates Sublime Text 2 project files.";
+  entry.Full =
+    "Project files for Sublime Text 2 will be created in the top directory "
+    "and in every subdirectory which features a CMakeLists.txt file "
+    "containing a PROJECT() call. "
+    "Additionally a hierarchy of makefiles is generated into the "
+    "build tree.  The appropriate make program can build the project through "
+    "the default make target.  A \"make install\" target is also provided.";
+}
+
+cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
+:cmExternalMakefileProjectGenerator()
+{
+#if defined(_WIN32)
+  this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
+  this->SupportedGlobalGenerators.push_back("NMake Makefiles");
+// disable until somebody actually tests it:
+//  this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
+#endif
+  this->SupportedGlobalGenerators.push_back("Ninja");
+  this->SupportedGlobalGenerators.push_back("Unix Makefiles");
+}
+
+
+void cmExtraSublimeTextGenerator::Generate()
+{
+  // for each sub project in the project create a sublime text 2 project
+  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+       it = this->GlobalGenerator->GetProjectMap().begin();
+      it!= this->GlobalGenerator->GetProjectMap().end();
+      ++it)
+    {
+    // create a project file
+    this->CreateProjectFile(it->second);
+    }
+}
+
+
+/* create the project file */
+void cmExtraSublimeTextGenerator::CreateProjectFile(
+                                     const std::vector<cmLocalGenerator*>& lgs)
+{
+  const cmMakefile* mf=lgs[0]->GetMakefile();
+  std::string outputDir=mf->GetStartOutputDirectory();
+  std::string projectName=mf->GetProjectName();
+
+  std::string filename=outputDir+"/";
+  filename+=projectName+".sublime-project";
+
+  this->CreateNewProjectFile(lgs, filename);
+}
+
+void cmExtraSublimeTextGenerator
+  ::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
+                         const std::string& filename)
+{
+  const cmMakefile* mf=lgs[0]->GetMakefile();
+  cmGeneratedFileStream fout(filename.c_str());
+  if(!fout)
+    {
+    return;
+    }
+
+  // A set of folders to include in the project
+  std::set<std::string> folderIncludePatternsSet;
+  // Collect all files, this includes source files and list files
+  std::vector<std::string> allFiles;
+  std::stringstream fileIncludePatternsStream;
+  for (std::vector<cmLocalGenerator *>::const_iterator
+       it = lgs.begin();
+       it != lgs.end();
+       ++it)
+    {
+    cmMakefile* makefile=(*it)->GetMakefile();
+    // Add list files
+    const std::vector<std::string> & listFiles =
+                                            makefile->GetListFiles();
+    allFiles.insert(allFiles.end(), listFiles.begin(), listFiles.end());
+    // Add source files
+    cmTargets& targets=makefile->GetTargets();
+    for (cmTargets::iterator ti = targets.begin();
+         ti != targets.end(); ti++)
+      {
+      switch(ti->second.GetType())
+        {
+        case cmTarget::EXECUTABLE:
+        case cmTarget::STATIC_LIBRARY:
+        case cmTarget::SHARED_LIBRARY:
+        case cmTarget::MODULE_LIBRARY:
+        case cmTarget::OBJECT_LIBRARY:
+        case cmTarget::UTILITY: // can have sources since 2.6.3
+          {
+          const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles();
+          for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
+               si!=sources.end(); si++)
+            {
+            // don't add source files which have the GENERATED property set:
+            if ((*si)->GetPropertyAsBool("GENERATED"))
+              {
+              continue;
+              }
+              allFiles.push_back((*si)->GetFullPath());
+            }
+          }
+        default:  // intended fallthrough
+           break;
+        }
+      }
+    }
+
+  // Convert
+  const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
+  for (std::vector<std::string>::const_iterator jt = allFiles.begin();
+       jt != allFiles.end();
+       ++jt)
+    {
+    // don't put cmake's own files into the project (#12110):
+    if (jt->find(cmakeRoot) == 0)
+      {
+      continue;
+      }
+
+    const std::string &relative = cmSystemTools::RelativePath(
+                       lgs[0]->GetMakefile()->GetHomeDirectory(),
+                       jt->c_str());
+    // Split filename from path
+    std::string fileName = cmSystemTools::GetFilenameName(relative);
+    std::string path = "";
+    if (fileName.length() < relative.length())
+      {
+      path = relative.substr(0, relative.length() - fileName.length() - 1);
+      }
+
+    // We don't want paths with CMakeFiles in them
+    if (relative.find("CMakeFiles") == std::string::npos)
+      {
+      if (fileIncludePatternsStream.tellp() > 0)
+        {
+          fileIncludePatternsStream << ", ";
+        }
+      fileIncludePatternsStream << "\"" << relative << "\"";
+      if ((!path.empty()) && (folderIncludePatternsSet.find(path) ==
+                              folderIncludePatternsSet.end()))
+        {
+        folderIncludePatternsSet.insert(path);
+        std::string::size_type splitIndex = path.rfind(PATH_SEP);
+        std::string splitPath = path;
+        while (splitIndex != std::string::npos)
+          {
+          splitPath = splitPath.substr(0, splitIndex);
+          if ((splitPath.empty()) ||
+                  (folderIncludePatternsSet.insert(splitPath).second == false))
+            {
+            // If the path is already in the set then all of its
+            // parents are as well
+            break;
+            }
+          splitIndex = splitPath.rfind(PATH_SEP);
+          }
+        }
+      }
+    }
+  // Write the folder entries to the project file
+  const std::string &homeRelative = cmSystemTools::RelativePath(
+                     lgs[0]->GetMakefile()->GetHomeOutputDirectory(),
+                     lgs[0]->GetMakefile()->GetHomeDirectory());
+  fout << "{\n";
+  fout << "\t\"folders\":\n\t[\n\t";
+  fout << "\t{\n\t\t\t\"path\": \"" << homeRelative << "\",\n";
+  fout << "\t\t\t\"folder_include_patterns\": [";
+  std::set<std::string>::const_iterator folderIter =
+          folderIncludePatternsSet.begin();
+  while (folderIter != folderIncludePatternsSet.end())
+    {
+    fout << "\"" << *folderIter << "\"";
+    folderIter++;
+    if (folderIter != folderIncludePatternsSet.end())
+      {
+        fout << ", ";
+      }
+    }
+  fout << "],\n";
+  fout << "\t\t\t\"file_include_patterns\": [" <<
+          fileIncludePatternsStream.str() << "]\n";
+  fout << "\t\t}\n\t";
+  // End of the folders section
+  fout << "]";
+
+  // Write the beginning of the build systems section to the project file
+  fout << ",\n\t\"build_systems\":\n\t[\n\t";
+
+  std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+  std::string compiler = "";
+  this->AppendTarget(fout, "all", 0, make.c_str(), mf, compiler.c_str(), true);
+  this->AppendTarget(fout, "clean", 0, make.c_str(), mf, compiler.c_str(),
+                     false);
+
+  // add all executable and library targets and some of the GLOBAL
+  // and UTILITY targets
+  for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
+       lg!=lgs.end(); lg++)
+    {
+    cmMakefile* makefile=(*lg)->GetMakefile();
+    cmTargets& targets=makefile->GetTargets();
+    for (cmTargets::iterator ti = targets.begin();
+         ti != targets.end(); ti++)
+      {
+      switch(ti->second.GetType())
+        {
+        case cmTarget::GLOBAL_TARGET:
+          {
+          bool insertTarget = false;
+          // Only add the global targets from CMAKE_BINARY_DIR,
+          // not from the subdirs
+          if (strcmp(makefile->GetStartOutputDirectory(),
+                     makefile->GetHomeOutputDirectory())==0)
+            {
+            insertTarget = true;
+            // only add the "edit_cache" target if it's not ccmake, because
+            // this will not work within the IDE
+            if (ti->first == "edit_cache")
+              {
+              const char* editCommand = makefile->GetDefinition
+                                                        ("CMAKE_EDIT_COMMAND");
+              if (editCommand == 0)
+                {
+                insertTarget = false;
+                }
+              else if (strstr(editCommand, "ccmake")!=NULL)
+                {
+                insertTarget = false;
+                }
+              }
+            }
+          if (insertTarget)
+            {
+            this->AppendTarget(fout, ti->first.c_str(), 0,
+                               make.c_str(), makefile, compiler.c_str(),
+                               false);
+            }
+          }
+          break;
+        case cmTarget::UTILITY:
+          // Add all utility targets, except the Nightly/Continuous/
+          // Experimental-"sub"targets as e.g. NightlyStart
+          if (((ti->first.find("Nightly")==0)   &&(ti->first!="Nightly"))
+             || ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous"))
+             || ((ti->first.find("Experimental")==0)
+                                               && (ti->first!="Experimental")))
+            {
+            break;
+            }
+
+          this->AppendTarget(fout, ti->first.c_str(), 0,
+                             make.c_str(), makefile, compiler.c_str(), false);
+          break;
+        case cmTarget::EXECUTABLE:
+        case cmTarget::STATIC_LIBRARY:
+        case cmTarget::SHARED_LIBRARY:
+        case cmTarget::MODULE_LIBRARY:
+        case cmTarget::OBJECT_LIBRARY:
+          {
+          this->AppendTarget(fout, ti->first.c_str(), &ti->second,
+                             make.c_str(), makefile, compiler.c_str(), false);
+          std::string fastTarget = ti->first;
+          fastTarget += "/fast";
+          this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
+                             make.c_str(), makefile, compiler.c_str(), false);
+          }
+          break;
+        default:
+          break;
+        }
+      }
+    }
+  // End of build_systems
+  fout << "\n\t]\n";
+
+  // End of file
+  fout << "}";
+}
+
+// Generate the build_system entry for one target
+void cmExtraSublimeTextGenerator::AppendTarget(cmGeneratedFileStream& fout,
+                                              const char* targetName,
+                                              cmTarget* target,
+                                              const char* make,
+                                              const cmMakefile* makefile,
+                                              const char* compiler,
+                                              bool firstTarget)
+{
+  std::string makefileName = makefile->GetStartOutputDirectory();
+  makefileName += "/Makefile";
+  if (!firstTarget)
+    {
+    fout << ",\n\t";
+    }
+  fout << "\t{\n\t\t\t\"name\": \"" << makefile->GetProjectName() << " - " <<
+          targetName << "\",\n";
+  fout << "\t\t\t\"cmd\": [" <<
+          this->BuildMakeCommand(make, makefileName.c_str(), targetName) <<
+          "],\n";
+  fout << "\t\t\t\"working_dir\": \"${project_path}\",\n";
+  fout << "\t\t\t\"file_regex\": \"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$\"\n";
+  fout << "\t\t}";
+}
+
+// Create the command line for building the given target using the selected
+// make
+std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
+             const std::string& make, const char* makefile, const char* target)
+{
+  std::string command = "\"";
+  command += make + "\"";
+  if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
+    {
+    std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
+    command += ", \"/NOLOGO\", \"/f\", \"";
+    command += makefileName + "\"";
+    command += ", \"VERBOSE=1\", \"";
+    command += target;
+    command += "\"";
+    }
+  else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+    {
+    // no escaping of spaces in this case, see
+    // http://public.kitware.com/Bug/view.php?id=10014
+    std::string makefileName = makefile;
+    command += ", \"-f\", \"";
+    command += makefileName + "\"";
+    command += ", \"VERBOSE=1\", \"";
+    command += target;
+    command += "\"";
+    }
+  else
+    {
+    std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
+    command += ", \"-f\", \"";
+    command += makefileName + "\"";
+    command += ", \"VERBOSE=1\", \"";
+    command += target;
+    command += "\"";
+    }
+  return command;
+}
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
new file mode 100644
index 0000000..231cc90
--- /dev/null
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -0,0 +1,61 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2009 Kitware, Inc.
+  Copyright 2004 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cmExtraSublimeTextGenerator_h
+#define cmExtraSublimeTextGenerator_h
+
+#include "cmExternalMakefileProjectGenerator.h"
+
+class cmLocalGenerator;
+class cmMakefile;
+class cmTarget;
+class cmGeneratedFileStream;
+
+/** \class cmExtraSublimeTextGenerator
+ * \brief Write Sublime Text 2 project files for Makefile based projects
+ */
+class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
+{
+public:
+  cmExtraSublimeTextGenerator();
+
+  virtual const char* GetName() const
+                        { return cmExtraSublimeTextGenerator::GetActualName();}
+  static const char* GetActualName()
+                        { return "SublimeText2";}
+  static cmExternalMakefileProjectGenerator* New()
+                                    { return new cmExtraSublimeTextGenerator; }
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry,
+                                const char* fullName) const;
+
+  virtual void Generate();
+private:
+
+  void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
+
+  void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
+                                const std::string& filename);
+
+  std::string BuildMakeCommand(const std::string& make, const char* makefile,
+                               const char* target);
+  void AppendTarget(cmGeneratedFileStream& fout,
+                    const char* targetName,
+                    cmTarget* target,
+                    const char* make,
+                    const cmMakefile* makefile,
+                    const char* compiler,
+                    bool firstTarget = true);
+
+};
+
+#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 0123427..3a25605 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -94,6 +94,7 @@
 #if !defined(CMAKE_BOOT_MINGW)
 # include "cmExtraCodeBlocksGenerator.h"
 #endif
+#include "cmExtraSublimeTextGenerator.h"
 
 #ifdef CMAKE_USE_KDEVELOP
 # include "cmGlobalKdevelopGenerator.h"
@@ -1847,6 +1848,8 @@ void cmake::AddDefaultExtraGenerators()
 
   this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(),
                           &cmExtraCodeBlocksGenerator::New);
+  this->AddExtraGenerator(cmExtraSublimeTextGenerator::GetActualName(),
+                          &cmExtraSublimeTextGenerator::New);
 
 #ifdef CMAKE_USE_ECLIPSE
   this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(),

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list