mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
cmGeneratorTarget: add method to get a filesystem-safe export name
C++ module support puts the export name in a filename. Export names with `:` in them are not valid filenames on Windows. Add a method to escape names as necessary. See: #25828
This commit is contained in:
@@ -367,6 +367,16 @@ std::string cmGeneratorTarget::GetExportName() const
|
|||||||
return this->GetName();
|
return this->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmGeneratorTarget::GetFilesystemExportName() const
|
||||||
|
{
|
||||||
|
auto fs_safe = this->GetExportName();
|
||||||
|
// First escape any `_` characters to avoid collisions.
|
||||||
|
cmSystemTools::ReplaceString(fs_safe, "_", "__");
|
||||||
|
// Escape other characters that are not generally filesystem-safe.
|
||||||
|
cmSystemTools::ReplaceString(fs_safe, ":", "_c");
|
||||||
|
return fs_safe;
|
||||||
|
}
|
||||||
|
|
||||||
cmValue cmGeneratorTarget::GetProperty(const std::string& prop) const
|
cmValue cmGeneratorTarget::GetProperty(const std::string& prop) const
|
||||||
{
|
{
|
||||||
if (cmValue result =
|
if (cmValue result =
|
||||||
|
@@ -99,6 +99,7 @@ public:
|
|||||||
cmStateEnums::TargetType GetType() const;
|
cmStateEnums::TargetType GetType() const;
|
||||||
const std::string& GetName() const;
|
const std::string& GetName() const;
|
||||||
std::string GetExportName() const;
|
std::string GetExportName() const;
|
||||||
|
std::string GetFilesystemExportName() const;
|
||||||
|
|
||||||
std::vector<std::string> GetPropertyKeys() const;
|
std::vector<std::string> GetPropertyKeys() const;
|
||||||
//! Might return a nullptr if the property is not set or invalid
|
//! Might return a nullptr if the property is not set or invalid
|
||||||
|
Reference in New Issue
Block a user