cmCxxModuleMapper: add a structure to represent BMI locations

This structure allows representing whether a module is private in order
to give a more useful error message when its usage is attempted from
another target.
This commit is contained in:
Ben Boeckel
2023-05-15 14:34:48 -04:00
committed by Brad King
parent 8207a3a266
commit 56f7d6f827
2 changed files with 61 additions and 0 deletions

View File

@@ -17,6 +17,50 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
CxxBmiLocation::CxxBmiLocation() = default;
CxxBmiLocation::CxxBmiLocation(std::string path)
: BmiLocation(std::move(path))
{
}
CxxBmiLocation CxxBmiLocation::Unknown()
{
return {};
}
CxxBmiLocation CxxBmiLocation::Private()
{
return { std::string{} };
}
CxxBmiLocation CxxBmiLocation::Known(std::string path)
{
return { std::move(path) };
}
bool CxxBmiLocation::IsKnown() const
{
return this->BmiLocation.has_value();
}
bool CxxBmiLocation::IsPrivate() const
{
if (auto const& loc = this->BmiLocation) {
return loc->empty();
}
return false;
}
std::string const& CxxBmiLocation::Location() const
{
if (auto const& loc = this->BmiLocation) {
return *loc;
}
static std::string empty;
return empty;
}
cm::optional<std::string> CxxModuleLocations::BmiGeneratorPathForModule(
std::string const& logical_name) const
{

View File

@@ -22,6 +22,23 @@ enum class CxxModuleMapFormat
Msvc,
};
struct CxxBmiLocation
{
static CxxBmiLocation Unknown();
static CxxBmiLocation Private();
static CxxBmiLocation Known(std::string path);
bool IsKnown() const;
bool IsPrivate() const;
std::string const& Location() const;
private:
CxxBmiLocation();
CxxBmiLocation(std::string path);
cm::optional<std::string> BmiLocation;
};
struct CxxModuleLocations
{
// The path from which all relative paths should be computed. If