diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index ee594b0050abc2f74f5ad5a3ccb965816ad6efff..830ab7f5e739ec3ae3d7ed07f96cd598c1c973ae 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -34,6 +34,11 @@
 const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
 const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
 const char* cmGlobalNinjaGenerator::INDENT = "  ";
+#ifdef _WIN32
+std::string const cmGlobalNinjaGenerator::SHELL_NOOP = "cd .";
+#else
+std::string const cmGlobalNinjaGenerator::SHELL_NOOP = ":";
+#endif
 
 void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count)
 {
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 81ec3ebe26daaab5963f548f218faff59dadcdef..064ff0b3bff0eea5e5da94882ce96381c696ba52 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -58,6 +58,9 @@ public:
   /// The indentation string used when generating Ninja's build file.
   static const char* INDENT;
 
+  /// The shell command used for a no-op.
+  static std::string const SHELL_NOOP;
+
   /// Write @a count times INDENT level to output stream @a os.
   static void Indent(std::ostream& os, int count);
 
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cd9af54fcd752b9fbda7d9968b1728bb188b8435..c27ab0993d20dd2d95133b7678c0dbd88796a801 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -299,15 +299,11 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
 std::string cmLocalNinjaGenerator::BuildCommandLine(
   const std::vector<std::string>& cmdLines)
 {
-  // If we have no commands but we need to build a command anyway, use ":".
+  // If we have no commands but we need to build a command anyway, use noop.
   // This happens when building a POST_BUILD value for link targets that
   // don't use POST_BUILD.
   if (cmdLines.empty()) {
-#ifdef _WIN32
-    return "cd .";
-#else
-    return ":";
-#endif
+    return cmGlobalNinjaGenerator::SHELL_NOOP;
   }
 
   std::ostringstream cmd;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 11773f9a3319d396ece04d97e41bc9747be7b20e..d70bf8ec291ddca73bee899808142f07e38e20d8 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -675,7 +675,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   if (!symlinkNeeded) {
     vars["POST_BUILD"] = postBuildCmdLine;
   } else {
-    vars["POST_BUILD"] = ":";
+    vars["POST_BUILD"] = cmGlobalNinjaGenerator::SHELL_NOOP;
     symlinkVars["POST_BUILD"] = postBuildCmdLine;
   }
   cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();