Skip to content

Commit edca8d5

Browse files
committed
Merge branch 'fileapi-install-generators' into release-3.15
Merge-request: !3639
2 parents 1ea751c + d70a0f8 commit edca8d5

File tree

6 files changed

+58
-8
lines changed

6 files changed

+58
-8
lines changed

Source/cmFileAPICodemodel.cxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,12 +1025,9 @@ Json::Value Target::DumpInstallPrefix()
10251025
Json::Value Target::DumpInstallDestinations()
10261026
{
10271027
Json::Value destinations = Json::arrayValue;
1028-
auto installGens = this->GT->Makefile->GetInstallGenerators();
1029-
for (auto iGen : installGens) {
1030-
auto itGen = dynamic_cast<cmInstallTargetGenerator*>(iGen);
1031-
if (itGen != nullptr && itGen->GetTarget() == this->GT) {
1032-
destinations.append(this->DumpInstallDestination(itGen));
1033-
}
1028+
auto installGens = this->GT->Target->GetInstallGenerators();
1029+
for (auto itGen : installGens) {
1030+
destinations.append(this->DumpInstallDestination(itGen));
10341031
}
10351032
return destinations;
10361033
}

Source/cmInstallCommand.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(
4343
target.SetHaveInstallRule(true);
4444
const char* component = namelink ? args.GetNamelinkComponent().c_str()
4545
: args.GetComponent().c_str();
46-
return new cmInstallTargetGenerator(
46+
auto g = new cmInstallTargetGenerator(
4747
target.GetName(), destination.c_str(), impLib,
4848
args.GetPermissions().c_str(), args.GetConfigurations(), component,
4949
message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
5050
backtrace);
51+
target.AddInstallGenerator(g);
52+
return g;
5153
}
5254

5355
static cmInstallTargetGenerator* CreateInstallTargetGenerator(

Source/cmTarget.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class cmTargetInternals
177177
std::vector<cmCustomCommand> PreBuildCommands;
178178
std::vector<cmCustomCommand> PreLinkCommands;
179179
std::vector<cmCustomCommand> PostBuildCommands;
180+
std::vector<cmInstallTargetGenerator*> InstallGenerators;
180181
std::set<std::string> SystemIncludeDirectories;
181182
cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
182183
std::vector<std::string> IncludeDirectoriesEntries;
@@ -857,6 +858,17 @@ void cmTarget::SetHaveInstallRule(bool hir)
857858
impl->HaveInstallRule = hir;
858859
}
859860

861+
void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g)
862+
{
863+
impl->InstallGenerators.emplace_back(g);
864+
}
865+
866+
std::vector<cmInstallTargetGenerator*> const& cmTarget::GetInstallGenerators()
867+
const
868+
{
869+
return impl->InstallGenerators;
870+
}
871+
860872
bool cmTarget::GetIsGeneratorProvided() const
861873
{
862874
return impl->IsGeneratorProvided;

Source/cmTarget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
class cmCustomCommand;
2222
class cmGlobalGenerator;
23+
class cmInstallTargetGenerator;
2324
class cmMakefile;
2425
class cmMessenger;
2526
class cmPropertyMap;
@@ -146,6 +147,9 @@ class cmTarget
146147
bool GetHaveInstallRule() const;
147148
void SetHaveInstallRule(bool hir);
148149

150+
void AddInstallGenerator(cmInstallTargetGenerator* g);
151+
std::vector<cmInstallTargetGenerator*> const& GetInstallGenerators() const;
152+
149153
/**
150154
* Get/Set whether this target was auto-created by a generator.
151155
*/

Tests/RunCMake/FileAPI/codemodel-v2-check.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,40 @@ def gen_check_targets(c, g, inSource):
20872087
],
20882088
"build": "^cxx$",
20892089
"source": "^cxx$",
2090-
"install": None,
2090+
"install": {
2091+
"prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
2092+
"destinations": [
2093+
{
2094+
"path": "bin",
2095+
"backtrace": [
2096+
{
2097+
"file": "^codemodel-v2\\.cmake$",
2098+
"line": 37,
2099+
"command": "install",
2100+
"hasParent": True,
2101+
},
2102+
{
2103+
"file": "^codemodel-v2\\.cmake$",
2104+
"line": None,
2105+
"command": None,
2106+
"hasParent": True,
2107+
},
2108+
{
2109+
"file": "^CMakeLists\\.txt$",
2110+
"line": 3,
2111+
"command": "include",
2112+
"hasParent": True,
2113+
},
2114+
{
2115+
"file": "^CMakeLists\\.txt$",
2116+
"line": None,
2117+
"command": None,
2118+
"hasParent": False,
2119+
},
2120+
],
2121+
},
2122+
],
2123+
},
20912124
"link": {
20922125
"language": "CXX",
20932126
"lto": None,

Tests/RunCMake/FileAPI/codemodel-v2.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ if(_ipo)
3333
set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
3434
file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "")
3535
endif()
36+
37+
install(TARGETS cxx_exe)

0 commit comments

Comments
 (0)