Merge topic 'doc-consistently-reference-packagename'

30d08bdce9 doc: Consistently use <PackageName> for describing the name of a package

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2283
diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst
index 821198d..551d440 100644
--- a/Help/command/add_link_options.rst
+++ b/Help/command/add_link_options.rst
@@ -1,7 +1,7 @@
 add_link_options
 ----------------
 
-Adds options to the link of targets.
+Adds options to the link of shared library, module and executable targets.
 
 ::
 
diff --git a/Help/prop_dir/LINK_OPTIONS.rst b/Help/prop_dir/LINK_OPTIONS.rst
index 04b9e08..15c555f 100644
--- a/Help/prop_dir/LINK_OPTIONS.rst
+++ b/Help/prop_dir/LINK_OPTIONS.rst
@@ -1,7 +1,8 @@
 LINK_OPTIONS
 ------------
 
-List of options to use for the link step.
+List of options to use for the link step of shared library, module
+and executable targets.
 
 This property holds a :ref:`;-list <CMake Language Lists>` of options
 given so far to the :command:`add_link_options` command.
diff --git a/Help/prop_tgt/LINK_FLAGS.rst b/Help/prop_tgt/LINK_FLAGS.rst
index e0b72b5..3a344e6 100644
--- a/Help/prop_tgt/LINK_FLAGS.rst
+++ b/Help/prop_tgt/LINK_FLAGS.rst
@@ -1,7 +1,9 @@
 LINK_FLAGS
 ----------
 
-Additional flags to use when linking this target.
+Additional flags to use when linking this target if it is a shared library,
+module library, or an executable. Static libraries need to use
+:prop_tgt:`STATIC_LIBRARY_FLAGS`.
 
 The LINK_FLAGS property, managed as a string, can be used to add extra flags
 to the link step of a target.  :prop_tgt:`LINK_FLAGS_<CONFIG>` will add to the
diff --git a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
index 1f2910b..c30ecf1 100644
--- a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
+++ b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
@@ -1,9 +1,9 @@
 LINK_FLAGS_<CONFIG>
 -------------------
 
-Per-configuration linker flags for a target.
+Per-configuration linker flags for a shared library, module or executable target.
 
-This is the configuration-specific version of LINK_FLAGS.
+This is the configuration-specific version of :prop_tgt:`LINK_FLAGS`.
 
 .. note::
 
diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
index d3b2cd4..c91b1ae 100644
--- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
+++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
@@ -1,6 +1,12 @@
 STATIC_LIBRARY_FLAGS
 --------------------
 
-Extra flags to use when linking static libraries.
+Archiver (or MSVC librarian) flags for a static library target.
+Targets that are shared libraries, modules, or executables can use
+the :prop_tgt:`LINK_OPTIONS` or :prop_tgt:`LINK_FLAGS` target property.
 
-Extra flags to use when linking a static library.
+The STATIC_LIBRARY_FLAGS property, managed as a string, can be used to add
+extra flags to the link step of a static library target.
+:prop_tgt:`STATIC_LIBRARY_FLAGS_<CONFIG>` will add to the configuration
+``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``, ``MINSIZEREL``,
+``RELWITHDEBINFO``, ...
diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
index cca353d..b867ac4 100644
--- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
+++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
@@ -1,6 +1,6 @@
 STATIC_LIBRARY_FLAGS_<CONFIG>
 -----------------------------
 
-Per-configuration flags for creating a static library.
+Per-configuration archiver (or MSVC librarian) flags for a static library target.
 
-This is the configuration-specific version of STATIC_LIBRARY_FLAGS.
+This is the configuration-specific version of :prop_tgt:`STATIC_LIBRARY_FLAGS`.
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 9b8631d..b7641ff 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 12)
-set(CMake_VERSION_PATCH 20180810)
+set(CMake_VERSION_PATCH 20180815)
 #set(CMake_VERSION_RC 1)
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 64ec30d..f26c717 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -38,7 +38,7 @@
 {
 }
 
-const char* cmCompiledGeneratorExpression::Evaluate(
+const std::string& cmCompiledGeneratorExpression::Evaluate(
   cmLocalGenerator* lg, const std::string& config, bool quiet,
   const cmGeneratorTarget* headTarget,
   cmGeneratorExpressionDAGChecker* dagChecker,
@@ -48,7 +48,7 @@
                         language);
 }
 
-const char* cmCompiledGeneratorExpression::Evaluate(
+const std::string& cmCompiledGeneratorExpression::Evaluate(
   cmLocalGenerator* lg, const std::string& config, bool quiet,
   const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
   cmGeneratorExpressionDAGChecker* dagChecker,
@@ -61,12 +61,12 @@
   return this->EvaluateWithContext(context, dagChecker);
 }
 
-const char* cmCompiledGeneratorExpression::EvaluateWithContext(
+const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
   cmGeneratorExpressionContext& context,
   cmGeneratorExpressionDAGChecker* dagChecker) const
 {
   if (!this->NeedsEvaluation) {
-    return this->Input.c_str();
+    return this->Input;
   }
 
   this->Output.clear();
@@ -97,8 +97,7 @@
 
   this->DependTargets = context.DependTargets;
   this->AllTargetsSeen = context.AllTargets;
-  // TODO: Return a std::string from here instead?
-  return this->Output.c_str();
+  return this->Output;
 }
 
 cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 9fd53c6..2899317 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -72,16 +72,17 @@
   CM_DISABLE_COPY(cmCompiledGeneratorExpression)
 
 public:
-  const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
-                       bool quiet = false,
-                       cmGeneratorTarget const* headTarget = nullptr,
-                       cmGeneratorTarget const* currentTarget = nullptr,
-                       cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
-                       std::string const& language = std::string()) const;
-  const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
-                       bool quiet, cmGeneratorTarget const* headTarget,
-                       cmGeneratorExpressionDAGChecker* dagChecker,
-                       std::string const& language = std::string()) const;
+  const std::string& Evaluate(
+    cmLocalGenerator* lg, const std::string& config, bool quiet = false,
+    cmGeneratorTarget const* headTarget = nullptr,
+    cmGeneratorTarget const* currentTarget = nullptr,
+    cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
+    std::string const& language = std::string()) const;
+  const std::string& Evaluate(
+    cmLocalGenerator* lg, const std::string& config, bool quiet,
+    cmGeneratorTarget const* headTarget,
+    cmGeneratorExpressionDAGChecker* dagChecker,
+    std::string const& language = std::string()) const;
 
   /** Get set of targets found during evaluations.  */
   std::set<cmGeneratorTarget*> const& GetTargets() const
@@ -126,7 +127,7 @@
                               std::map<std::string, std::string>& mapping);
 
 private:
-  const char* EvaluateWithContext(
+  const std::string& EvaluateWithContext(
     cmGeneratorExpressionContext& context,
     cmGeneratorExpressionDAGChecker* dagChecker) const;
 
@@ -219,13 +220,16 @@
       this->GeneratorExpression.Parse(expression);
 
     if (dagChecker == nullptr) {
-      return this->CompiledGeneratorExpression->Evaluate(
-        this->LocalGenerator, this->Config, false, this->GeneratorTarget);
+      return this->CompiledGeneratorExpression
+        ->Evaluate(this->LocalGenerator, this->Config, false,
+                   this->GeneratorTarget)
+        .c_str();
     }
 
-    return this->CompiledGeneratorExpression->Evaluate(
-      this->LocalGenerator, this->Config, false, this->GeneratorTarget,
-      dagChecker, this->Language);
+    return this->CompiledGeneratorExpression
+      ->Evaluate(this->LocalGenerator, this->Config, false,
+                 this->GeneratorTarget, dagChecker, this->Language)
+      .c_str();
   }
 
 private:
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index a094fa5..e7a55e0 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -55,7 +55,7 @@
 
   std::string outputFileName = this->OutputFileExpr->Evaluate(
     lg, config, false, nullptr, nullptr, nullptr, lang);
-  const std::string outputContent = inputExpression->Evaluate(
+  const std::string& outputContent = inputExpression->Evaluate(
     lg, config, false, nullptr, nullptr, nullptr, lang);
 
   if (cmSystemTools::FileIsFullPath(outputFileName)) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index c20fd13..1548374 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5519,7 +5519,7 @@
       this->GetName(), "LINK_LIBRARIES", nullptr, nullptr);
     cmGeneratorExpression ge(*btIt);
     std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
-    std::string const evaluated =
+    std::string const& evaluated =
       cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
     cmSystemTools::ExpandListArgument(evaluated, llibs);
     if (cge->GetHadHeadSensitiveCondition()) {
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 21121f2..28cbdc7 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -679,7 +679,7 @@
           std::unique_ptr<cmCompiledGeneratorExpression> cge =
             ge.Parse(propertyValue);
           if (cmSystemTools::IsOn(
-                cge->Evaluate(target->GetLocalGenerator(), i))) {
+                cge->Evaluate(target->GetLocalGenerator(), i).c_str())) {
             activeConfigs.insert(i);
           }
         }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index d265cab..5e6ce1a 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2524,12 +2524,12 @@
 
 const char* cmLocalGenerator::GetCurrentBinaryDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str();
 }
 
 const char* cmLocalGenerator::GetCurrentSourceDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentSource();
+  return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str();
 }
 
 std::string cmLocalGenerator::GetTargetDirectory(
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index c90c5b8..b35b116 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -712,8 +712,8 @@
   targetOptions.FixExceptionHandlingDefault();
   std::string asmLocation = configName + "/";
   targetOptions.AddFlag("AssemblerListingLocation", asmLocation);
-  targetOptions.Parse(flags.c_str());
-  targetOptions.Parse(defineFlags.c_str());
+  targetOptions.Parse(flags);
+  targetOptions.Parse(defineFlags);
   targetOptions.ParseFinish();
   if (!langForClCompile.empty()) {
     std::vector<std::string> targetDefines;
@@ -990,7 +990,7 @@
   }
   linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable);
 
-  linkOptions.Parse(extraLinkOptions.c_str());
+  linkOptions.Parse(extraLinkOptions);
   cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
     target->GetModuleDefinitionInfo(configName);
   if (mdi && !mdi->DefFile.empty()) {
@@ -1735,7 +1735,7 @@
               table = cmLocalVisualStudio7GeneratorFortranFlagTable;
             }
             Options fileOptions(this, tool, table, gg->ExtraFlagTable);
-            fileOptions.Parse(fc.CompileFlags.c_str());
+            fileOptions.Parse(fc.CompileFlags);
             fileOptions.AddDefines(fc.CompileDefs);
             fileOptions.AddDefines(fc.CompileDefsConfig);
             // validate source level include directories
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c868159..9e14917 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1637,12 +1637,12 @@
 
 const char* cmMakefile::GetCurrentSourceDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentSource();
+  return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str();
 }
 
 const char* cmMakefile::GetCurrentBinaryDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str();
 }
 
 std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index fd42c53..dbe6fa1 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -83,9 +83,9 @@
                                              std::string const& remote_path,
                                              cmStateDirectory const& directory)
 {
-  const std::string relativePathTopBinary =
+  const std::string& relativePathTopBinary =
     directory.GetRelativePathTopBinary();
-  const std::string relativePathTopSource =
+  const std::string& relativePathTopSource =
     directory.GetRelativePathTopSource();
 
   const bool bothInBinary =
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index c267160..f0a5e26 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -797,9 +797,8 @@
 
   // Remove any config specific variables from the output.
   cmGeneratorExpression ge;
-  auto cge = ge.Parse(command.c_str());
-  const char* processed = cge->Evaluate(lg, config);
-
+  auto cge = ge.Parse(command);
+  const std::string& processed = cge->Evaluate(lg, config);
   result[kCTEST_COMMAND] = processed;
 
   // Build up the list of properties that may have been specified
@@ -810,7 +809,7 @@
 
     // Remove config variables from the value too.
     auto cge_value = ge.Parse(prop.second.GetValue());
-    const char* processed_value = cge_value->Evaluate(lg, config);
+    const std::string& processed_value = cge_value->Evaluate(lg, config);
     entry[kVALUE_KEY] = processed_value;
     properties.append(entry);
   }
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 6eac8e2..925b161 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -84,9 +84,9 @@
   }
 }
 
-const char* cmStateDirectory::GetCurrentSource() const
+std::string const& cmStateDirectory::GetCurrentSource() const
 {
-  return this->DirectoryState->Location.c_str();
+  return this->DirectoryState->Location;
 }
 
 void cmStateDirectory::SetCurrentSource(std::string const& dir)
@@ -101,9 +101,9 @@
   this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc);
 }
 
-const char* cmStateDirectory::GetCurrentBinary() const
+std::string const& cmStateDirectory::GetCurrentBinary() const
 {
-  return this->DirectoryState->OutputLocation.c_str();
+  return this->DirectoryState->OutputLocation;
 }
 
 void cmStateDirectory::SetCurrentBinary(std::string const& dir)
@@ -118,14 +118,14 @@
   this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc);
 }
 
-const char* cmStateDirectory::GetRelativePathTopSource() const
+std::string const& cmStateDirectory::GetRelativePathTopSource() const
 {
-  return this->DirectoryState->RelativePathTopSource.c_str();
+  return this->DirectoryState->RelativePathTopSource;
 }
 
-const char* cmStateDirectory::GetRelativePathTopBinary() const
+std::string const& cmStateDirectory::GetRelativePathTopBinary() const
 {
-  return this->DirectoryState->RelativePathTopBinary.c_str();
+  return this->DirectoryState->RelativePathTopBinary;
 }
 
 void cmStateDirectory::SetRelativePathTopSource(const char* dir)
@@ -474,7 +474,7 @@
   if (prop == "PARENT_DIRECTORY") {
     cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
     if (parent.IsValid()) {
-      return parent.GetDirectory().GetCurrentSource();
+      return parent.GetDirectory().GetCurrentSource().c_str();
     }
     return "";
   }
diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h
index bc96cc9..412664f 100644
--- a/Source/cmStateDirectory.h
+++ b/Source/cmStateDirectory.h
@@ -22,13 +22,13 @@
     cmStateSnapshot const& snapshot);
 
 public:
-  const char* GetCurrentSource() const;
+  std::string const& GetCurrentSource() const;
   void SetCurrentSource(std::string const& dir);
-  const char* GetCurrentBinary() const;
+  std::string const& GetCurrentBinary() const;
   void SetCurrentBinary(std::string const& dir);
 
-  const char* GetRelativePathTopSource() const;
-  const char* GetRelativePathTopBinary() const;
+  std::string const& GetRelativePathTopSource() const;
+  std::string const& GetRelativePathTopBinary() const;
   void SetRelativePathTopSource(const char* dir);
   void SetRelativePathTopBinary(const char* dir);
 
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 380ac88..cc5a176 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1415,13 +1415,15 @@
       return this->GetMakefile()
         ->GetStateSnapshot()
         .GetDirectory()
-        .GetCurrentBinary();
+        .GetCurrentBinary()
+        .c_str();
     }
     if (prop == propSOURCE_DIR) {
       return this->GetMakefile()
         ->GetStateSnapshot()
         .GetDirectory()
-        .GetCurrentSource();
+        .GetCurrentSource()
+        .c_str();
     }
   }
 
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index c532efb..796d2df 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -103,7 +103,7 @@
     }
   } else {
     // Use the command name given.
-    exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config);
+    exe = ge.Parse(exe)->Evaluate(this->LG, config);
     cmSystemTools::ConvertToUnixSlashes(exe);
   }
 
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 41567a3..56d7243 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1742,10 +1742,8 @@
         e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
       }
       for (size_t i = 0; i != this->Configurations.size(); ++i) {
-        if (0 ==
-            strcmp(
-              cge->Evaluate(this->LocalGenerator, this->Configurations[i]),
-              "1")) {
+        if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
+            "1") {
           e2.WritePlatformConfigTag("DeploymentContent",
                                     "'$(Configuration)|$(Platform)'=='" +
                                       this->Configurations[i] + "|" +
@@ -1793,14 +1791,14 @@
         ge.Parse(shaderEnableDebug);
 
       for (size_t i = 0; i != this->Configurations.size(); ++i) {
-        const char* enableDebug =
+        const std::string& enableDebug =
           cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
-        if (strlen(enableDebug) > 0) {
+        if (!enableDebug.empty()) {
           e2.WritePlatformConfigTag(
             "EnableDebuggingInformation",
             "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
               "|" + this->Platform + "'",
-            cmSystemTools::IsOn(enableDebug) ? "true" : "false");
+            cmSystemTools::IsOn(enableDebug.c_str()) ? "true" : "false");
         }
       }
     }
@@ -1810,14 +1808,15 @@
         ge.Parse(shaderDisableOptimizations);
 
       for (size_t i = 0; i != this->Configurations.size(); ++i) {
-        const char* disableOptimizations =
+        const std::string& disableOptimizations =
           cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
-        if (strlen(disableOptimizations) > 0) {
+        if (!disableOptimizations.empty()) {
           e2.WritePlatformConfigTag(
             "DisableOptimizations",
             "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
               "|" + this->Platform + "'",
-            (cmSystemTools::IsOn(disableOptimizations) ? "true" : "false"));
+            (cmSystemTools::IsOn(disableOptimizations.c_str()) ? "true"
+                                                               : "false"));
         }
       }
     }
@@ -2129,7 +2128,7 @@
       if (configDependentFlags) {
         clOptions.Parse(genexInterpreter.Evaluate(flags, "COMPILE_FLAGS"));
       } else {
-        clOptions.Parse(flags.c_str());
+        clOptions.Parse(flags);
       }
       if (!options.empty()) {
         std::string expandedOptions;
@@ -2140,7 +2139,7 @@
         } else {
           this->LocalGenerator->AppendCompileOptions(expandedOptions, options);
         }
-        clOptions.Parse(expandedOptions.c_str());
+        clOptions.Parse(expandedOptions);
       }
       if (clOptions.HasFlag("DisableSpecificWarnings")) {
         clOptions.AppendFlag("DisableSpecificWarnings",
@@ -2524,8 +2523,8 @@
     }
   }
 
-  clOptions.Parse(flags.c_str());
-  clOptions.Parse(defineFlags.c_str());
+  clOptions.Parse(flags);
+  clOptions.Parse(defineFlags);
   std::vector<std::string> targetDefines;
   switch (this->ProjectType) {
     case vcxproj:
@@ -2692,7 +2691,7 @@
     std::string(" ") +
     std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
 
-  rcOptions.Parse(flags.c_str());
+  rcOptions.Parse(flags);
 
   // For historical reasons, add the C preprocessor defines to RC.
   Options& clOptions = *(this->ClOptions[configName]);
@@ -2754,8 +2753,8 @@
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Makefile->GetDefineFlags();
 
-  cudaOptions.Parse(flags.c_str());
-  cudaOptions.Parse(defineFlags.c_str());
+  cudaOptions.Parse(flags);
+  cudaOptions.Parse(defineFlags);
   cudaOptions.ParseFinish();
 
   // If we haven't explicitly enabled GPU debug information
@@ -2962,7 +2961,7 @@
     std::string(" ") +
     std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
 
-  masmOptions.Parse(flags.c_str());
+  masmOptions.Parse(flags);
 
   // Get includes for this target
   masmOptions.AddIncludes(this->GetIncludes(configName, "ASM_MASM"));
@@ -3019,7 +3018,7 @@
       this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT")) +
     std::string(" ") +
     std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
-  nasmOptions.Parse(flags.c_str());
+  nasmOptions.Parse(flags);
 
   // Get includes for this target
   nasmOptions.AddIncludes(this->GetIncludes(configName, "ASM_NASM"));
@@ -3065,7 +3064,7 @@
     cmVS10GeneratorOptions libOptions(this->LocalGenerator,
                                       cmVisualStudioGeneratorOptions::Linker,
                                       gg->GetLibFlagTable(), this);
-    libOptions.Parse(libflags.c_str());
+    libOptions.Parse(libflags);
     OptionsHelper oh(libOptions, e2);
     oh.PrependInheritedString("AdditionalOptions");
     oh.OutputFlagMap();
@@ -3411,7 +3410,7 @@
     linkOptions.AddFlag("SoName", targetNameSO);
   }
 
-  linkOptions.Parse(flags.c_str());
+  linkOptions.Parse(flags);
   linkOptions.FixManifestUACFlags();
 
   if (this->MSTools) {
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 4afef8b..5d67dcf 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -297,12 +297,12 @@
   AddFlag(ENABLE_UAC, "true");
 }
 
-void cmVisualStudioGeneratorOptions::Parse(const char* flags)
+void cmVisualStudioGeneratorOptions::Parse(const std::string& flags)
 {
   // Parse the input string as a windows command line since the string
   // is intended for writing directly into the build files.
   std::vector<std::string> args;
-  cmSystemTools::ParseWindowsCommandLine(flags, args);
+  cmSystemTools::ParseWindowsCommandLine(flags.c_str(), args);
 
   // Process flags that need to be represented specially in the IDE
   // project file.
@@ -366,7 +366,7 @@
   std::string const original = i->second[0];
   i->second[0] = "";
   this->UnknownFlagField = key;
-  this->Parse(original.c_str());
+  this->Parse(original);
 }
 
 void cmVisualStudioGeneratorOptions::StoreUnknownFlag(std::string const& flag)
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index c6b594d..a30a67f 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -42,7 +42,7 @@
   void ClearTables();
 
   // Store options from command line flags.
-  void Parse(const char* flags);
+  void Parse(const std::string& flags);
   void ParseFinish();
 
   void PrependInheritedString(std::string const& key);
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake
new file mode 100644
index 0000000..b68e451
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake
@@ -0,0 +1,7 @@
+
+if (actual_stdout MATCHES "BADFLAG_RELEASE")
+  set (RunCMake_TEST_FAILED "Found 'BADFLAG_RELEASE' which was not expected.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+  string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake
index f17195d..84cf129 100644
--- a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake
@@ -22,6 +22,13 @@
 target_link_libraries(LinkOptions_consumer PRIVATE LinkOptions_producer)
 
 
+# static library with generator expression
+add_library(LinkOptions_static STATIC LinkOptionsLib.c)
+target_link_options(LinkOptions_static PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>
+  "SHELL:" # produces no options
+  )
+
+
 # shared library with generator expression
 add_library(LinkOptions_shared SHARED LinkOptionsLib.c)
 target_link_options(LinkOptions_shared PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>
diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
index 121a0ce..39f580f 100644
--- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
@@ -21,6 +21,7 @@
 
   run_cmake_target(LINK_OPTIONS basic LinkOptions)
   run_cmake_target(LINK_OPTIONS interface LinkOptions_consumer)
+  run_cmake_target(LINK_OPTIONS static LinkOptions_static --config Release)
   run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release)
   run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release)
   run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release)