diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-05-15 18:34:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-18 12:32:07 (GMT) |
commit | 56f7d6f827290dd7d4d5c6edf0fe12568d4a819e (patch) | |
tree | 800c5235e8aba10d1fbd401c2fabc391f633bc0c | |
parent | 8207a3a266d85e64532a2a69ccea344fd645fe53 (diff) | |
download | CMake-56f7d6f827290dd7d4d5c6edf0fe12568d4a819e.zip CMake-56f7d6f827290dd7d4d5c6edf0fe12568d4a819e.tar.gz CMake-56f7d6f827290dd7d4d5c6edf0fe12568d4a819e.tar.bz2 |
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.
-rw-r--r-- | Source/cmCxxModuleMapper.cxx | 44 | ||||
-rw-r--r-- | Source/cmCxxModuleMapper.h | 17 |
2 files changed, 61 insertions, 0 deletions
diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index 59bf4c7..e320f54 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -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 { diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index 0f453b0..f405054 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -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 |