[Cmake-commits] CMake branch, next, updated. v3.7.0-rc2-806-gab06931

Brad King brad.king at kitware.com
Fri Oct 28 09:10:38 EDT 2016


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  ab0693126ee1cf32aaef440b778f8a0a62e127dc (commit)
       via  95805d725d49af665c2254f97effbe8b812239ea (commit)
      from  6dc7f3cd015c7ffae07e391f102dafa211c475b9 (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ab0693126ee1cf32aaef440b778f8a0a62e127dc
commit ab0693126ee1cf32aaef440b778f8a0a62e127dc
Merge: 6dc7f3c 95805d7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 09:10:37 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Oct 28 09:10:37 2016 -0400

    Merge topic 'st2-env-vars-variable' into next
    
    95805d72 Sublime: Add option to specify env vars for the .sublime-project


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95805d725d49af665c2254f97effbe8b812239ea
commit 95805d725d49af665c2254f97effbe8b812239ea
Author:     Bruno Pedrosa <brupelo at gmail.com>
AuthorDate: Wed Oct 26 20:58:11 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 27 14:07:18 2016 -0400

    Sublime: Add option to specify env vars for the .sublime-project
    
    Create a `CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS` variable to control
    addition of env vars in the `.sublime-project`.
    
    Closes: #16387

diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index a5b1daa..93e809a 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -160,6 +160,7 @@ Variables that Change Behavior
    /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE
    /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
    /variable/CMAKE_STAGING_PREFIX
+   /variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
    /variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE
    /variable/CMAKE_SYSTEM_APPBUNDLE_PATH
    /variable/CMAKE_SYSTEM_FRAMEWORK_PATH
diff --git a/Help/release/dev/st2-env-settings.rst b/Help/release/dev/st2-env-settings.rst
new file mode 100644
index 0000000..7b36347
--- /dev/null
+++ b/Help/release/dev/st2-env-settings.rst
@@ -0,0 +1,6 @@
+st2-env-settings
+----------------
+
+* The :generator:`Sublime Text 2` extra generator learned to place
+  environment variables in the generated ``.sublime-project``.
+  See the :variable:`CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS` variable.
diff --git a/Help/variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS.rst b/Help/variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS.rst
new file mode 100644
index 0000000..02c8663
--- /dev/null
+++ b/Help/variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS.rst
@@ -0,0 +1,25 @@
+CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
+---------------------------------
+
+This variable contains a list of env vars as a list of tokens with the
+syntax ``var=value``.
+
+Example:
+
+.. code-block:: cmake
+
+  set(CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
+     "FOO=FOO1\;FOO2\;FOON"
+     "BAR=BAR1\;BAR2\;BARN"
+     "BAZ=BAZ1\;BAZ2\;BAZN"
+     "FOOBAR=FOOBAR1\;FOOBAR2\;FOOBARN"
+     "VALID="
+     )
+
+In case of malformed variables CMake will fail:
+
+.. code-block:: cmake
+
+  set(CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
+      "THIS_IS_NOT_VALID"
+      )
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index f46019e..ff5036f 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -62,6 +62,8 @@ void cmExtraSublimeTextGenerator::Generate()
 {
   this->ExcludeBuildFolder = this->GlobalGenerator->GlobalSettingIsOn(
     "CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE");
+  this->EnvSettings = this->GlobalGenerator->GetSafeGlobalSetting(
+    "CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS");
 
   // for each sub project in the project create a sublime text 2 project
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
@@ -130,7 +132,37 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
 
   // End of build_systems
   fout << "\n\t]";
-  fout << "\n\t}";
+  std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
+  std::vector<std::string> tokens;
+  cmSystemTools::ExpandListArgument(this->EnvSettings, tokens);
+
+  if (!this->EnvSettings.empty()) {
+    fout << ",";
+    fout << "\n\t\"env\":";
+    fout << "\n\t{";
+    fout << "\n\t\t" << systemName << ":";
+    fout << "\n\t\t{";
+    for (std::vector<std::string>::iterator i = tokens.begin();
+         i != tokens.end(); ++i) {
+      size_t const pos = i->find_first_of('=');
+
+      if (pos != std::string::npos) {
+        std::string varName = i->substr(0, pos);
+        std::string varValue = i->substr(pos + 1);
+
+        fout << "\n\t\t\t\"" << varName << "\":\"" << varValue << "\"";
+      } else {
+        std::ostringstream e;
+        e << "Could not parse Env Vars specified in "
+             "\"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS\""
+          << ", corrupted string " << *i;
+        mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+      }
+    }
+    fout << "\n\t\t}";
+    fout << "\n\t}";
+  }
+  fout << "\n}";
 }
 
 void cmExtraSublimeTextGenerator::AppendAllTargets(
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 0c58221..a860d34 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -66,6 +66,7 @@ private:
                              cmGeneratorTarget* gtgt);
 
   bool ExcludeBuildFolder;
+  std::string EnvSettings;
 };
 
 #endif

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

Summary of changes:
 Help/manual/cmake-variables.7.rst                  |    1 +
 Help/release/dev/st2-env-settings.rst              |    6 ++++
 .../variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS.rst |   25 ++++++++++++++
 Source/cmExtraSublimeTextGenerator.cxx             |   34 +++++++++++++++++++-
 Source/cmExtraSublimeTextGenerator.h               |    1 +
 5 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 Help/release/dev/st2-env-settings.rst
 create mode 100644 Help/variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list