1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
#include <cm/string_view>
#include "cmExportFileGenerator.h"
#include "cmFindPackageStack.h"
#include "cmStateTypes.h"
namespace Json {
class Value;
}
class cmGeneratorTarget;
class cmPackageInfoArguments;
/** \class cmExportPackageInfoGenerator
* \brief Generate Common Package Specification package information files
* exporting targets from a build or install tree.
*
* cmExportPackageInfoGenerator is the superclass for
* cmExportBuildPackageInfoGenerator and cmExportInstallPackageInfoGenerator.
* It contains common code generation routines for the two kinds of export
* implementations.
*/
class cmExportPackageInfoGenerator : virtual public cmExportFileGenerator
{
public:
cmExportPackageInfoGenerator(cmPackageInfoArguments arguments);
using cmExportFileGenerator::GenerateImportFile;
protected:
std::string const& GetPackageName() const { return this->PackageName; }
void WritePackageInfo(Json::Value const& packageInfo,
std::ostream& os) const;
// Methods to implement export file code generation.
bool GenerateImportFile(std::ostream& os) override;
bool CheckPackage() const
{
return this->CheckVersion() && this->CheckDefaultTargets();
}
Json::Value GeneratePackageInfo() const;
Json::Value* GenerateImportTarget(Json::Value& components,
cmGeneratorTarget const* target,
cmStateEnums::TargetType targetType) const;
void GeneratePackageRequires(Json::Value& package) const;
using ImportPropertyMap = std::map<std::string, std::string>;
bool GenerateInterfaceProperties(Json::Value& component,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties) const;
Json::Value GenerateInterfaceConfigProperties(
std::string const& suffix, ImportPropertyMap const& properties) const;
cm::string_view GetImportPrefixWithSlash() const override;
std::string GetCxxModuleFile(std::string const& /*name*/) const override
{
// CPS does not have a general CxxModuleFile, we use the config-specific
// manifests directly
return {};
}
void GenerateCxxModuleConfigInformation(std::string const& /*name*/,
std::ostream& /*os*/) const override
{
// We embed this directly in the CPS json
}
std::string GenerateCxxModules(Json::Value& component,
cmGeneratorTarget* target,
std::string const& packagePath,
std::string const& config);
bool NoteLinkedTarget(cmGeneratorTarget const* target,
std::string const& linkedName,
cmGeneratorTarget const* linkedTarget) override;
private:
bool CheckVersion() const;
bool CheckDefaultTargets() const;
std::vector<std::string> ExtractRequirements(
std::vector<std::string> const& names, bool& result,
std::vector<std::string>& libraryPaths) const;
void GenerateInterfaceLinkProperties(
bool& result, Json::Value& component, cmGeneratorTarget const* target,
ImportPropertyMap const& properties) const;
void GenerateInterfaceCompileFeatures(
bool& result, Json::Value& component, cmGeneratorTarget const* target,
ImportPropertyMap const& properties) const;
void GenerateInterfaceCompileDefines(
bool& result, Json::Value& component, cmGeneratorTarget const* target,
ImportPropertyMap const& properties) const;
void GenerateInterfaceListProperty(
bool& result, Json::Value& component, cmGeneratorTarget const* target,
std::string const& outName, cm::string_view inName,
ImportPropertyMap const& properties) const;
void GenerateProperty(bool& result, Json::Value& component,
cmGeneratorTarget const* target,
std::string const& outName, std::string const& inName,
ImportPropertyMap const& properties) const;
std::string const PackageName;
std::string const PackageVersion;
std::string const PackageVersionCompat;
std::string const PackageVersionSchema;
std::string const PackageDescription;
std::string const PackageWebsite;
std::string const PackageLicense;
std::string const DefaultLicense;
std::vector<std::string> DefaultTargets;
std::vector<std::string> DefaultConfigurations;
std::map<std::string, std::string> LinkTargets;
std::map<std::string, cmPackageInformation> Requirements;
};
|