summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-05 14:20:13 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-08-05 14:20:27 (GMT)
commit7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 (patch)
tree38cbf15a897580da28834824f1b9af83a9139072
parent3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (diff)
parentd70a0f8681919713940d254f9e23141f69f68c31 (diff)
downloadCMake-7eb2fd6ca68e2681a08aef8b1dd8db253b172e00.zip
CMake-7eb2fd6ca68e2681a08aef8b1dd8db253b172e00.tar.gz
CMake-7eb2fd6ca68e2681a08aef8b1dd8db253b172e00.tar.bz2
Merge topic 'fileapi-install-generators'
d70a0f8681 fileapi: Fix codemodel target install destination for cross-dir rules Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3639
-rw-r--r--Source/cmFileAPICodemodel.cxx9
-rw-r--r--Source/cmInstallCommand.cxx4
-rw-r--r--Source/cmTarget.cxx12
-rw-r--r--Source/cmTarget.h4
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-check.py35
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2.cmake2
6 files changed, 58 insertions, 8 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index e9ee7f5..172897c 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1144,12 +1144,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 aca7268..5349a9d 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 beccfce..7ca2391 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -180,6 +180,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;
@@ -873,6 +874,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 4e5141b..2b75879 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -21,6 +21,7 @@
class cmCustomCommand;
class cmGlobalGenerator;
+class cmInstallTargetGenerator;
class cmMakefile;
class cmMessenger;
class cmPropertyMap;
@@ -147,6 +148,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 3b0ec6e..89f63d0 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -2092,7 +2092,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)