[Cmake-commits] CMake branch, next, updated. v2.8.12-4234-g0acb875

Brad King brad.king at kitware.com
Mon Oct 21 12:55:43 EDT 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  0acb875e9f10337ca0cf2b5186b8f87e07094b64 (commit)
       via  4e184a21beda9de3703ecda94085c234f5bbd7da (commit)
      from  1c469b1b9577f62c420fcf8182f66bda8fd776b3 (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=0acb875e9f10337ca0cf2b5186b8f87e07094b64
commit 0acb875e9f10337ca0cf2b5186b8f87e07094b64
Merge: 1c469b1 4e184a2
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 21 12:55:39 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Oct 21 12:55:39 2013 -0400

    Merge topic 'string-CONCAT-command' into next
    
    4e184a2 string: Add CONCAT sub-command


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e184a21beda9de3703ecda94085c234f5bbd7da
commit 4e184a21beda9de3703ecda94085c234f5bbd7da
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 21 12:49:15 2013 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 21 12:54:20 2013 -0400

    string: Add CONCAT sub-command
    
    Add a string(CONCAT) command to simply concatenate input arguments
    together.  This will be useful for combining strings from different
    quoting syntaxes.  Add a RunCMake.string test covering these cases.

diff --git a/Help/command/string.rst b/Help/command/string.rst
index 1e18ca6..af18825 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -15,6 +15,7 @@ String operations.
   string(REPLACE <match_string>
          <replace_string> <output variable>
          <input> [<input>...])
+  string(CONCAT <output variable> [<input>...])
   string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512>
          <output variable> <input>)
   string(COMPARE EQUAL <string1> <string2> <output variable>)
@@ -51,6 +52,9 @@ through argument parsing.
 REPLACE will replace all occurrences of match_string in the input with
 replace_string and store the result in the output.
 
+CONCAT will concatenate all the input arguments together and store
+the result in the named output variable.
+
 MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 will compute a
 cryptographic hash of the input string.
 
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 68ba13f..f9b69e3 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -73,6 +73,10 @@ bool cmStringCommand
     {
     return this->HandleLengthCommand(args);
     }
+  else if(subCommand == "CONCAT")
+    {
+    return this->HandleConcatCommand(args);
+    }
   else if(subCommand == "SUBSTRING")
     {
     return this->HandleSubstringCommand(args);
@@ -768,6 +772,27 @@ bool cmStringCommand
 
 //----------------------------------------------------------------------------
 bool cmStringCommand
+::HandleConcatCommand(std::vector<std::string> const& args)
+{
+  if(args.size() < 2)
+    {
+    this->SetError("sub-command CONCAT requires at least one argument.");
+    return false;
+    }
+
+  std::string const& variableName = args[1];
+  std::string value;
+  for(unsigned int i = 2; i < args.size(); ++i)
+    {
+    value += args[i];
+    }
+
+  this->Makefile->AddDefinition(variableName.c_str(), value.c_str());
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmStringCommand
 ::HandleMakeCIdentifierCommand(std::vector<std::string> const& args)
 {
   if(args.size() != 3)
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 0e833c4..66b48e6 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -69,6 +69,7 @@ protected:
   bool HandleReplaceCommand(std::vector<std::string> const& args);
   bool HandleLengthCommand(std::vector<std::string> const& args);
   bool HandleSubstringCommand(std::vector<std::string> const& args);
+  bool HandleConcatCommand(std::vector<std::string> const& args);
   bool HandleStripCommand(std::vector<std::string> const& args);
   bool HandleRandomCommand(std::vector<std::string> const& args);
   bool HandleFindCommand(std::vector<std::string> const& args);
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 52c8667..44da6f2 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -98,6 +98,7 @@ add_RunCMake_test(include)
 add_RunCMake_test(include_directories)
 add_RunCMake_test(list)
 add_RunCMake_test(message)
+add_RunCMake_test(string)
 add_RunCMake_test(try_compile)
 add_RunCMake_test(variable_watch)
 add_RunCMake_test(CMP0004)
diff --git a/Tests/RunCMake/string/CMakeLists.txt b/Tests/RunCMake/string/CMakeLists.txt
new file mode 100644
index 0000000..12cd3c7
--- /dev/null
+++ b/Tests/RunCMake/string/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/string/Concat.cmake b/Tests/RunCMake/string/Concat.cmake
new file mode 100644
index 0000000..7260c95
--- /dev/null
+++ b/Tests/RunCMake/string/Concat.cmake
@@ -0,0 +1,19 @@
+set(b b)
+set(out x)
+string(CONCAT out)
+if(NOT out STREQUAL "")
+  message(FATAL_ERROR "\"string(CONCAT out)\" set out to \"${out}\"")
+endif()
+string(CONCAT out a)
+if(NOT out STREQUAL "a")
+  message(FATAL_ERROR "\"string(CONCAT out a)\" set out to \"${out}\"")
+endif()
+string(CONCAT out a "b")
+if(NOT out STREQUAL "ab")
+  message(FATAL_ERROR "\"string(CONCAT out a \"b\")\" set out to \"${out}\"")
+endif()
+string(CONCAT out a "${b}" [[
+${c}]])
+if(NOT out STREQUAL "ab\${c}")
+  message(FATAL_ERROR "\"string(CONCAT out a \"\${b}\" [[\${c}]])\" set out to \"${out}\"")
+endif()
diff --git a/Tests/RunCMake/string/ConcatNoArgs-result.txt b/Tests/RunCMake/string/ConcatNoArgs-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/string/ConcatNoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/ConcatNoArgs-stderr.txt b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt
new file mode 100644
index 0000000..efea5f1
--- /dev/null
+++ b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at ConcatNoArgs.cmake:1 \(string\):
+  string sub-command CONCAT requires at least one argument.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/string/ConcatNoArgs.cmake b/Tests/RunCMake/string/ConcatNoArgs.cmake
new file mode 100644
index 0000000..ba21136
--- /dev/null
+++ b/Tests/RunCMake/string/ConcatNoArgs.cmake
@@ -0,0 +1 @@
+string(CONCAT)
diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake
new file mode 100644
index 0000000..501acd2
--- /dev/null
+++ b/Tests/RunCMake/string/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(Concat)
+run_cmake(ConcatNoArgs)

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

Summary of changes:
 Help/command/string.rst                            |    4 +++
 Source/cmStringCommand.cxx                         |   25 ++++++++++++++++++++
 Source/cmStringCommand.h                           |    1 +
 Tests/RunCMake/CMakeLists.txt                      |    1 +
 Tests/RunCMake/{CMP0004 => string}/CMakeLists.txt  |    0
 Tests/RunCMake/string/Concat.cmake                 |   19 +++++++++++++++
 .../ConcatNoArgs-result.txt}                       |    0
 Tests/RunCMake/string/ConcatNoArgs-stderr.txt      |    4 +++
 Tests/RunCMake/string/ConcatNoArgs.cmake           |    1 +
 Tests/RunCMake/string/RunCMakeTest.cmake           |    4 +++
 10 files changed, 59 insertions(+), 0 deletions(-)
 copy Tests/RunCMake/{CMP0004 => string}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/string/Concat.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => string/ConcatNoArgs-result.txt} (100%)
 create mode 100644 Tests/RunCMake/string/ConcatNoArgs-stderr.txt
 create mode 100644 Tests/RunCMake/string/ConcatNoArgs.cmake
 create mode 100644 Tests/RunCMake/string/RunCMakeTest.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list