[Cmake-commits] CMake branch, master, updated. v3.11.1-743-gd15b491

Kitware Robot kwrobot at kitware.com
Tue May 8 08:45:05 EDT 2018


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, master has been updated
       via  d15b4914496be1007914da3f2491b891b9e2926a (commit)
       via  0df2e3063858d452e3091739774024a9d4567203 (commit)
       via  c400cd4f3a0ca99882bb2cbba9329447642405cd (commit)
       via  6a95a097d9bcf0e931011704575a5260ced48911 (commit)
       via  e16a04ce2ec02e1ba97f117c7f1ddadfbe5909c9 (commit)
       via  f60e2eb3c59f8c2a8a1f4f8013da8eeedc0c459d (commit)
       via  42d198744b8645ee35633c7af6e122d152bda8e9 (commit)
       via  b7c2b2cd78a8bc16cd7e294c2ae9d5d45f029e22 (commit)
       via  d244f2cad3fea2884eb706e2761189ea9644b70b (commit)
       via  1e5a8f882f36648a74c54ebda1d2480bb99c29b1 (commit)
       via  8d7ffed04819669ebc9fb365ade6bffaab443a3a (commit)
       via  73ee599a8203271245ab7a55095eb92843768b54 (commit)
       via  e76a0c6071337a6114c6a5851422aa735addb74b (commit)
       via  ac5731a7e380349f19dc319e6c31e189b5faba93 (commit)
      from  65431c727b53ff092ad6f2f8c081982bdde52385 (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=d15b4914496be1007914da3f2491b891b9e2926a
commit d15b4914496be1007914da3f2491b891b9e2926a
Merge: e16a04c 0df2e30
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 8 08:39:32 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue May 8 08:39:32 2018 -0400

    Merge branch 'release-3.11'


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e16a04ce2ec02e1ba97f117c7f1ddadfbe5909c9
commit e16a04ce2ec02e1ba97f117c7f1ddadfbe5909c9
Merge: f60e2eb ac5731a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 8 12:36:32 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue May 8 08:37:35 2018 -0400

    Merge topic 'pkgconf-imp-target-lib-path'
    
    ac5731a7e3 FindPkgConfig: correct library search path for imported targets.
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2027


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f60e2eb3c59f8c2a8a1f4f8013da8eeedc0c459d
commit f60e2eb3c59f8c2a8a1f4f8013da8eeedc0c459d
Merge: 42d1987 e76a0c6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 8 12:36:20 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue May 8 08:36:57 2018 -0400

    Merge topic 'vs-improve-options'
    
    e76a0c6071 VS: improve options generation
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2044


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42d198744b8645ee35633c7af6e122d152bda8e9
commit 42d198744b8645ee35633c7af6e122d152bda8e9
Merge: 65431c7 b7c2b2c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 8 12:36:10 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue May 8 08:36:20 2018 -0400

    Merge topic 'deprecate_static_managed_targets'
    
    b7c2b2cd78 cmVisualStudio10TargetGenerator: add handling of static C# targets
    d244f2cad3 cmVisualStudio10TargetGenerator: add handling of manual /clr setting
    1e5a8f882f cmVisualStudio10TargetGenerator: fix checking for managed target
    8d7ffed048 cmVisualStudio10TargetGenerator: issue warning when adding static C# lib
    73ee599a82 cmGeneratorTarget: make GetManagedType() return 'Native' for static targets
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2014


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b7c2b2cd78a8bc16cd7e294c2ae9d5d45f029e22
commit b7c2b2cd78a8bc16cd7e294c2ae9d5d45f029e22
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Fri Apr 27 07:31:45 2018 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Mon May 7 07:21:12 2018 +0200

    cmVisualStudio10TargetGenerator: add handling of static C# targets

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 3fb0e10..f4911c9 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3823,6 +3823,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
           }
         }
       }
+      // Workaround for static library C# targets
+      if (referenceNotManaged &&
+          dt->GetType() == cmStateEnums::STATIC_LIBRARY) {
+        referenceNotManaged = !dt->HasLanguage("CSharp", "");
+      }
       if (referenceNotManaged) {
         e2.Element("ReferenceOutputAssembly", "false");
       }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d244f2cad3fea2884eb706e2761189ea9644b70b
commit d244f2cad3fea2884eb706e2761189ea9644b70b
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Fri Apr 27 07:31:03 2018 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Mon May 7 07:21:10 2018 +0200

    cmVisualStudio10TargetGenerator: add handling of manual /clr setting

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 95e52e6..3fb0e10 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3813,6 +3813,16 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
       // 'ReferenceOutputAssembly' to false.
       auto referenceNotManaged =
         dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed;
+      // Workaround to check for manually set /clr flags.
+      if (referenceNotManaged) {
+        if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) {
+          std::string flagsStr = flags;
+          if (flagsStr.find("clr") != std::string::npos) {
+            // There is a warning already issued when building the flags.
+            referenceNotManaged = false;
+          }
+        }
+      }
       if (referenceNotManaged) {
         e2.Element("ReferenceOutputAssembly", "false");
       }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e5a8f882f36648a74c54ebda1d2480bb99c29b1
commit 1e5a8f882f36648a74c54ebda1d2480bb99c29b1
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Fri Apr 27 07:29:57 2018 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Mon May 7 07:21:08 2018 +0200

    cmVisualStudio10TargetGenerator: fix checking for managed target

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index da00f5c..95e52e6 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3811,18 +3811,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
       // If the dependency target is not managed (compiled with /clr or
       // C# target) we cannot reference it and have to set
       // 'ReferenceOutputAssembly' to false.
-      cmGeneratorTarget::ManagedType check =
-        cmGeneratorTarget::ManagedType::Mixed;
-      // FIXME: These (5) lines should be removed. They are here to allow
-      //        manual setting of the /clr flag in compiler options. Setting
-      //        /clr manually makes cmGeneratorTarget::GetManagedType() return
-      //        'Native' instead of 'Mixed' or 'Managed'.
-      check = cmGeneratorTarget::ManagedType::Native;
-      bool unmanagedStatic = false;
-      if (dt->GetType() == cmStateEnums::STATIC_LIBRARY) {
-        unmanagedStatic = !dt->HasLanguage("CSharp", "");
-      }
-      if (dt->GetManagedType("") < check || unmanagedStatic) {
+      auto referenceNotManaged =
+        dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed;
+      if (referenceNotManaged) {
         e2.Element("ReferenceOutputAssembly", "false");
       }
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d7ffed04819669ebc9fb365ade6bffaab443a3a
commit 8d7ffed04819669ebc9fb365ade6bffaab443a3a
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Fri Apr 27 07:24:47 2018 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Mon May 7 07:20:46 2018 +0200

    cmVisualStudio10TargetGenerator: issue warning when adding static C# lib

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7a7c647..da00f5c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -333,6 +333,14 @@ void cmVisualStudio10TargetGenerator::Generate()
     this->ProjectType = vcxproj;
     this->Managed = false;
   } else if (this->ProjectFileExtension == ".csproj") {
+    if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+      std::string message = "The C# target \"" +
+        this->GeneratorTarget->GetName() +
+        "\" is of type STATIC_LIBRARY. This is discouraged (and may be "
+        "disabled in future). Make it a SHARED library instead.";
+      this->Makefile->IssueMessage(cmake::MessageType::DEPRECATION_WARNING,
+                                   message);
+    }
     this->ProjectType = csproj;
     this->Managed = true;
   }
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
new file mode 100644
index 0000000..1ea3b51
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+  The C# target "foo" is of type STATIC_LIBRARY.  This is discouraged \(and
+  may be disabled in future\).  Make it a SHARED library instead.$
diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
new file mode 100644
index 0000000..4402b8f
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+  The C# target "foo2" is of type STATIC_LIBRARY.  This is discouraged \(and
+  may be disabled in future\).  Make it a SHARED library instead.
+
+
+CMake Deprecation Warning in CMakeLists.txt:
+  The C# target "foo" is of type STATIC_LIBRARY.  This is discouraged \(and
+  may be disabled in future\).  Make it a SHARED library instead.$

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73ee599a8203271245ab7a55095eb92843768b54
commit 73ee599a8203271245ab7a55095eb92843768b54
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Mon Apr 23 07:16:04 2018 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Mon May 7 07:20:45 2018 +0200

    cmGeneratorTarget: make GetManagedType() return 'Native' for static targets

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index bf5ff65..799ae95 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5510,12 +5510,14 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType(
   const std::string& config) const
 {
   // Only libraries and executables can be managed targets.
-  if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
-      this->GetType() != cmStateEnums::STATIC_LIBRARY &&
-      this->GetType() != cmStateEnums::EXECUTABLE) {
+  if (this->GetType() > cmStateEnums::SHARED_LIBRARY) {
     return ManagedType::Undefined;
   }
 
+  if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
+    return ManagedType::Native;
+  }
+
   // Check imported target.
   if (this->IsImported()) {
     if (cmGeneratorTarget::ImportInfo const* info =

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e76a0c6071337a6114c6a5851422aa735addb74b
commit e76a0c6071337a6114c6a5851422aa735addb74b
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Sat May 5 17:35:37 2018 -0400
Commit:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
CommitDate: Sat May 5 17:35:37 2018 -0400

    VS: improve options generation
    
    Make use of the `Elem` and `OptionsHelper` classes; some cleanup

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7a7c647..cbc328a 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -77,23 +77,14 @@ struct cmVisualStudio10TargetGenerator::Elem
     this->WriteString("<") << tag;
     return *this;
   }
-  template <typename T>
-  void WriteElem(const char* tag, const T& val)
-  {
-    this->WriteString("<") << tag << ">" << val << "</" << tag << ">\n";
-  }
   void Element(const char* tag, const std::string& val)
   {
-    Elem(*this).WriteElem(tag, cmVS10EscapeXML(val));
-  }
-  template <typename T>
-  void Attr(const char* an, const T& av)
-  {
-    this->S << " " << an << "=\"" << av << "\"";
+    Elem(*this).WriteString("<") << tag << ">" << cmVS10EscapeXML(val) << "</"
+                                 << tag << ">\n";
   }
   Elem& Attribute(const char* an, const std::string& av)
   {
-    Attr(an, cmVS10EscapeAttr(av));
+    this->S << " " << an << "=\"" << cmVS10EscapeAttr(av) << "\"";
     return *this;
   }
   // This method for now assumes that this->Tag has been set, e.g. by calling
@@ -117,6 +108,7 @@ struct cmVisualStudio10TargetGenerator::Elem
 class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions
 {
 public:
+  typedef cmVisualStudio10TargetGenerator::Elem Elem;
   cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
                          cmVS7FlagTable const* table,
                          cmVisualStudio10TargetGenerator* g = nullptr)
@@ -125,48 +117,50 @@ public:
   {
   }
 
-  void OutputFlag(std::ostream& fout, int indent, const char* tag,
+  void OutputFlag(std::ostream& /*fout*/, int /*indent*/, const char* tag,
                   const std::string& content) override
   {
     if (!this->GetConfiguration().empty()) {
       // if there are configuration specific flags, then
       // use the configuration specific tag for PreprocessorDefinitions
       this->TargetGenerator->WritePlatformConfigTag(
-        tag, this->GetConfiguration(), indent, content);
+        tag, this->GetConfiguration(), *Parent, content);
     } else {
-      fout.fill(' ');
-      fout.width(indent * 2);
-      // write an empty string to get the fill level indent to print
-      fout << "";
-      fout << "<" << tag << ">";
-      fout << cmVS10EscapeXML(content);
-      fout << "</" << tag << ">\n";
+      Parent->Element(tag, content);
     }
   }
 
 private:
-  cmVisualStudio10TargetGenerator* TargetGenerator;
+  cmVisualStudio10TargetGenerator* const TargetGenerator;
+  Elem* Parent = nullptr;
+  friend cmVisualStudio10TargetGenerator::OptionsHelper;
 };
 
-inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
-                                                       const char* val,
-                                                       int indentLevel)
-{
-  Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val);
-}
-
-inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag,
-                                                       std::string const& val,
-                                                       int indentLevel)
+struct cmVisualStudio10TargetGenerator::OptionsHelper
 {
-  Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val);
-}
+  cmVS10GeneratorOptions& O;
+  OptionsHelper(cmVS10GeneratorOptions& o, Elem& e)
+    : O(o)
+  {
+    O.Parent = &e;
+  }
+  ~OptionsHelper() { O.Parent = nullptr; }
 
-inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
-  const char* tag, std::string const& val, int indentLevel)
-{
-  this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel);
-}
+  void OutputPreprocessorDefinitions(const std::string& lang)
+  {
+    O.OutputPreprocessorDefinitions(O.Parent->S, O.Parent->Indent + 1, lang);
+  }
+  void OutputAdditionalIncludeDirectories(const std::string& lang)
+  {
+    O.OutputAdditionalIncludeDirectories(O.Parent->S, O.Parent->Indent + 1,
+                                         lang);
+  }
+  void OutputFlagMap() { O.OutputFlagMap(O.Parent->S, O.Parent->Indent + 1); }
+  void PrependInheritedString(std::string const& key)
+  {
+    O.PrependInheritedString(key);
+  }
+};
 
 static std::string cmVS10EscapeComment(std::string comment)
 {
@@ -275,18 +269,12 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition(
 }
 
 void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
-  const char* tag, const std::string& config, int indentLevel,
+  const char* tag, const std::string& config, Elem& parent,
   const std::string& content)
 {
-  std::ostream& stream = *this->BuildFileStream;
-  stream.fill(' ');
-  stream.width(indentLevel * 2);
-  stream << ""; // applies indentation
-  stream << "<" << tag << " Condition=\"";
-  stream << this->CalcCondition(config);
-  stream << "\"";
-  stream << ">" << cmVS10EscapeXML(content);
-  stream << "</" << tag << ">\n";
+  Elem(parent, tag)
+    .Attribute("Condition", this->CalcCondition(config))
+    .Content(content);
 }
 
 std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
@@ -847,7 +835,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
             s = "$(RootNamespace).";
           }
           s += "%(Filename).resources";
-          this->WritePlatformConfigTag("LogicalName", i, e2.Indent + 1, s);
+          this->WritePlatformConfigTag("LogicalName", i, e2, s);
         }
       } else {
         std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
@@ -1179,7 +1167,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
     e1.Element("StartProgram", outDir + assemblyName + ".exe");
   }
 
-  o.OutputFlagMap(e1.S, e1.Indent + 1);
+  OptionsHelper oh(o, e1);
+  oh.OutputFlagMap();
 }
 
 //----------------------------------------------------------------------------
@@ -2127,7 +2116,6 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     // use them
     if (!flags.empty() || !options.empty() || !configDefines.empty() ||
         !includes.empty() || compileAs || noWinRT) {
-      e2.SetHasElements();
       cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
       cmIDEFlagTable const* flagtable = nullptr;
       const std::string& srclang = source->GetLanguage();
@@ -2193,10 +2181,11 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
       }
       clOptions.AddIncludes(includeList);
       clOptions.SetConfiguration(config);
-      clOptions.PrependInheritedString("AdditionalOptions");
-      clOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, lang);
-      clOptions.OutputFlagMap(e2.S, e2.Indent + 1);
-      clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, lang);
+      OptionsHelper oh(clOptions, e2);
+      oh.PrependInheritedString("AdditionalOptions");
+      oh.OutputAdditionalIncludeDirectories(lang);
+      oh.OutputFlagMap();
+      oh.OutputPreprocessorDefinitions(lang);
     }
   }
   if (this->IsXamlSource(source->GetFullPath())) {
@@ -2250,7 +2239,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
   for (std::string const& config : this->Configurations) {
     if (ttype >= cmStateEnums::UTILITY) {
       this->WritePlatformConfigTag(
-        "IntDir", config, e1.Indent + 1,
+        "IntDir", config, e1,
         "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
     } else {
       std::string intermediateDir =
@@ -2271,68 +2260,67 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
       ConvertToWindowsSlash(intermediateDir);
       ConvertToWindowsSlash(outDir);
 
-      this->WritePlatformConfigTag("OutDir", config, e1.Indent + 1, outDir);
+      this->WritePlatformConfigTag("OutDir", config, e1, outDir);
 
-      this->WritePlatformConfigTag("IntDir", config, e1.Indent + 1,
-                                   intermediateDir);
+      this->WritePlatformConfigTag("IntDir", config, e1, intermediateDir);
 
       if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) {
-        this->WritePlatformConfigTag("ExecutablePath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("ExecutablePath", config, e1,
                                      sdkExecutableDirectories);
       }
 
       if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) {
-        this->WritePlatformConfigTag("IncludePath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("IncludePath", config, e1,
                                      sdkIncludeDirectories);
       }
 
       if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) {
-        this->WritePlatformConfigTag("ReferencePath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("ReferencePath", config, e1,
                                      sdkReferenceDirectories);
       }
 
       if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) {
-        this->WritePlatformConfigTag("LibraryPath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("LibraryPath", config, e1,
                                      sdkLibraryDirectories);
       }
 
       if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) {
-        this->WritePlatformConfigTag("LibraryWPath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("LibraryWPath", config, e1,
                                      sdkLibraryWDirectories);
       }
 
       if (const char* sdkSourceDirectories =
             this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) {
-        this->WritePlatformConfigTag("SourcePath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("SourcePath", config, e1,
                                      sdkSourceDirectories);
       }
 
       if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition(
             "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) {
-        this->WritePlatformConfigTag("ExcludePath", config, e1.Indent + 1,
+        this->WritePlatformConfigTag("ExcludePath", config, e1,
                                      sdkExcludeDirectories);
       }
 
       if (const char* workingDir = this->GeneratorTarget->GetProperty(
             "VS_DEBUGGER_WORKING_DIRECTORY")) {
         this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config,
-                                     e1.Indent + 1, workingDir);
+                                     e1, workingDir);
       }
 
       if (const char* debuggerCommand =
             this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
-        this->WritePlatformConfigTag("LocalDebuggerCommand", config,
-                                     e1.Indent + 1, debuggerCommand);
+        this->WritePlatformConfigTag("LocalDebuggerCommand", config, e1,
+                                     debuggerCommand);
       }
 
       std::string name =
         cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
-      this->WritePlatformConfigTag("TargetName", config, e1.Indent + 1, name);
+      this->WritePlatformConfigTag("TargetName", config, e1, name);
 
       std::string ext =
         cmSystemTools::GetFilenameLastExtension(targetNameFull);
@@ -2341,7 +2329,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
         // A single "." appears to be treated as an empty extension.
         ext = ".";
       }
-      this->WritePlatformConfigTag("TargetExt", config, e1.Indent + 1, ext);
+      this->WritePlatformConfigTag("TargetExt", config, e1, ext);
 
       this->OutputLinkIncremental(e1, config);
     }
@@ -2367,12 +2355,12 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
   Options& linkOptions = *(this->LinkOptions[configName]);
 
   const char* incremental = linkOptions.GetFlag("LinkIncremental");
-  this->WritePlatformConfigTag("LinkIncremental", configName, e1.Indent + 1,
+  this->WritePlatformConfigTag("LinkIncremental", configName, e1,
                                (incremental ? incremental : "true"));
   linkOptions.RemoveFlag("LinkIncremental");
 
   const char* manifest = linkOptions.GetFlag("GenerateManifest");
-  this->WritePlatformConfigTag("GenerateManifest", configName, e1.Indent + 1,
+  this->WritePlatformConfigTag("GenerateManifest", configName, e1,
                                (manifest ? manifest : "true"));
   linkOptions.RemoveFlag("GenerateManifest");
 
@@ -2382,7 +2370,7 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
   for (const char** f = flags; *f; ++f) {
     const char* flag = *f;
     if (const char* value = linkOptions.GetFlag(flag)) {
-      this->WritePlatformConfigTag(flag, configName, e1.Indent + 1, value);
+      this->WritePlatformConfigTag(flag, configName, e1, value);
       linkOptions.RemoveFlag(flag);
     }
   }
@@ -2612,13 +2600,11 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
     return;
   }
   Elem e2(e1, "ClCompile");
-  e2.SetHasElements();
-  clOptions.PrependInheritedString("AdditionalOptions");
-  clOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1,
-                                               this->LangForClCompile);
-  clOptions.OutputFlagMap(e2.S, e2.Indent + 1);
-  clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1,
-                                          this->LangForClCompile);
+  OptionsHelper oh(clOptions, e2);
+  oh.PrependInheritedString("AdditionalOptions");
+  oh.OutputAdditionalIncludeDirectories(this->LangForClCompile);
+  oh.OutputFlagMap();
+  oh.OutputPreprocessorDefinitions(this->LangForClCompile);
 
   if (this->NsightTegra) {
     if (const char* processMax =
@@ -2714,13 +2700,12 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
     return;
   }
   Elem e2(e1, "ResourceCompile");
-  e2.SetHasElements();
 
-  Options& rcOptions = *(this->RcOptions[configName]);
-  rcOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "RC");
-  rcOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, "RC");
+  OptionsHelper rcOptions(*(this->RcOptions[configName]), e2);
+  rcOptions.OutputPreprocessorDefinitions("RC");
+  rcOptions.OutputAdditionalIncludeDirectories("RC");
   rcOptions.PrependInheritedString("AdditionalOptions");
-  rcOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+  rcOptions.OutputFlagMap();
 
   e2.EndElement();
 }
@@ -2863,13 +2848,12 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions(
     return;
   }
   Elem e2(e1, "CudaCompile");
-  e2.SetHasElements();
 
-  Options& cudaOptions = *(this->CudaOptions[configName]);
-  cudaOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1, "CUDA");
-  cudaOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "CUDA");
+  OptionsHelper cudaOptions(*(this->CudaOptions[configName]), e2);
+  cudaOptions.OutputAdditionalIncludeDirectories("CUDA");
+  cudaOptions.OutputPreprocessorDefinitions("CUDA");
   cudaOptions.PrependInheritedString("AdditionalOptions");
-  cudaOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+  cudaOptions.OutputFlagMap();
 
   e2.EndElement();
 }
@@ -2937,9 +2921,8 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
   }
 
   Elem e2(e1, "CudaLink");
-  e2.SetHasElements();
-  Options& cudaLinkOptions = *(this->CudaLinkOptions[configName]);
-  cudaLinkOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+  OptionsHelper cudaLinkOptions(*(this->CudaLinkOptions[configName]), e2);
+  cudaLinkOptions.OutputFlagMap();
   e2.EndElement();
 }
 
@@ -2987,17 +2970,15 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
     return;
   }
   Elem e2(e1, "MASM");
-  e2.SetHasElements();
 
   // Preprocessor definitions and includes are shared with clOptions.
-  Options& clOptions = *(this->ClOptions[configName]);
-  clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_MASM");
+  OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
+  clOptions.OutputPreprocessorDefinitions("ASM_MASM");
 
-  Options& masmOptions = *(this->MasmOptions[configName]);
-  masmOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1,
-                                                 "ASM_MASM");
+  OptionsHelper masmOptions(*(this->MasmOptions[configName]), e2);
+  masmOptions.OutputAdditionalIncludeDirectories("ASM_MASM");
   masmOptions.PrependInheritedString("AdditionalOptions");
-  masmOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+  masmOptions.OutputFlagMap();
 
   e2.EndElement();
 }
@@ -3047,20 +3028,18 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions(
     return;
   }
   Elem e2(e1, "NASM");
-  e2.SetHasElements();
 
   std::vector<std::string> includes =
     this->GetIncludes(configName, "ASM_NASM");
-  Options& nasmOptions = *(this->NasmOptions[configName]);
-  nasmOptions.OutputAdditionalIncludeDirectories(e2.S, e2.Indent + 1,
-                                                 "ASM_NASM");
-  nasmOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+  OptionsHelper nasmOptions(*(this->NasmOptions[configName]), e2);
+  nasmOptions.OutputAdditionalIncludeDirectories("ASM_NASM");
+  nasmOptions.OutputFlagMap();
   nasmOptions.PrependInheritedString("AdditionalOptions");
-  nasmOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_NASM");
+  nasmOptions.OutputPreprocessorDefinitions("ASM_NASM");
 
   // Preprocessor definitions and includes are shared with clOptions.
-  Options& clOptions = *(this->ClOptions[configName]);
-  clOptions.OutputPreprocessorDefinitions(e2.S, e2.Indent + 1, "ASM_NASM");
+  OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
+  clOptions.OutputPreprocessorDefinitions("ASM_NASM");
 
   e2.EndElement();
 }
@@ -3077,14 +3056,14 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
     libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget);
   if (!libflags.empty()) {
     Elem e2(e1, "Lib");
-    e2.SetHasElements();
     cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
     cmVS10GeneratorOptions libOptions(this->LocalGenerator,
                                       cmVisualStudioGeneratorOptions::Linker,
                                       gg->GetLibFlagTable(), this);
     libOptions.Parse(libflags.c_str());
-    libOptions.PrependInheritedString("AdditionalOptions");
-    libOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+    OptionsHelper oh(libOptions, e2);
+    oh.PrependInheritedString("AdditionalOptions");
+    oh.OutputFlagMap();
     e2.EndElement();
   }
 
@@ -3514,13 +3493,12 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(
   if (this->ProjectType == csproj) {
     return;
   }
-  Options& linkOptions = *(this->LinkOptions[config]);
 
   {
     Elem e2(e1, "Link");
-    e2.SetHasElements();
+    OptionsHelper linkOptions(*(this->LinkOptions[config]), e2);
     linkOptions.PrependInheritedString("AdditionalOptions");
-    linkOptions.OutputFlagMap(e2.S, e2.Indent + 1);
+    linkOptions.OutputFlagMap();
     e2.EndElement();
   }
 
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index f6c5a64..d0fe51c 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -32,10 +32,6 @@ public:
                                   cmGlobalVisualStudio10Generator* gg);
   ~cmVisualStudio10TargetGenerator();
   void Generate();
-  // used by cmVisualStudioGeneratorOptions
-  std::string CalcCondition(const std::string& config) const;
-  void WritePlatformConfigTag(const char* tag, const std::string& config,
-                              int indentLevel, const std::string& content);
 
 private:
   struct ToolSource
@@ -54,13 +50,13 @@ private:
   };
 
   struct Elem;
+  struct OptionsHelper;
 
   std::string ConvertPath(std::string const& path, bool forceRelative);
   void WriteString(const char* line, int indentLevel);
-  void WriteElem(const char* tag, const char* val, int indentLevel);
-  void WriteElem(const char* tag, std::string const& val, int indentLevel);
-  void WriteElemEscapeXML(const char* tag, std::string const& val,
-                          int indentLevel);
+  std::string CalcCondition(const std::string& config) const;
+  void WritePlatformConfigTag(const char* tag, const std::string& config,
+                              Elem& parent, const std::string& content);
   void WriteProjectConfigurations(Elem& e0);
   void WriteProjectConfigurationValues(Elem& e0);
   void WriteMSToolConfigurationValues(Elem& e1, std::string const& config);
@@ -182,6 +178,7 @@ private:
   void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
 
 private:
+  friend class cmVS10GeneratorOptions;
   typedef cmVS10GeneratorOptions Options;
   typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap;
   OptionsMap ClOptions;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac5731a7e380349f19dc319e6c31e189b5faba93
commit ac5731a7e380349f19dc319e6c31e189b5faba93
Author:     Aleksandr Mezin <mezin.alexander at gmail.com>
AuthorDate: Wed May 2 04:16:55 2018 +0600
Commit:     Aleksandr Mezin <mezin.alexander at gmail.com>
CommitDate: Wed May 2 04:16:55 2018 +0600

    FindPkgConfig: correct library search path for imported targets.
    
    `-L` in LDFLAGS doesn't mean that standard search paths should be
    excluded. Example:
    
        $ pkg-config --libs libmutter-2
        -L/usr/lib/mutter -lmutter-2 -lgtk-3 -lgdk-3 -lmutter-clutter-2 -lcairo-gobject -latk-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -ljson-glib-1.0 -lgio-2.0 -lwayland-egl -lwayland-client -lXtst -lXi -lmutter-cogl-2 -lcairo
    -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lgbm -ldrm -lwayland-server -lEGL -lXext -lXdamage -lXfixes -lXcomposite -lXrandr -lX11
    
    Most of these libraries are located at standard paths, not in
    `/usr/lib/mutter`.
    
    Fixes: #17954

diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 415e914..95af0bf 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -200,9 +200,7 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
   unset(_search_paths)
   foreach (flag IN LISTS ${_prefix}_LDFLAGS)
     if (flag MATCHES "^-L(.*)")
-      # only look into the given paths from now on
       list(APPEND _search_paths ${CMAKE_MATCH_1})
-      set(_find_opts HINTS ${_search_paths} NO_DEFAULT_PATH)
       continue()
     endif()
     if (flag MATCHES "^-l(.*)")
@@ -211,6 +209,12 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
       continue()
     endif()
 
+    if(_search_paths)
+        # Firstly search in -L paths
+        find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
+                     NAMES ${_pkg_search}
+                     HINTS ${_search_paths} NO_DEFAULT_PATH)
+    endif()
     find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
                  NAMES ${_pkg_search}
                  ${_find_opts})

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

Summary of changes:
 Modules/FindPkgConfig.cmake                        |    8 +-
 Source/cmGeneratorTarget.cxx                       |    8 +-
 Source/cmVisualStudio10TargetGenerator.cxx         |  246 ++++++++++----------
 Source/cmVisualStudio10TargetGenerator.h           |   13 +-
 .../VS10Project/VsCSharpCustomTags-stderr.txt      |    3 +
 .../VS10Project/VsCSharpReferenceProps-stderr.txt  |    8 +
 6 files changed, 146 insertions(+), 140 deletions(-)
 create mode 100644 Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
 create mode 100644 Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list