summaryrefslogtreecommitdiffstats
path: root/Source/cmExportInstallCMakeConfigGenerator.cxx
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2024-07-18 15:20:58 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2024-07-25 22:33:35 (GMT)
commite5b73b60e385dbb37418f9707d8efd74fecd7cae (patch)
tree11cd975c19047f51ef08a0807433bc449ddab965 /Source/cmExportInstallCMakeConfigGenerator.cxx
parentcd217739f7883e8cfcac965b1a6cd83d24222c39 (diff)
downloadCMake-e5b73b60e385dbb37418f9707d8efd74fecd7cae.zip
CMake-e5b73b60e385dbb37418f9707d8efd74fecd7cae.tar.gz
CMake-e5b73b60e385dbb37418f9707d8efd74fecd7cae.tar.bz2
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.
Diffstat (limited to 'Source/cmExportInstallCMakeConfigGenerator.cxx')
-rw-r--r--Source/cmExportInstallCMakeConfigGenerator.cxx38
1 files changed, 4 insertions, 34 deletions
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 @@ void cmExportInstallCMakeConfigGenerator::LoadConfigFiles(std::ostream& os)
/* 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(