cmake/Source/cmExportSet.cxx

74 lines
2.1 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2013-03-16 19:13:01 +02:00
#include "cmExportSet.h"
2016-07-09 11:21:54 +02:00
2022-07-29 21:54:54 +02:00
#include <algorithm>
2020-02-01 23:06:01 +01:00
#include <tuple>
#include <utility>
2022-07-29 21:54:54 +02:00
#include "cmGeneratorTarget.h"
2016-03-13 13:35:51 +01:00
#include "cmLocalGenerator.h"
2022-07-29 21:54:54 +02:00
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
2016-07-09 11:21:54 +02:00
#include "cmTargetExport.h"
2013-03-16 19:13:01 +02:00
2020-02-01 23:06:01 +01:00
cmExportSet::cmExportSet(std::string name)
: Name(std::move(name))
2013-03-16 19:13:01 +02:00
{
}
2020-02-01 23:06:01 +01:00
cmExportSet::~cmExportSet() = default;
2022-07-29 21:54:54 +02:00
bool cmExportSet::Compute(cmLocalGenerator* lg)
2016-03-13 13:35:51 +01:00
{
2020-02-01 23:06:01 +01:00
for (std::unique_ptr<cmTargetExport>& tgtExport : this->TargetExports) {
2018-01-26 17:06:56 +01:00
tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
2022-07-29 21:54:54 +02:00
auto const interfaceFileSets =
tgtExport->Target->Target->GetAllInterfaceFileSets();
auto const fileSetInTargetExport =
[&tgtExport, lg](const std::string& fileSetName) -> bool {
auto* fileSet = tgtExport->Target->Target->GetFileSet(fileSetName);
if (!tgtExport->FileSetGenerators.count(fileSet)) {
lg->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("File set \"", fileSetName,
"\" is listed in interface file sets of ",
tgtExport->Target->GetName(),
" but has not been exported"));
return false;
}
return true;
};
if (!std::all_of(interfaceFileSets.begin(), interfaceFileSets.end(),
fileSetInTargetExport)) {
return false;
}
2016-07-09 11:21:54 +02:00
}
2022-07-29 21:54:54 +02:00
return true;
2016-03-13 13:35:51 +01:00
}
2020-02-01 23:06:01 +01:00
void cmExportSet::AddTargetExport(std::unique_ptr<cmTargetExport> te)
2013-03-16 19:13:01 +02:00
{
2020-02-01 23:06:01 +01:00
this->TargetExports.emplace_back(std::move(te));
2013-03-16 19:13:01 +02:00
}
void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation)
{
this->Installations.push_back(installation);
}
2020-02-01 23:06:01 +01:00
cmExportSet& cmExportSetMap::operator[](const std::string& name)
{
auto it = this->find(name);
if (it == this->end()) // Export set not found
{
auto tup_name = std::make_tuple(name);
it = this->emplace(std::piecewise_construct, tup_name, tup_name).first;
}
return it->second;
}