export: Generalize GenerateImportFileConfig

Move some logic that is specific to CMake-format exports from
GenerateImportFileConfig to an overload of GenerateImportConfig, so that
the former can be moved (back) to the generic base class. This will
allow it to also be used for Common Package Specification exports. To
facilitate this, also add a method to get the format-specific character
used to separate the export file base name from the config suffix, so
that the rest of the logic to determine the file name can be shared.
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index f9ee73d..f765493 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -87,7 +87,8 @@
 
   /** Generate per-configuration target information to the given output
       stream.  */
-  void GenerateImportConfig(std::ostream& os, std::string const& config);
+  virtual void GenerateImportConfig(std::ostream& os,
+                                    std::string const& config);
 
   /** Each subclass knows where the target files are located.  */
   virtual void GenerateImportTargetsConfig(std::ostream& os,
diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h
index 8fa3d3e..1e1a5a8 100644
--- a/Source/cmExportInstallAndroidMKGenerator.h
+++ b/Source/cmExportInstallAndroidMKGenerator.h
@@ -40,6 +40,8 @@
 protected:
   GenerateType GetGenerateType() const override { return INSTALL; }
 
+  char GetConfigFileNameSeparator() const override { return '-'; }
+
   // Implement virtual methods from the superclass.
   void ReportDuplicateTarget(std::string const& targetName) const;
   bool GenerateMainFile(std::ostream& os) override;
diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx
index e2185ed..e1b2285 100644
--- a/Source/cmExportInstallCMakeConfigGenerator.cxx
+++ b/Source/cmExportInstallCMakeConfigGenerator.cxx
@@ -13,6 +13,7 @@
 #include <cm/string_view>
 #include <cmext/string_view>
 
+#include "cmExportFileGenerator.h"
 #include "cmExportSet.h"
 #include "cmFileSet.h"
 #include "cmGeneratedFileStream.h"
@@ -224,48 +225,17 @@
   /* clang-format on */
 }
 
-bool cmExportInstallCMakeConfigGenerator::GenerateImportFileConfig(
-  std::string const& config)
+void cmExportInstallCMakeConfigGenerator::GenerateImportConfig(
+  std::ostream& os, std::string const& config)
 {
-  // Skip configurations not enabled for this export.
-  if (!this->IEGen->InstallsForConfig(config)) {
-    return true;
-  }
-
-  // Construct the name of the file to generate.
-  std::string fileName = cmStrCat(this->FileDir, '/', this->FileBase, '-');
-  if (!config.empty()) {
-    fileName += cmSystemTools::LowerCase(config);
-  } else {
-    fileName += "noconfig";
-  }
-  fileName += this->FileExt;
-
-  // Open the output file to generate it.
-  cmGeneratedFileStream exportFileStream(fileName, true);
-  if (!exportFileStream) {
-    std::string se = cmSystemTools::GetLastSystemError();
-    std::ostringstream e;
-    e << "cannot write to file \"" << fileName << "\": " << se;
-    cmSystemTools::Error(e.str());
-    return false;
-  }
-  exportFileStream.SetCopyIfDifferent(true);
-  std::ostream& os = exportFileStream;
-
   // Start with the import file header.
   this->GenerateImportHeaderCode(os, config);
 
   // Generate the per-config target information.
-  this->GenerateImportConfig(os, config);
+  this->cmExportFileGenerator::GenerateImportConfig(os, config);
 
   // End with the import file footer.
   this->GenerateImportFooterCode(os);
-
-  // Record this per-config import file.
-  this->ConfigImportFiles[config] = fileName;
-
-  return true;
 }
 
 void cmExportInstallCMakeConfigGenerator::GenerateImportTargetsConfig(
diff --git a/Source/cmExportInstallCMakeConfigGenerator.h b/Source/cmExportInstallCMakeConfigGenerator.h
index 2ef9af0..e56836b 100644
--- a/Source/cmExportInstallCMakeConfigGenerator.h
+++ b/Source/cmExportInstallCMakeConfigGenerator.h
@@ -49,6 +49,10 @@
   bool GenerateMainFile(std::ostream& os) override;
   void GenerateImportTargetsConfig(std::ostream& os, std::string const& config,
                                    std::string const& suffix) override;
+  void GenerateImportConfig(std::ostream& os,
+                            std::string const& config) override;
+
+  char GetConfigFileNameSeparator() const override { return '-'; }
 
   /** Generate the relative import prefix.  */
   virtual void GenerateImportPrefix(std::ostream&);
@@ -58,9 +62,6 @@
 
   virtual void CleanupTemporaryVariables(std::ostream&);
 
-  /** Generate a per-configuration file for the targets.  */
-  virtual bool GenerateImportFileConfig(std::string const& config);
-
   std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
                                     cmTargetExport const* te) override;
   std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 5e17131..e61e8c1 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -11,6 +11,7 @@
 #include <utility>
 
 #include "cmExportSet.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmInstallTargetGenerator.h"
@@ -98,6 +99,45 @@
   return importedXcFrameworkLocation;
 }
 
+bool cmExportInstallFileGenerator::GenerateImportFileConfig(
+  std::string const& config)
+{
+  // Skip configurations not enabled for this export.
+  if (!this->IEGen->InstallsForConfig(config)) {
+    return true;
+  }
+
+  // Construct the name of the file to generate.
+  std::string fileName = cmStrCat(this->FileDir, '/', this->FileBase,
+                                  this->GetConfigFileNameSeparator());
+  if (!config.empty()) {
+    fileName += cmSystemTools::LowerCase(config);
+  } else {
+    fileName += "noconfig";
+  }
+  fileName += this->FileExt;
+
+  // Open the output file to generate it.
+  cmGeneratedFileStream exportFileStream(fileName, true);
+  if (!exportFileStream) {
+    std::string se = cmSystemTools::GetLastSystemError();
+    std::ostringstream e;
+    e << "cannot write to file \"" << fileName << "\": " << se;
+    cmSystemTools::Error(e.str());
+    return false;
+  }
+  exportFileStream.SetCopyIfDifferent(true);
+  std::ostream& os = exportFileStream;
+
+  // Generate the per-config target information.
+  this->GenerateImportConfig(os, config);
+
+  // Record this per-config import file.
+  this->ConfigImportFiles[config] = fileName;
+
+  return true;
+}
+
 void cmExportInstallFileGenerator::SetImportLocationProperty(
   std::string const& config, std::string const& suffix,
   cmInstallTargetGenerator* itgen, ImportPropertyMap& properties,
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index a181b66..86c9949 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -78,6 +78,7 @@
     cm::string_view const& prefixWithSlash = this->GetImportPrefixWithSlash();
     return std::string(prefixWithSlash.data(), prefixWithSlash.length() - 1);
   }
+  virtual char GetConfigFileNameSeparator() const = 0;
 
   void HandleMissingTarget(std::string& link_libs,
                            cmGeneratorTarget const* depender,
@@ -96,6 +97,9 @@
 
   void ReportError(std::string const& errorMessage) const override;
 
+  /** Generate a per-configuration file for the targets.  */
+  virtual bool GenerateImportFileConfig(std::string const& config);
+
   /** Fill in properties indicating installed file locations.  */
   void SetImportLocationProperty(std::string const& config,
                                  std::string const& suffix,