summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-05-01 13:29:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-05-01 13:29:55 (GMT)
commit4bf49bc43764f33d135abf298812cf9e6531802d (patch)
treea33a1adef808f17d7c8d6a2647a12d6cc47d71e8 /Source
parent52f1aa10f8d946bbe20903d4878583cd27c271eb (diff)
parent142a85f9c17ae8266168eb8eb2e1c9dfb76f876e (diff)
downloadCMake-4bf49bc43764f33d135abf298812cf9e6531802d.zip
CMake-4bf49bc43764f33d135abf298812cf9e6531802d.tar.gz
CMake-4bf49bc43764f33d135abf298812cf9e6531802d.tar.bz2
Merge topic 'export-name-safe-name' into release-3.29
142a85f9c1 cxxmodules: use filesystem-safe export names in filenames 4452d41488 cmGeneratorTarget: add method to get a filesystem-safe export name Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !9474
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDyndepCollation.cxx10
-rw-r--r--Source/cmExportBuildFileGenerator.cxx4
-rw-r--r--Source/cmExportInstallFileGenerator.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx10
-rw-r--r--Source/cmGeneratorTarget.h1
5 files changed, 23 insertions, 6 deletions
diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx
index ed4762b..e7ec7ef 100644
--- a/Source/cmDyndepCollation.cxx
+++ b/Source/cmDyndepCollation.cxx
@@ -207,6 +207,7 @@ Json::Value CollationInformationExports(cmGeneratorTarget const* gt)
{
Json::Value tdi_exports = Json::arrayValue;
std::string export_name = gt->GetExportName();
+ std::string fs_export_name = gt->GetFilesystemExportName();
auto const& all_install_exports = gt->GetGlobalGenerator()->GetExportSets();
for (auto const& exp : all_install_exports) {
@@ -232,6 +233,7 @@ Json::Value CollationInformationExports(cmGeneratorTarget const* gt)
tdi_export_info["namespace"] = ns;
tdi_export_info["export-name"] = export_name;
+ tdi_export_info["filesystem-export-name"] = fs_export_name;
tdi_export_info["destination"] = dest;
tdi_export_info["cxx-module-info-dir"] = cxxm_dir;
tdi_export_info["export-prefix"] = export_prefix;
@@ -268,6 +270,7 @@ Json::Value CollationInformationExports(cmGeneratorTarget const* gt)
tdi_export_info["namespace"] = ns;
tdi_export_info["export-name"] = export_name;
+ tdi_export_info["filesystem-export-name"] = fs_export_name;
tdi_export_info["destination"] = dest;
tdi_export_info["cxx-module-info-dir"] = cxxm_dir;
tdi_export_info["export-prefix"] = export_prefix;
@@ -315,6 +318,7 @@ struct CxxModuleBmiInstall
struct CxxModuleExport
{
std::string Name;
+ std::string FilesystemName;
std::string Destination;
std::string Prefix;
std::string CxxModuleInfoDir;
@@ -352,6 +356,7 @@ cmDyndepCollation::ParseExportInfo(Json::Value const& tdi)
CxxModuleExport exp;
exp.Install = tdi_export["install"].asBool();
exp.Name = tdi_export["export-name"].asString();
+ exp.FilesystemName = tdi_export["filesystem-export-name"].asString();
exp.Destination = tdi_export["destination"].asString();
exp.Prefix = tdi_export["export-prefix"].asString();
exp.CxxModuleInfoDir = tdi_export["cxx-module-info-dir"].asString();
@@ -426,8 +431,9 @@ bool cmDyndepCollation::WriteDyndepMetadata(
std::string const export_dir =
cmStrCat(exp.Prefix, '/', exp.CxxModuleInfoDir, '/');
- std::string const property_file_path = cmStrCat(
- export_dir, "target-", exp.Name, '-', export_info.Config, ".cmake");
+ std::string const property_file_path =
+ cmStrCat(export_dir, "target-", exp.FilesystemName, '-',
+ export_info.Config, ".cmake");
properties = cm::make_unique<cmGeneratedFileStream>(property_file_path);
// Set up the preamble.
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 81e3d54..2345d64 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -591,8 +591,8 @@ bool cmExportBuildFileGenerator::GenerateImportCxxModuleConfigTargetInclusion(
continue;
}
- os << "include(\"${CMAKE_CURRENT_LIST_DIR}/target-" << tgt->GetExportName()
- << '-' << config << ".cmake\")\n";
+ os << "include(\"${CMAKE_CURRENT_LIST_DIR}/target-"
+ << tgt->GetFilesystemExportName() << '-' << config << ".cmake\")\n";
}
return true;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index c5b9dc9..5c95ecd 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -780,8 +780,8 @@ bool cmExportInstallFileGenerator::
continue;
}
- auto prop_filename = cmStrCat("target-", tgt->GetExportName(), '-',
- filename_config, ".cmake");
+ auto prop_filename = cmStrCat("target-", tgt->GetFilesystemExportName(),
+ '-', filename_config, ".cmake");
prop_files.emplace_back(cmStrCat(dest, prop_filename));
os << "include(\"${CMAKE_CURRENT_LIST_DIR}/" << prop_filename << "\")\n";
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f507807..ccb6748 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -368,6 +368,16 @@ std::string cmGeneratorTarget::GetExportName() const
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
{
if (cmValue result =
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index fd4b2ec..90b15ec 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -99,6 +99,7 @@ public:
cmStateEnums::TargetType GetType() const;
const std::string& GetName() const;
std::string GetExportName() const;
+ std::string GetFilesystemExportName() const;
std::vector<std::string> GetPropertyKeys() const;
//! Might return a nullptr if the property is not set or invalid