mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
cmObjectLocation: support install-specific object locations
This will be used to implement custom install object paths. These can support per-configuration values much more easily as it is generator-agnostic.
This commit is contained in:
@@ -4054,7 +4054,8 @@ void cmGeneratorTarget::GetTargetObjectLocations(
|
||||
// Find the object file name corresponding to this source file.
|
||||
auto map_it = mapping.find(src);
|
||||
auto const& buildLoc = map_it->second.GetLocation(buildUseShortPaths);
|
||||
auto const& installLoc = map_it->second.GetLocation(installUseShortPaths);
|
||||
auto const& installLoc =
|
||||
map_it->second.GetInstallLocation(installUseShortPaths, config);
|
||||
// It must exist because we populated the mapping just above.
|
||||
assert(!buildLoc.GetPath().empty());
|
||||
assert(!installLoc.GetPath().empty());
|
||||
|
@@ -45,3 +45,22 @@ std::string const& cmObjectLocations::GetPath(UseShortPath use) const
|
||||
{
|
||||
return this->GetLocation(use).GetPath();
|
||||
}
|
||||
|
||||
cmObjectLocation const& cmObjectLocations::GetInstallLocation(
|
||||
UseShortPath use, std::string const& config) const
|
||||
{
|
||||
if (use == UseShortPath::Yes && this->ShortLoc) {
|
||||
return *this->ShortLoc;
|
||||
}
|
||||
auto it = this->InstallLongLoc.find(config);
|
||||
if (it != this->InstallLongLoc.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return this->LongLoc;
|
||||
}
|
||||
|
||||
std::string const& cmObjectLocations::GetInstallPath(
|
||||
UseShortPath use, std::string const& config) const
|
||||
{
|
||||
return this->GetInstallLocation(use, config).GetPath();
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -39,6 +40,7 @@ struct cmObjectLocations
|
||||
|
||||
cm::optional<cmObjectLocation> ShortLoc;
|
||||
cmObjectLocation LongLoc;
|
||||
std::map<std::string, cmObjectLocation> InstallLongLoc;
|
||||
|
||||
enum class UseShortPath
|
||||
{
|
||||
@@ -47,4 +49,9 @@ struct cmObjectLocations
|
||||
};
|
||||
cmObjectLocation const& GetLocation(UseShortPath use) const;
|
||||
std::string const& GetPath(UseShortPath use) const;
|
||||
|
||||
cmObjectLocation const& GetInstallLocation(UseShortPath use,
|
||||
std::string const& config) const;
|
||||
std::string const& GetInstallPath(UseShortPath use,
|
||||
std::string const& config) const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user