[cmake-developers] How to get install locations?
Brad King
brad.king at kitware.com
Thu Mar 23 13:10:39 EDT 2017
On 03/23/2017 11:37 AM, Tobias Hunger wrote:
> cmInstallTargetGenerator has std::string GetDestination(std::string
> const& config) const, too, which might have what I need. Unfortunately
> that is not static, so I need to figure out how to get the right
> instance of cmInstallTargetGenerator.
>
> I tried to get the cmMakefile from the localGenerator and then iterate
> over the list of cmInstallGenerator* I got from the cmMakefile's
> GetInstallGenerators() method. But that in empty after I am done with
> configure. Is that expected?
>
> Am I on the right track with this?
Yes, but there is a separate list in each cmMakefile for each source
directory. You'd have to traverse the entire structure to find all
of them.
> One cmInstallTargetGenerator seems to install one file only and there
> seems to be one per cmGeneratorTarget. Is that correct? How does the
> installation of targets with multiple artifacts work?
They are created by install() command invocations. See the impl in
`Source/cmInstallCommand.cxx`. For each target the artifacts are
each given an install generator. Then there is a block that adds
all of them:
```
this->Makefile->AddInstallGenerator(archiveGenerator);
this->Makefile->AddInstallGenerator(libraryGenerator);
this->Makefile->AddInstallGenerator(runtimeGenerator);
...
```
The code model reported by your protocol needs to cover the possibility
of more than one install(TARGETS) command for a given target. Each
target may be installed to zero or more destinations. You could either
try to put this in a list inside each target, or separately model our
concept of installation lists that reference targets instead.
-Brad
More information about the cmake-developers
mailing list