From ef8cbf43088466775670e1e7d0fc864e6016e114 Mon Sep 17 00:00:00 2001
From: Stefan Kislinskiy <s.kislinskiy@dkfz-heidelberg.de>
Date: Mon, 21 Sep 2015 12:42:49 +0200
Subject: [PATCH 1/3] Genex: Add SHELL_PATH
To: cmake-developers@cmake.org

---
 Source/cmGeneratorExpressionNode.cxx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 31b6766..936e707 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -13,6 +13,7 @@
 #include "cmGeneratorExpressionNode.h"
 #include "cmGlobalGenerator.h"
 #include "cmAlgorithms.h"
+#include "cmOutputConverter.h"
 
 //----------------------------------------------------------------------------
 std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
@@ -1792,6 +1793,22 @@ static const
 TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup;
 
 //----------------------------------------------------------------------------
+static const struct ShellPathNode : public cmGeneratorExpressionNode
+{
+  ShellPathNode() {}
+
+  std::string Evaluate(const std::vector<std::string> &parameters,
+                       cmGeneratorExpressionContext *context,
+                       const GeneratorExpressionContent *,
+                       cmGeneratorExpressionDAGChecker *) const
+  {
+    cmOutputConverter converter(context->Makefile->GetStateSnapshot());
+    return converter.ConvertToOutputFormat(parameters.front(),
+                                           cmOutputConverter::SHELL);
+  }
+} shellPathNode;
+
+//----------------------------------------------------------------------------
 const cmGeneratorExpressionNode*
 cmGeneratorExpressionNode::GetNode(const std::string &identifier)
 {
@@ -1846,6 +1863,7 @@ cmGeneratorExpressionNode::GetNode(const std::string &identifier)
     nodeMap["JOIN"] = &joinNode;
     nodeMap["LINK_ONLY"] = &linkOnlyNode;
     nodeMap["COMPILE_LANGUAGE"] = &languageNode;
+    nodeMap["SHELL_PATH"] = &shellPathNode;
     }
   NodeMap::const_iterator i = nodeMap.find(identifier);
   if (i == nodeMap.end())
-- 
2.1.4


From 448bc7ff693d18e5224e8eb8c616e18898c2295d Mon Sep 17 00:00:00 2001
From: Stefan Kislinskiy <s.kislinskiy@dkfz-heidelberg.de>
Date: Mon, 21 Sep 2015 12:43:11 +0200
Subject: [PATCH 2/3] Help: Document SHELL_PATH genex
To: cmake-developers@cmake.org

---
 Help/manual/cmake-generator-expressions.7.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 189c3ef..67c4223 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -278,3 +278,7 @@ Available output expressions are:
   object of type ``OBJECT_LIBRARY``.  This expression may only be used in
   the sources of :command:`add_library` and :command:`add_executable`
   commands.
+``$<SHELL_PATH:...>``
+  Content of ``...`` converted to shell path style. For example, slashes are
+  converted to backslashes in Windows shells and drive letters are converted
+  to posix paths in MSYS shells.
-- 
2.1.4


From 1f92f40c436e7e863e860d6c051be2199addd95f Mon Sep 17 00:00:00 2001
From: Stefan Kislinskiy <s.kislinskiy@dkfz-heidelberg.de>
Date: Mon, 21 Sep 2015 12:45:05 +0200
Subject: [PATCH 3/3] Tests: Cover SHELL_PATH genex
To: cmake-developers@cmake.org

---
 Tests/GeneratorExpression/CMakeLists.txt    | 14 +++++++++++---
 Tests/GeneratorExpression/check-part4.cmake | 10 ++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 Tests/GeneratorExpression/check-part4.cmake

diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 758165c..73b981b 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -66,7 +66,7 @@ add_custom_target(check-part1 ALL
     -Dtest_colons_4=$<1:C:\\CMake>
     -Dtest_colons_5=$<1:C:/CMake>
     -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake
-  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 3)"
+  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)"
   VERBATIM
   )
 
@@ -137,7 +137,7 @@ add_custom_target(check-part2 ALL
     -Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
     -Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
     -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
-  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 3)"
+  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)"
   VERBATIM
 )
 
@@ -221,7 +221,15 @@ add_custom_target(check-part3 ALL
     -Dequal22=$<EQUAL:10,-012>
     -Dequal23=$<EQUAL:-10,-012>
     -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
-  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
+  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)"
+  VERBATIM
+  )
+
+add_custom_target(check-part4 ALL
+  COMMAND ${CMAKE_COMMAND}
+    -Dtest_shell_path=$<SHELL_PATH:c:/shell/path>
+    -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake
+  COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)"
   VERBATIM
   )
 
diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake
new file mode 100644
index 0000000..6c87ef3
--- /dev/null
+++ b/Tests/GeneratorExpression/check-part4.cmake
@@ -0,0 +1,10 @@
+
+include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake)
+
+if(MSYS)
+  check(test_shell_path "/c/shell/path")
+elseif(WIN32)
+  check(test_shell_path "c:\\\\shell\\\\path")
+elseif(UNIX)
+  check(test_shell_path "c:/shell/path")
+endif()
-- 
2.1.4

