mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
export: Factor out CMake-specific export generation (1/2)
In order to support generation of Common Package Specifications, the mechanisms CMake uses to export package information need to be made more abstract. As a first step toward this, refactor cmInstallExportGenerator so that logic specific to config.cmake and Android .mk lives in separate subclasses. While we're at it, clean up the code style a bit and try to use moves a bit more consistently. This is step 1 of 2. The next step will refactor the individual file generators along similar lines, which will also involve creating additional classes for format-agnostic logic that is shared between build-tree and install-tree variants.
This commit is contained in:
@@ -311,6 +311,10 @@ add_library(
|
|||||||
cmGraphVizWriter.h
|
cmGraphVizWriter.h
|
||||||
cmImportedCxxModuleInfo.cxx
|
cmImportedCxxModuleInfo.cxx
|
||||||
cmImportedCxxModuleInfo.h
|
cmImportedCxxModuleInfo.h
|
||||||
|
cmInstallAndroidMKExportGenerator.cxx
|
||||||
|
cmInstallAndroidMKExportGenerator.h
|
||||||
|
cmInstallCMakeConfigExportGenerator.cxx
|
||||||
|
cmInstallCMakeConfigExportGenerator.h
|
||||||
cmInstallGenerator.h
|
cmInstallGenerator.h
|
||||||
cmInstallGenerator.cxx
|
cmInstallGenerator.cxx
|
||||||
cmInstallGetRuntimeDependenciesGenerator.h
|
cmInstallGetRuntimeDependenciesGenerator.h
|
||||||
|
@@ -1635,6 +1635,18 @@ void cmExportFileGenerator::GenerateTargetFileSets(cmGeneratorTarget* gte,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmExportFileGenerator::GetCxxModuleFile(
|
||||||
|
std::string const& name) const
|
||||||
|
{
|
||||||
|
auto const& cxxModuleDirname = this->GetCxxModulesDirectory();
|
||||||
|
if (cxxModuleDirname.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmStrCat(cmSystemTools::GetFilenamePath(this->MainImportFile), '/',
|
||||||
|
cxxModuleDirname, "/cxx-modules-", name, ".cmake");
|
||||||
|
}
|
||||||
|
|
||||||
void cmExportFileGenerator::GenerateCxxModuleInformation(
|
void cmExportFileGenerator::GenerateCxxModuleInformation(
|
||||||
std::string const& name, std::ostream& os)
|
std::string const& name, std::ostream& os)
|
||||||
{
|
{
|
||||||
@@ -1648,14 +1660,8 @@ void cmExportFileGenerator::GenerateCxxModuleInformation(
|
|||||||
<< "include(\"${CMAKE_CURRENT_LIST_DIR}/" << cxx_module_dirname
|
<< "include(\"${CMAKE_CURRENT_LIST_DIR}/" << cxx_module_dirname
|
||||||
<< "/cxx-modules-" << name << ".cmake\")\n\n";
|
<< "/cxx-modules-" << name << ".cmake\")\n\n";
|
||||||
|
|
||||||
// Get the path to the file we're going to write.
|
|
||||||
std::string path = this->MainImportFile;
|
|
||||||
path = cmSystemTools::GetFilenamePath(path);
|
|
||||||
auto trampoline_path =
|
|
||||||
cmStrCat(path, '/', cxx_module_dirname, "/cxx-modules-", name, ".cmake");
|
|
||||||
|
|
||||||
// Include all configuration-specific include files.
|
// Include all configuration-specific include files.
|
||||||
cmGeneratedFileStream ap(trampoline_path, true);
|
cmGeneratedFileStream ap(this->GetCxxModuleFile(name), true);
|
||||||
ap.SetCopyIfDifferent(true);
|
ap.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
this->GenerateCxxModuleConfigInformation(name, ap);
|
this->GenerateCxxModuleConfigInformation(name, ap);
|
||||||
|
@@ -207,6 +207,8 @@ protected:
|
|||||||
|
|
||||||
virtual cmExportSet* GetExportSet() const { return nullptr; }
|
virtual cmExportSet* GetExportSet() const { return nullptr; }
|
||||||
|
|
||||||
|
std::string GetCxxModuleFile(std::string const& name) const;
|
||||||
|
|
||||||
void SetRequiredCMakeVersion(unsigned int major, unsigned int minor,
|
void SetRequiredCMakeVersion(unsigned int major, unsigned int minor,
|
||||||
unsigned int patch);
|
unsigned int patch);
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||||||
std::string expectedTargets;
|
std::string expectedTargets;
|
||||||
std::string sep;
|
std::string sep;
|
||||||
for (std::unique_ptr<cmTargetExport> const& te :
|
for (std::unique_ptr<cmTargetExport> const& te :
|
||||||
this->IEGen->GetExportSet()->GetTargetExports()) {
|
this->GetExportSet()->GetTargetExports()) {
|
||||||
if (te->NamelinkOnly) {
|
if (te->NamelinkOnly) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||||||
allTargets.push_back(te.get());
|
allTargets.push_back(te.get());
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
|
e << "install(EXPORT \"" << this->GetExportSet()->GetName()
|
||||||
<< "\" ...) "
|
<< "\" ...) "
|
||||||
<< "includes target \"" << te->Target->GetName()
|
<< "includes target \"" << te->Target->GetName()
|
||||||
<< "\" more than once in the export set.";
|
<< "\" more than once in the export set.";
|
||||||
@@ -172,7 +172,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
std::string cxx_modules_name = this->IEGen->GetExportSet()->GetName();
|
std::string cxx_modules_name = this->GetExportSet()->GetName();
|
||||||
this->GenerateCxxModuleInformation(cxx_modules_name, os);
|
this->GenerateCxxModuleInformation(cxx_modules_name, os);
|
||||||
if (requiresConfigFiles) {
|
if (requiresConfigFiles) {
|
||||||
for (std::string const& c : this->Configurations) {
|
for (std::string const& c : this->Configurations) {
|
||||||
@@ -338,7 +338,7 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
|
|||||||
{
|
{
|
||||||
// Add each target in the set to the export.
|
// Add each target in the set to the export.
|
||||||
for (std::unique_ptr<cmTargetExport> const& te :
|
for (std::unique_ptr<cmTargetExport> const& te :
|
||||||
this->IEGen->GetExportSet()->GetTargetExports()) {
|
this->GetExportSet()->GetTargetExports()) {
|
||||||
// Collect import properties for this target.
|
// Collect import properties for this target.
|
||||||
if (this->GetExportTargetType(te.get()) ==
|
if (this->GetExportTargetType(te.get()) ==
|
||||||
cmStateEnums::INTERFACE_LIBRARY) {
|
cmStateEnums::INTERFACE_LIBRARY) {
|
||||||
@@ -559,8 +559,7 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
|
|||||||
std::vector<std::string> const& exportFiles)
|
std::vector<std::string> const& exportFiles)
|
||||||
{
|
{
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
|
e << "install(EXPORT \"" << this->GetExportSet()->GetName() << "\" ...) "
|
||||||
<< "\" ...) "
|
|
||||||
<< "includes target \"" << depender->GetName()
|
<< "includes target \"" << depender->GetName()
|
||||||
<< "\" which requires target \"" << dependee->GetName() << "\" ";
|
<< "\" which requires target \"" << dependee->GetName() << "\" ";
|
||||||
if (exportFiles.empty()) {
|
if (exportFiles.empty()) {
|
||||||
@@ -742,6 +741,11 @@ void cmExportInstallFileGenerator::GenerateCxxModuleConfigInformation(
|
|||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmExportInstallFileGenerator::GetCxxModuleFile() const
|
||||||
|
{
|
||||||
|
return this->GetCxxModuleFile(this->GetExportSet()->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
bool cmExportInstallFileGenerator::
|
bool cmExportInstallFileGenerator::
|
||||||
GenerateImportCxxModuleConfigTargetInclusion(std::string const& name,
|
GenerateImportCxxModuleConfigTargetInclusion(std::string const& name,
|
||||||
std::string const& config)
|
std::string const& config)
|
||||||
|
@@ -51,6 +51,9 @@ public:
|
|||||||
return this->ConfigImportFiles;
|
return this->ConfigImportFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the temporary location of the config-agnostic C++ module file. */
|
||||||
|
std::string GetCxxModuleFile() const;
|
||||||
|
|
||||||
/** Get the per-config C++ module file generated for each configuration.
|
/** Get the per-config C++ module file generated for each configuration.
|
||||||
This maps from the configuration name to the file temporary location
|
This maps from the configuration name to the file temporary location
|
||||||
for installation. */
|
for installation. */
|
||||||
@@ -118,6 +121,8 @@ protected:
|
|||||||
std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
|
std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
|
||||||
cmTargetExport* te) override;
|
cmTargetExport* te) override;
|
||||||
|
|
||||||
|
using cmExportFileGenerator::GetCxxModuleFile;
|
||||||
|
|
||||||
std::string GetCxxModulesDirectory() const override;
|
std::string GetCxxModulesDirectory() const override;
|
||||||
void GenerateCxxModuleConfigInformation(std::string const&,
|
void GenerateCxxModuleConfigInformation(std::string const&,
|
||||||
std::ostream&) const override;
|
std::ostream&) const override;
|
||||||
|
38
Source/cmInstallAndroidMKExportGenerator.cxx
Normal file
38
Source/cmInstallAndroidMKExportGenerator.cxx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#include "cmInstallAndroidMKExportGenerator.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <cm/memory>
|
||||||
|
|
||||||
|
#include "cmExportInstallAndroidMKGenerator.h"
|
||||||
|
#include "cmExportInstallFileGenerator.h"
|
||||||
|
#include "cmListFileCache.h"
|
||||||
|
|
||||||
|
class cmExportSet;
|
||||||
|
|
||||||
|
cmInstallAndroidMKExportGenerator::cmInstallAndroidMKExportGenerator(
|
||||||
|
cmExportSet* exportSet, std::string destination, std::string filePermissions,
|
||||||
|
std::vector<std::string> const& configurations, std::string component,
|
||||||
|
MessageLevel message, bool excludeFromAll, std::string filename,
|
||||||
|
std::string targetNamespace, bool exportOld, cmListFileBacktrace backtrace)
|
||||||
|
: cmInstallExportGenerator(exportSet, std::move(destination),
|
||||||
|
std::move(filePermissions), configurations,
|
||||||
|
std::move(component), message, excludeFromAll,
|
||||||
|
std::move(filename), std::move(targetNamespace),
|
||||||
|
std::string{}, std::move(backtrace))
|
||||||
|
, ExportOld(exportOld)
|
||||||
|
{
|
||||||
|
this->EFGen = cm::make_unique<cmExportInstallAndroidMKGenerator>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmInstallAndroidMKExportGenerator::~cmInstallAndroidMKExportGenerator() =
|
||||||
|
default;
|
||||||
|
|
||||||
|
void cmInstallAndroidMKExportGenerator::GenerateScript(std::ostream& os)
|
||||||
|
{
|
||||||
|
this->EFGen->SetExportOld(this->ExportOld);
|
||||||
|
|
||||||
|
this->cmInstallExportGenerator::GenerateScript(os);
|
||||||
|
}
|
40
Source/cmInstallAndroidMKExportGenerator.h
Normal file
40
Source/cmInstallAndroidMKExportGenerator.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "cmInstallExportGenerator.h"
|
||||||
|
|
||||||
|
class cmExportSet;
|
||||||
|
class cmListFileBacktrace;
|
||||||
|
|
||||||
|
/** \class cmInstallAndroidMKExportGenerator
|
||||||
|
* \brief Generate rules for creating Android .mk export files.
|
||||||
|
*/
|
||||||
|
class cmInstallAndroidMKExportGenerator : public cmInstallExportGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cmInstallAndroidMKExportGenerator(
|
||||||
|
cmExportSet* exportSet, std::string destination,
|
||||||
|
std::string filePermissions,
|
||||||
|
std::vector<std::string> const& configurations, std::string component,
|
||||||
|
MessageLevel message, bool excludeFromAll, std::string filename,
|
||||||
|
std::string targetNamespace, bool exportOld,
|
||||||
|
cmListFileBacktrace backtrace);
|
||||||
|
cmInstallAndroidMKExportGenerator(cmInstallAndroidMKExportGenerator const&) =
|
||||||
|
delete;
|
||||||
|
~cmInstallAndroidMKExportGenerator() override;
|
||||||
|
|
||||||
|
cmInstallAndroidMKExportGenerator& operator=(
|
||||||
|
cmInstallAndroidMKExportGenerator const&) = delete;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
char const* InstallSubcommand() const override { return "EXPORT"; }
|
||||||
|
|
||||||
|
void GenerateScript(std::ostream& os) override;
|
||||||
|
|
||||||
|
bool const ExportOld;
|
||||||
|
};
|
40
Source/cmInstallCMakeConfigExportGenerator.cxx
Normal file
40
Source/cmInstallCMakeConfigExportGenerator.cxx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#include "cmInstallCMakeConfigExportGenerator.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <cm/memory>
|
||||||
|
|
||||||
|
#include "cmExportInstallFileGenerator.h"
|
||||||
|
#include "cmListFileCache.h"
|
||||||
|
|
||||||
|
class cmExportSet;
|
||||||
|
|
||||||
|
cmInstallCMakeConfigExportGenerator::cmInstallCMakeConfigExportGenerator(
|
||||||
|
cmExportSet* exportSet, std::string destination, std::string filePermissions,
|
||||||
|
std::vector<std::string> const& configurations, std::string component,
|
||||||
|
MessageLevel message, bool excludeFromAll, std::string filename,
|
||||||
|
std::string targetNamespace, std::string cxxModulesDirectory, bool exportOld,
|
||||||
|
bool exportPackageDependencies, cmListFileBacktrace backtrace)
|
||||||
|
: cmInstallExportGenerator(
|
||||||
|
exportSet, std::move(destination), std::move(filePermissions),
|
||||||
|
configurations, std::move(component), message, excludeFromAll,
|
||||||
|
std::move(filename), std::move(targetNamespace),
|
||||||
|
std::move(cxxModulesDirectory), std::move(backtrace))
|
||||||
|
, ExportOld(exportOld)
|
||||||
|
, ExportPackageDependencies(exportPackageDependencies)
|
||||||
|
{
|
||||||
|
this->EFGen = cm::make_unique<cmExportInstallFileGenerator>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmInstallCMakeConfigExportGenerator::~cmInstallCMakeConfigExportGenerator() =
|
||||||
|
default;
|
||||||
|
|
||||||
|
void cmInstallCMakeConfigExportGenerator::GenerateScript(std::ostream& os)
|
||||||
|
{
|
||||||
|
this->EFGen->SetExportOld(this->ExportOld);
|
||||||
|
this->EFGen->SetExportPackageDependencies(this->ExportPackageDependencies);
|
||||||
|
|
||||||
|
this->cmInstallExportGenerator::GenerateScript(os);
|
||||||
|
}
|
42
Source/cmInstallCMakeConfigExportGenerator.h
Normal file
42
Source/cmInstallCMakeConfigExportGenerator.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "cmInstallExportGenerator.h"
|
||||||
|
|
||||||
|
class cmExportSet;
|
||||||
|
class cmListFileBacktrace;
|
||||||
|
|
||||||
|
/** \class cmInstallCMakeConfigExportGenerator
|
||||||
|
* \brief Generate rules for creating CMake export files.
|
||||||
|
*/
|
||||||
|
class cmInstallCMakeConfigExportGenerator : public cmInstallExportGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cmInstallCMakeConfigExportGenerator(
|
||||||
|
cmExportSet* exportSet, std::string destination,
|
||||||
|
std::string filePermissions,
|
||||||
|
std::vector<std::string> const& configurations, std::string component,
|
||||||
|
MessageLevel message, bool excludeFromAll, std::string filename,
|
||||||
|
std::string targetNamespace, std::string cxxModulesDirectory,
|
||||||
|
bool exportOld, bool exportPackageDependencies,
|
||||||
|
cmListFileBacktrace backtrace);
|
||||||
|
cmInstallCMakeConfigExportGenerator(
|
||||||
|
cmInstallCMakeConfigExportGenerator const&) = delete;
|
||||||
|
~cmInstallCMakeConfigExportGenerator() override;
|
||||||
|
|
||||||
|
cmInstallCMakeConfigExportGenerator& operator=(
|
||||||
|
cmInstallCMakeConfigExportGenerator const&) = delete;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
char const* InstallSubcommand() const override { return "EXPORT"; }
|
||||||
|
|
||||||
|
void GenerateScript(std::ostream& os) override;
|
||||||
|
|
||||||
|
bool const ExportOld;
|
||||||
|
bool const ExportPackageDependencies;
|
||||||
|
};
|
@@ -26,10 +26,11 @@
|
|||||||
#include "cmFileSet.h"
|
#include "cmFileSet.h"
|
||||||
#include "cmGeneratorExpression.h"
|
#include "cmGeneratorExpression.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
|
#include "cmInstallAndroidMKExportGenerator.h"
|
||||||
|
#include "cmInstallCMakeConfigExportGenerator.h"
|
||||||
#include "cmInstallCommandArguments.h"
|
#include "cmInstallCommandArguments.h"
|
||||||
#include "cmInstallCxxModuleBmiGenerator.h"
|
#include "cmInstallCxxModuleBmiGenerator.h"
|
||||||
#include "cmInstallDirectoryGenerator.h"
|
#include "cmInstallDirectoryGenerator.h"
|
||||||
#include "cmInstallExportGenerator.h"
|
|
||||||
#include "cmInstallFileSetGenerator.h"
|
#include "cmInstallFileSetGenerator.h"
|
||||||
#include "cmInstallFilesGenerator.h"
|
#include "cmInstallFilesGenerator.h"
|
||||||
#include "cmInstallGenerator.h"
|
#include "cmInstallGenerator.h"
|
||||||
@@ -2028,11 +2029,11 @@ bool HandleExportAndroidMKMode(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
// Create the export install generator.
|
// Create the export install generator.
|
||||||
helper.Makefile->AddInstallGenerator(
|
helper.Makefile->AddInstallGenerator(
|
||||||
cm::make_unique<cmInstallExportGenerator>(
|
cm::make_unique<cmInstallAndroidMKExportGenerator>(
|
||||||
&exportSet, ica.GetDestination(), ica.GetPermissions(),
|
&exportSet, ica.GetDestination(), ica.GetPermissions(),
|
||||||
ica.GetConfigurations(), ica.GetComponent(), message,
|
ica.GetConfigurations(), ica.GetComponent(), message,
|
||||||
ica.GetExcludeFromAll(), fname, name_space, "", exportOld, true, false,
|
ica.GetExcludeFromAll(), std::move(fname), std::move(name_space),
|
||||||
helper.Makefile->GetBacktrace()));
|
exportOld, helper.Makefile->GetBacktrace()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@@ -2151,11 +2152,11 @@ bool HandleExportMode(std::vector<std::string> const& args,
|
|||||||
|
|
||||||
// Create the export install generator.
|
// Create the export install generator.
|
||||||
helper.Makefile->AddInstallGenerator(
|
helper.Makefile->AddInstallGenerator(
|
||||||
cm::make_unique<cmInstallExportGenerator>(
|
cm::make_unique<cmInstallCMakeConfigExportGenerator>(
|
||||||
&exportSet, ica.GetDestination(), ica.GetPermissions(),
|
&exportSet, ica.GetDestination(), ica.GetPermissions(),
|
||||||
ica.GetConfigurations(), ica.GetComponent(), message,
|
ica.GetConfigurations(), ica.GetComponent(), message,
|
||||||
ica.GetExcludeFromAll(), fname, name_space, cxx_modules_directory,
|
ica.GetExcludeFromAll(), std::move(fname), std::move(name_space),
|
||||||
exportOld, false, exportPackageDependencies,
|
std::move(cxx_modules_directory), exportOld, exportPackageDependencies,
|
||||||
helper.Makefile->GetBacktrace()));
|
helper.Makefile->GetBacktrace()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -6,12 +6,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <cm/memory>
|
|
||||||
|
|
||||||
#include "cmCryptoHash.h"
|
#include "cmCryptoHash.h"
|
||||||
#ifndef CMAKE_BOOTSTRAP
|
|
||||||
# include "cmExportInstallAndroidMKGenerator.h"
|
|
||||||
#endif
|
|
||||||
#include "cmExportInstallFileGenerator.h"
|
#include "cmExportInstallFileGenerator.h"
|
||||||
#include "cmExportSet.h"
|
#include "cmExportSet.h"
|
||||||
#include "cmInstallType.h"
|
#include "cmInstallType.h"
|
||||||
@@ -22,29 +17,20 @@
|
|||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
cmInstallExportGenerator::cmInstallExportGenerator(
|
cmInstallExportGenerator::cmInstallExportGenerator(
|
||||||
cmExportSet* exportSet, std::string const& destination,
|
cmExportSet* exportSet, std::string destination, std::string filePermissions,
|
||||||
std::string file_permissions, std::vector<std::string> const& configurations,
|
std::vector<std::string> const& configurations, std::string component,
|
||||||
std::string const& component, MessageLevel message, bool exclude_from_all,
|
MessageLevel message, bool excludeFromAll, std::string filename,
|
||||||
std::string filename, std::string name_space,
|
std::string targetNamespace, std::string cxxModulesDirectory,
|
||||||
std::string cxx_modules_directory, bool exportOld, bool android,
|
cmListFileBacktrace backtrace)
|
||||||
bool exportPackageDependencies, cmListFileBacktrace backtrace)
|
: cmInstallGenerator(std::move(destination), configurations,
|
||||||
: cmInstallGenerator(destination, configurations, component, message,
|
std::move(component), message, excludeFromAll, false,
|
||||||
exclude_from_all, false, std::move(backtrace))
|
std::move(backtrace))
|
||||||
, ExportSet(exportSet)
|
, ExportSet(exportSet)
|
||||||
, FilePermissions(std::move(file_permissions))
|
, FilePermissions(std::move(filePermissions))
|
||||||
, FileName(std::move(filename))
|
, FileName(std::move(filename))
|
||||||
, Namespace(std::move(name_space))
|
, Namespace(std::move(targetNamespace))
|
||||||
, CxxModulesDirectory(std::move(cxx_modules_directory))
|
, CxxModulesDirectory(std::move(cxxModulesDirectory))
|
||||||
, ExportOld(exportOld)
|
|
||||||
, ExportPackageDependencies(exportPackageDependencies)
|
|
||||||
{
|
{
|
||||||
if (android) {
|
|
||||||
#ifndef CMAKE_BOOTSTRAP
|
|
||||||
this->EFGen = cm::make_unique<cmExportInstallAndroidMKGenerator>(this);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
this->EFGen = cm::make_unique<cmExportInstallFileGenerator>(this);
|
|
||||||
}
|
|
||||||
exportSet->AddInstallation(this);
|
exportSet->AddInstallation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +78,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
|
|||||||
// Skip empty sets.
|
// Skip empty sets.
|
||||||
if (this->ExportSet->GetTargetExports().empty()) {
|
if (this->ExportSet->GetTargetExports().empty()) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "INSTALL(EXPORT) given unknown export \""
|
e << "INSTALL(" << this->InstallSubcommand() << ") given unknown export \""
|
||||||
<< this->ExportSet->GetName() << "\"";
|
<< this->ExportSet->GetName() << "\"";
|
||||||
cmSystemTools::Error(e.str());
|
cmSystemTools::Error(e.str());
|
||||||
return;
|
return;
|
||||||
@@ -108,7 +94,6 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
|
|||||||
// Generate the import file for this export set.
|
// Generate the import file for this export set.
|
||||||
this->EFGen->SetExportFile(this->MainImportFile.c_str());
|
this->EFGen->SetExportFile(this->MainImportFile.c_str());
|
||||||
this->EFGen->SetNamespace(this->Namespace);
|
this->EFGen->SetNamespace(this->Namespace);
|
||||||
this->EFGen->SetExportOld(this->ExportOld);
|
|
||||||
if (this->ConfigurationTypes->empty()) {
|
if (this->ConfigurationTypes->empty()) {
|
||||||
if (!this->ConfigurationName.empty()) {
|
if (!this->ConfigurationName.empty()) {
|
||||||
this->EFGen->AddConfiguration(this->ConfigurationName);
|
this->EFGen->AddConfiguration(this->ConfigurationName);
|
||||||
@@ -120,7 +105,6 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
|
|||||||
this->EFGen->AddConfiguration(c);
|
this->EFGen->AddConfiguration(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->EFGen->SetExportPackageDependencies(this->ExportPackageDependencies);
|
|
||||||
this->EFGen->GenerateImportFile();
|
this->EFGen->GenerateImportFile();
|
||||||
|
|
||||||
// Perform the main install script generation.
|
// Perform the main install script generation.
|
||||||
@@ -149,22 +133,18 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
|
|||||||
|
|
||||||
// Now create a configuration-specific install rule for the C++ module import
|
// Now create a configuration-specific install rule for the C++ module import
|
||||||
// property file of each configuration.
|
// property file of each configuration.
|
||||||
auto cxx_module_dest =
|
auto const cxxModuleDestination =
|
||||||
cmStrCat(this->Destination, '/', this->CxxModulesDirectory);
|
cmStrCat(this->Destination, '/', this->CxxModulesDirectory);
|
||||||
std::string config_file_example;
|
auto const cxxModuleInstallFilePath = this->EFGen->GetCxxModuleFile();
|
||||||
for (auto const& i : this->EFGen->GetConfigCxxModuleFiles()) {
|
if (!cxxModuleInstallFilePath.empty()) {
|
||||||
config_file_example = i.second;
|
auto const cxxModuleFilename =
|
||||||
break;
|
cmSystemTools::GetFilenameName(cxxModuleInstallFilePath);
|
||||||
}
|
|
||||||
if (!config_file_example.empty()) {
|
|
||||||
// Remove old per-configuration export files if the main changes.
|
// Remove old per-configuration export files if the main changes.
|
||||||
std::string installedDir = cmStrCat(
|
std::string installedDir =
|
||||||
"$ENV{DESTDIR}", ConvertToAbsoluteDestination(cxx_module_dest), '/');
|
cmStrCat("$ENV{DESTDIR}",
|
||||||
std::string installedFile = cmStrCat(installedDir, "/cxx-modules-",
|
ConvertToAbsoluteDestination(cxxModuleDestination), '/');
|
||||||
this->ExportSet->GetName(), ".cmake");
|
std::string installedFile = cmStrCat(installedDir, cxxModuleFilename);
|
||||||
std::string toInstallFile =
|
|
||||||
cmStrCat(cmSystemTools::GetFilenamePath(config_file_example),
|
|
||||||
"/cxx-modules-", this->ExportSet->GetName(), ".cmake");
|
|
||||||
os << indent << "if(EXISTS \"" << installedFile << "\")\n";
|
os << indent << "if(EXISTS \"" << installedFile << "\")\n";
|
||||||
Indent indentN = indent.Next();
|
Indent indentN = indent.Next();
|
||||||
Indent indentNN = indentN.Next();
|
Indent indentNN = indentN.Next();
|
||||||
@@ -172,7 +152,7 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
|
|||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
os << indentN << "file(DIFFERENT _cmake_export_file_changed FILES\n"
|
os << indentN << "file(DIFFERENT _cmake_export_file_changed FILES\n"
|
||||||
<< indentN << " \"" << installedFile << "\"\n"
|
<< indentN << " \"" << installedFile << "\"\n"
|
||||||
<< indentN << " \"" << toInstallFile << "\")\n";
|
<< indentN << " \"" << cxxModuleInstallFilePath << "\")\n";
|
||||||
os << indentN << "if(_cmake_export_file_changed)\n";
|
os << indentN << "if(_cmake_export_file_changed)\n";
|
||||||
os << indentNN << "file(GLOB _cmake_old_config_files \"" << installedDir
|
os << indentNN << "file(GLOB _cmake_old_config_files \"" << installedDir
|
||||||
<< this->EFGen->GetConfigImportFileGlob() << "\")\n";
|
<< this->EFGen->GetConfigImportFileGlob() << "\")\n";
|
||||||
@@ -191,8 +171,8 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
|
|||||||
|
|
||||||
// All of these files are siblings; get its location to know where the
|
// All of these files are siblings; get its location to know where the
|
||||||
// "anchor" file is.
|
// "anchor" file is.
|
||||||
files.push_back(toInstallFile);
|
files.push_back(cxxModuleInstallFilePath);
|
||||||
this->AddInstallRule(os, cxx_module_dest, cmInstallType_FILES, files,
|
this->AddInstallRule(os, cxxModuleDestination, cmInstallType_FILES, files,
|
||||||
false, this->FilePermissions.c_str(), nullptr,
|
false, this->FilePermissions.c_str(), nullptr,
|
||||||
nullptr, nullptr, indent);
|
nullptr, nullptr, indent);
|
||||||
files.clear();
|
files.clear();
|
||||||
@@ -201,7 +181,7 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
|
|||||||
files.push_back(i.second);
|
files.push_back(i.second);
|
||||||
std::string config_test = this->CreateConfigTest(i.first);
|
std::string config_test = this->CreateConfigTest(i.first);
|
||||||
os << indent << "if(" << config_test << ")\n";
|
os << indent << "if(" << config_test << ")\n";
|
||||||
this->AddInstallRule(os, cxx_module_dest, cmInstallType_FILES, files,
|
this->AddInstallRule(os, cxxModuleDestination, cmInstallType_FILES, files,
|
||||||
false, this->FilePermissions.c_str(), nullptr,
|
false, this->FilePermissions.c_str(), nullptr,
|
||||||
nullptr, nullptr, indent.Next());
|
nullptr, nullptr, indent.Next());
|
||||||
os << indent << "endif()\n";
|
os << indent << "endif()\n";
|
||||||
@@ -210,9 +190,9 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
|
|||||||
for (auto const& i : this->EFGen->GetConfigCxxModuleTargetFiles()) {
|
for (auto const& i : this->EFGen->GetConfigCxxModuleTargetFiles()) {
|
||||||
std::string config_test = this->CreateConfigTest(i.first);
|
std::string config_test = this->CreateConfigTest(i.first);
|
||||||
os << indent << "if(" << config_test << ")\n";
|
os << indent << "if(" << config_test << ")\n";
|
||||||
this->AddInstallRule(os, cxx_module_dest, cmInstallType_FILES, i.second,
|
this->AddInstallRule(os, cxxModuleDestination, cmInstallType_FILES,
|
||||||
false, this->FilePermissions.c_str(), nullptr,
|
i.second, false, this->FilePermissions.c_str(),
|
||||||
nullptr, nullptr, indent.Next());
|
nullptr, nullptr, nullptr, indent.Next());
|
||||||
os << indent << "endif()\n";
|
os << indent << "endif()\n";
|
||||||
files.clear();
|
files.clear();
|
||||||
}
|
}
|
||||||
|
@@ -17,19 +17,18 @@ class cmListFileBacktrace;
|
|||||||
class cmLocalGenerator;
|
class cmLocalGenerator;
|
||||||
|
|
||||||
/** \class cmInstallExportGenerator
|
/** \class cmInstallExportGenerator
|
||||||
* \brief Generate rules for creating an export files.
|
* \brief Support class for generating rules for creating export files.
|
||||||
*/
|
*/
|
||||||
class cmInstallExportGenerator : public cmInstallGenerator
|
class cmInstallExportGenerator : public cmInstallGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmInstallExportGenerator(cmExportSet* exportSet, std::string const& dest,
|
cmInstallExportGenerator(cmExportSet* exportSet, std::string destination,
|
||||||
std::string file_permissions,
|
std::string filePermissions,
|
||||||
const std::vector<std::string>& configurations,
|
std::vector<std::string> const& configurations,
|
||||||
std::string const& component, MessageLevel message,
|
std::string component, MessageLevel message,
|
||||||
bool exclude_from_all, std::string filename,
|
bool excludeFromAll, std::string filename,
|
||||||
std::string name_space,
|
std::string targetNamespace,
|
||||||
std::string cxx_modules_directory, bool exportOld,
|
std::string cxxModulesDirectory,
|
||||||
bool android, bool exportPackageDependencies,
|
|
||||||
cmListFileBacktrace backtrace);
|
cmListFileBacktrace backtrace);
|
||||||
cmInstallExportGenerator(const cmInstallExportGenerator&) = delete;
|
cmInstallExportGenerator(const cmInstallExportGenerator&) = delete;
|
||||||
~cmInstallExportGenerator() override;
|
~cmInstallExportGenerator() override;
|
||||||
@@ -57,11 +56,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual char const* InstallSubcommand() const = 0;
|
||||||
|
|
||||||
void GenerateScript(std::ostream& os) override;
|
void GenerateScript(std::ostream& os) override;
|
||||||
void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
|
void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
|
||||||
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
||||||
void GenerateImportFile(cmExportSet const* exportSet);
|
|
||||||
void GenerateImportFile(const char* config, cmExportSet const* exportSet);
|
|
||||||
std::string TempDirCalculate() const;
|
std::string TempDirCalculate() const;
|
||||||
void ComputeTempDir();
|
void ComputeTempDir();
|
||||||
|
|
||||||
@@ -70,8 +69,6 @@ protected:
|
|||||||
std::string const FileName;
|
std::string const FileName;
|
||||||
std::string const Namespace;
|
std::string const Namespace;
|
||||||
std::string const CxxModulesDirectory;
|
std::string const CxxModulesDirectory;
|
||||||
bool const ExportOld;
|
|
||||||
bool const ExportPackageDependencies;
|
|
||||||
cmLocalGenerator* LocalGenerator = nullptr;
|
cmLocalGenerator* LocalGenerator = nullptr;
|
||||||
|
|
||||||
std::string TempDir;
|
std::string TempDir;
|
||||||
|
@@ -408,6 +408,7 @@ CMAKE_CXX_SOURCES="\
|
|||||||
cmIncludeGuardCommand \
|
cmIncludeGuardCommand \
|
||||||
cmIncludeDirectoryCommand \
|
cmIncludeDirectoryCommand \
|
||||||
cmIncludeRegularExpressionCommand \
|
cmIncludeRegularExpressionCommand \
|
||||||
|
cmInstallCMakeConfigExportGenerator \
|
||||||
cmInstallCommand \
|
cmInstallCommand \
|
||||||
cmInstallCommandArguments \
|
cmInstallCommandArguments \
|
||||||
cmInstallCxxModuleBmiGenerator \
|
cmInstallCxxModuleBmiGenerator \
|
||||||
|
Reference in New Issue
Block a user