[Cmake-commits] CMake branch, master, updated. v3.15.1-570-g7eb2fd6

Kitware Robot kwrobot at kitware.com
Mon Aug 5 10:21:45 EDT 2019


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  7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 (commit)
       via  d70a0f8681919713940d254f9e23141f69f68c31 (commit)
      from  3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (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=7eb2fd6ca68e2681a08aef8b1dd8db253b172e00
commit 7eb2fd6ca68e2681a08aef8b1dd8db253b172e00
Merge: 3ebd3fa d70a0f8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 5 14:20:13 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Aug 5 10:20:27 2019 -0400

    Merge topic 'fileapi-install-generators'
    
    d70a0f8681 fileapi: Fix codemodel target install destination for cross-dir rules
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !3639


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d70a0f8681919713940d254f9e23141f69f68c31
commit d70a0f8681919713940d254f9e23141f69f68c31
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 31 15:17:45 2019 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jul 31 19:32:55 2019 -0400

    fileapi: Fix codemodel target install destination for cross-dir rules
    
    Since commit e89ad0f94e (install: Allow installing targets created in
    another directory, 2018-06-18, v3.13.0-rc1~407^2) we support calling
    `install(TARGETS)` for targets created in another directory.  However,
    install generators are associated with the directory in which the call
    to `install()` appears.  This may not be the same directory in which the
    target is defined.  Record in each target the list of install generators
    it has.
    
    Fixes: #19546

diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 0fb166a..6025025 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1025,12 +1025,9 @@ Json::Value Target::DumpInstallPrefix()
 Json::Value Target::DumpInstallDestinations()
 {
   Json::Value destinations = Json::arrayValue;
-  auto installGens = this->GT->Makefile->GetInstallGenerators();
-  for (auto iGen : installGens) {
-    auto itGen = dynamic_cast<cmInstallTargetGenerator*>(iGen);
-    if (itGen != nullptr && itGen->GetTarget() == this->GT) {
-      destinations.append(this->DumpInstallDestination(itGen));
-    }
+  auto installGens = this->GT->Target->GetInstallGenerators();
+  for (auto itGen : installGens) {
+    destinations.append(this->DumpInstallDestination(itGen));
   }
   return destinations;
 }
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index dba4bbb..c9e6923 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -43,11 +43,13 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(
   target.SetHaveInstallRule(true);
   const char* component = namelink ? args.GetNamelinkComponent().c_str()
                                    : args.GetComponent().c_str();
-  return new cmInstallTargetGenerator(
+  auto g = new cmInstallTargetGenerator(
     target.GetName(), destination.c_str(), impLib,
     args.GetPermissions().c_str(), args.GetConfigurations(), component,
     message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
     backtrace);
+  target.AddInstallGenerator(g);
+  return g;
 }
 
 static cmInstallTargetGenerator* CreateInstallTargetGenerator(
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index cd67586..a67122c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -177,6 +177,7 @@ public:
   std::vector<cmCustomCommand> PreBuildCommands;
   std::vector<cmCustomCommand> PreLinkCommands;
   std::vector<cmCustomCommand> PostBuildCommands;
+  std::vector<cmInstallTargetGenerator*> InstallGenerators;
   std::set<std::string> SystemIncludeDirectories;
   cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
   std::vector<std::string> IncludeDirectoriesEntries;
@@ -857,6 +858,17 @@ void cmTarget::SetHaveInstallRule(bool hir)
   impl->HaveInstallRule = hir;
 }
 
+void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g)
+{
+  impl->InstallGenerators.emplace_back(g);
+}
+
+std::vector<cmInstallTargetGenerator*> const& cmTarget::GetInstallGenerators()
+  const
+{
+  return impl->InstallGenerators;
+}
+
 bool cmTarget::GetIsGeneratorProvided() const
 {
   return impl->IsGeneratorProvided;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index fdcca47..2bd9e6d 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -20,6 +20,7 @@
 
 class cmCustomCommand;
 class cmGlobalGenerator;
+class cmInstallTargetGenerator;
 class cmMakefile;
 class cmMessenger;
 class cmPropertyMap;
@@ -146,6 +147,9 @@ public:
   bool GetHaveInstallRule() const;
   void SetHaveInstallRule(bool hir);
 
+  void AddInstallGenerator(cmInstallTargetGenerator* g);
+  std::vector<cmInstallTargetGenerator*> const& GetInstallGenerators() const;
+
   /**
    * Get/Set whether this target was auto-created by a generator.
    */
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
index 18b9347..3096358 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -2087,7 +2087,40 @@ def gen_check_targets(c, g, inSource):
             ],
             "build": "^cxx$",
             "source": "^cxx$",
-            "install": None,
+            "install": {
+                "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
+                "destinations": [
+                    {
+                        "path": "bin",
+                        "backtrace": [
+                            {
+                                "file": "^codemodel-v2\\.cmake$",
+                                "line": 37,
+                                "command": "install",
+                                "hasParent": True,
+                            },
+                            {
+                                "file": "^codemodel-v2\\.cmake$",
+                                "line": None,
+                                "command": None,
+                                "hasParent": True,
+                            },
+                            {
+                                "file": "^CMakeLists\\.txt$",
+                                "line": 3,
+                                "command": "include",
+                                "hasParent": True,
+                            },
+                            {
+                                "file": "^CMakeLists\\.txt$",
+                                "line": None,
+                                "command": None,
+                                "hasParent": False,
+                            },
+                        ],
+                    },
+                ],
+            },
             "link": {
                 "language": "CXX",
                 "lto": None,
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake
index 72073d5..c98a84c 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake
+++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake
@@ -33,3 +33,5 @@ if(_ipo)
   set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
   file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "")
 endif()
+
+install(TARGETS cxx_exe)

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

Summary of changes:
 Source/cmFileAPICodemodel.cxx                |  9 +++----
 Source/cmInstallCommand.cxx                  |  4 +++-
 Source/cmTarget.cxx                          | 12 ++++++++++
 Source/cmTarget.h                            |  4 ++++
 Tests/RunCMake/FileAPI/codemodel-v2-check.py | 35 +++++++++++++++++++++++++++-
 Tests/RunCMake/FileAPI/codemodel-v2.cmake    |  2 ++
 6 files changed, 58 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list