mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-02 04:09:33 -05:00
Merge topic 'dyndep-manifest-support'
ef7533113dcmake-cxxmodule: Document cxx-modules map membersdddd0794c1cmCxxModuleMetadata: Don't serialize default valuesce309f8885cmDyndepCollation: Cxx module manifest format Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com> Merge-request: !11617
This commit is contained in:
@@ -578,6 +578,25 @@ modules. The :term:`collate` step uses a target-specific
|
||||
:term:`collation <collate>` metadata file is describing
|
||||
- ``include-dirs`` and ``forward-modules-from-target-dirs``: unused for C++
|
||||
|
||||
Each entry in the ``cxx-modules`` map records the following:
|
||||
|
||||
- ``bmi-only`` (bool): True if only the BMI, not the source of the BMI, is
|
||||
available
|
||||
- ``compile-features`` (list[string]): :manual:`cmake-compile-features(7)` used
|
||||
to build the object
|
||||
- ``compile-options`` (list[string]): compilation options/flags used to build
|
||||
the object, except for those derived from ``compile-features``
|
||||
- ``definitions`` (list[string]): preprocessor defines used to build the object
|
||||
- ``destination`` (string): intended install destination of the source file
|
||||
- ``include-directories`` (list[string]): include directories used to build the
|
||||
object
|
||||
- ``name`` (string): name of the file set which owns the source file
|
||||
- ``relative-directory`` (string): base path relative to which the source file
|
||||
will be relocated into the install destination
|
||||
- ``source`` (string): path to the source file
|
||||
- ``type`` (string): type of the file set which owns the source file
|
||||
- ``visibility`` (string): visibility of the file set which owns the source file
|
||||
|
||||
For each compilation, CMake will also provide a :term:`module map` which will
|
||||
be created during the build by the :term:`collate` command. How this is
|
||||
provided to the compiler is specified by the ``CMAKE_CXX_MODULE_MAP_FORMAT``
|
||||
|
||||
+110
-33
@@ -16,6 +16,7 @@
|
||||
#include "cmsys/FStream.hxx"
|
||||
|
||||
#include "cmFileSet.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmJSONState.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -69,8 +70,39 @@ bool ParsePreprocessorDefine(Json::Value& dval,
|
||||
out.Undef = dval["undef"].asBool();
|
||||
}
|
||||
|
||||
if (dval.isMember("vendor")) {
|
||||
out.Vendor = std::move(dval["vendor"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseCMakeLocalArgumentsVendor(
|
||||
Json::Value& cmlav, cmCxxModuleMetadata::LocalArgumentsData& out,
|
||||
cmJSONState* state)
|
||||
{
|
||||
|
||||
if (!cmlav.isObject()) {
|
||||
state->AddErrorAtValue("'vendor' must be an object", &cmlav);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cmlav.isMember("compile-options")) {
|
||||
if (!JsonIsStringArray(cmlav["compile-options"])) {
|
||||
state->AddErrorAtValue("'compile-options' must be an array of strings",
|
||||
&cmlav["compile-options"]);
|
||||
return false;
|
||||
}
|
||||
for (auto const& s : cmlav["compile-options"]) {
|
||||
out.CompileOptions.push_back(s.asString());
|
||||
}
|
||||
}
|
||||
|
||||
if (cmlav.isMember("compile-features")) {
|
||||
if (!JsonIsStringArray(cmlav["compile-features"])) {
|
||||
state->AddErrorAtValue("'compile-features' must be an array of strings",
|
||||
&cmlav["compile-features"]);
|
||||
return false;
|
||||
}
|
||||
for (auto const& s : cmlav["compile-features"]) {
|
||||
out.CompileFeatures.push_back(s.asString());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -124,7 +156,9 @@ bool ParseLocalArguments(Json::Value& lav,
|
||||
}
|
||||
|
||||
if (lav.isMember("vendor")) {
|
||||
out.Vendor = std::move(lav["vendor"]);
|
||||
if (!ParseCMakeLocalArgumentsVendor(lav["vendor"], out, state)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -186,10 +220,6 @@ bool ParseModule(Json::Value& mval, cmCxxModuleMetadata::ModuleData& mod,
|
||||
}
|
||||
}
|
||||
|
||||
if (mval.isMember("vendor")) {
|
||||
mod.Vendor = std::move(mval["vendor"]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -212,6 +242,14 @@ bool ParseRoot(Json::Value& root, cmCxxModuleMetadata& meta,
|
||||
meta.Revision = root["revision"].asInt();
|
||||
}
|
||||
|
||||
if (meta.Version != 1) {
|
||||
state->AddErrorAtValue(cmStrCat("Module manifest version number, '",
|
||||
meta.Version, '.', meta.Revision,
|
||||
"' is newer than max supported (1.1)"),
|
||||
&root);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (root.isMember("modules")) {
|
||||
if (!root["modules"].isArray()) {
|
||||
state->AddErrorAtValue("'modules' must be an array", &root["modules"]);
|
||||
@@ -225,13 +263,6 @@ bool ParseRoot(Json::Value& root, cmCxxModuleMetadata& meta,
|
||||
}
|
||||
}
|
||||
|
||||
for (std::string& key : root.getMemberNames()) {
|
||||
if (key == "version" || key == "revision" || key == "modules") {
|
||||
continue;
|
||||
}
|
||||
meta.Extensions.emplace(std::move(key), std::move(root[key]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -269,16 +300,35 @@ Json::Value SerializePreprocessorDefine(
|
||||
dv["name"] = d.Name;
|
||||
if (d.Value) {
|
||||
dv["value"] = *d.Value;
|
||||
} else {
|
||||
dv["value"] = Json::Value::null;
|
||||
}
|
||||
dv["undef"] = d.Undef;
|
||||
if (d.Vendor) {
|
||||
dv["vendor"] = *d.Vendor;
|
||||
if (d.Undef) {
|
||||
dv["undef"] = d.Undef;
|
||||
}
|
||||
return dv;
|
||||
}
|
||||
|
||||
Json::Value SerializeCMakeLocalArgumentsVendor(
|
||||
cmCxxModuleMetadata::LocalArgumentsData const& la)
|
||||
{
|
||||
Json::Value vend(Json::objectValue);
|
||||
|
||||
if (!la.CompileOptions.empty()) {
|
||||
Json::Value& opts = vend["compile-options"] = Json::arrayValue;
|
||||
for (auto const& s : la.CompileOptions) {
|
||||
opts.append(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (!la.CompileFeatures.empty()) {
|
||||
Json::Value& feats = vend["compile-features"] = Json::arrayValue;
|
||||
for (auto const& s : la.CompileFeatures) {
|
||||
feats.append(s);
|
||||
}
|
||||
}
|
||||
|
||||
return vend;
|
||||
}
|
||||
|
||||
Json::Value SerializeLocalArguments(
|
||||
cmCxxModuleMetadata::LocalArgumentsData const& la)
|
||||
{
|
||||
@@ -305,18 +355,26 @@ Json::Value SerializeLocalArguments(
|
||||
}
|
||||
}
|
||||
|
||||
if (la.Vendor) {
|
||||
lav["vendor"] = *la.Vendor;
|
||||
Json::Value vend = SerializeCMakeLocalArgumentsVendor(la);
|
||||
if (!vend.empty()) {
|
||||
Json::Value& cmvend = lav["vendor"] = Json::objectValue;
|
||||
cmvend["cmake"] = std::move(vend);
|
||||
}
|
||||
|
||||
return lav;
|
||||
}
|
||||
|
||||
Json::Value SerializeModule(cmCxxModuleMetadata::ModuleData const& m)
|
||||
Json::Value SerializeModule(std::string& manifestRoot,
|
||||
cmCxxModuleMetadata::ModuleData const& m)
|
||||
{
|
||||
Json::Value mv(Json::objectValue);
|
||||
mv["logical-name"] = m.LogicalName;
|
||||
mv["source-path"] = m.SourcePath;
|
||||
if (cmSystemTools::FileIsFullPath(m.SourcePath)) {
|
||||
mv["source-path"] = m.SourcePath;
|
||||
} else {
|
||||
mv["source-path"] = cmSystemTools::ForceToRelativePath(
|
||||
manifestRoot, cmStrCat('/', m.SourcePath));
|
||||
}
|
||||
mv["is-interface"] = m.IsInterface;
|
||||
mv["is-std-library"] = m.IsStdLibrary;
|
||||
|
||||
@@ -324,10 +382,6 @@ Json::Value SerializeModule(cmCxxModuleMetadata::ModuleData const& m)
|
||||
mv["local-arguments"] = SerializeLocalArguments(*m.LocalArguments);
|
||||
}
|
||||
|
||||
if (m.Vendor) {
|
||||
mv["vendor"] = *m.Vendor;
|
||||
}
|
||||
|
||||
return mv;
|
||||
}
|
||||
|
||||
@@ -341,12 +395,15 @@ Json::Value cmCxxModuleMetadata::ToJsonValue(cmCxxModuleMetadata const& meta)
|
||||
root["revision"] = meta.Revision;
|
||||
|
||||
Json::Value& modules = root["modules"] = Json::arrayValue;
|
||||
for (auto const& m : meta.Modules) {
|
||||
modules.append(SerializeModule(m));
|
||||
std::string manifestRoot =
|
||||
cmSystemTools::GetFilenamePath(meta.MetadataFilePath);
|
||||
|
||||
if (!cmSystemTools::FileIsFullPath(meta.MetadataFilePath)) {
|
||||
manifestRoot = cmStrCat('/', manifestRoot);
|
||||
}
|
||||
|
||||
for (auto const& kv : meta.Extensions) {
|
||||
root[kv.first] = kv.second;
|
||||
for (auto const& m : meta.Modules) {
|
||||
modules.append(SerializeModule(manifestRoot, m));
|
||||
}
|
||||
|
||||
return root;
|
||||
@@ -357,9 +414,9 @@ cmCxxModuleMetadata::SaveResult cmCxxModuleMetadata::SaveToFile(
|
||||
{
|
||||
SaveResult st;
|
||||
|
||||
cmsys::ofstream ofs(path.c_str());
|
||||
cmGeneratedFileStream ofs(path);
|
||||
if (!ofs.is_open()) {
|
||||
st.Error = cmStrCat("Unable to open file for writing: "_s, path);
|
||||
st.Error = "Unable to open temp file for writing";
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -367,6 +424,8 @@ cmCxxModuleMetadata::SaveResult cmCxxModuleMetadata::SaveToFile(
|
||||
wbuilder["indentation"] = " ";
|
||||
ofs << Json::writeString(wbuilder, ToJsonValue(meta));
|
||||
|
||||
ofs.Close();
|
||||
|
||||
if (!ofs.good()) {
|
||||
st.Error = cmStrCat("Write failed for file: "_s, path);
|
||||
return st;
|
||||
@@ -381,6 +440,8 @@ void cmCxxModuleMetadata::PopulateTarget(
|
||||
std::vector<std::string> const& configs)
|
||||
{
|
||||
std::vector<cm::string_view> allIncludeDirectories;
|
||||
std::vector<cm::string_view> allCompileOptions;
|
||||
std::vector<cm::string_view> allCompileFeatures;
|
||||
std::vector<std::string> allCompileDefinitions;
|
||||
std::set<std::string> baseDirs;
|
||||
|
||||
@@ -410,6 +471,12 @@ void cmCxxModuleMetadata::PopulateTarget(
|
||||
module.LocalArguments->SystemIncludeDirectories) {
|
||||
allIncludeDirectories.push_back(sysIncDir);
|
||||
}
|
||||
for (auto const& opt : module.LocalArguments->CompileOptions) {
|
||||
allCompileOptions.push_back(opt);
|
||||
}
|
||||
for (auto const& opt : module.LocalArguments->CompileFeatures) {
|
||||
allCompileFeatures.push_back(opt);
|
||||
}
|
||||
|
||||
for (auto const& def : module.LocalArguments->Definitions) {
|
||||
if (!def.Undef) {
|
||||
@@ -438,6 +505,16 @@ void cmCxxModuleMetadata::PopulateTarget(
|
||||
cmJoin(allCompileDefinitions, ";"));
|
||||
}
|
||||
|
||||
if (!allCompileOptions.empty()) {
|
||||
target.SetProperty("IMPORTED_CXX_MODULES_COMPILE_OPTIONS",
|
||||
cmJoin(allCompileOptions, ";"));
|
||||
}
|
||||
|
||||
if (!allCompileFeatures.empty()) {
|
||||
target.SetProperty("IMPORTED_CXX_MODULES_COMPILE_FEATURES",
|
||||
cmJoin(allCompileFeatures, ";"));
|
||||
}
|
||||
|
||||
for (auto const& config : configs) {
|
||||
std::vector<std::string> moduleList;
|
||||
for (auto const& module : meta.Modules) {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
@@ -18,36 +17,54 @@ class cmCxxModuleMetadata
|
||||
public:
|
||||
struct PreprocessorDefineData
|
||||
{
|
||||
// definition["name"]
|
||||
std::string Name;
|
||||
// definition["value"]
|
||||
cm::optional<std::string> Value;
|
||||
// definition["undef"]
|
||||
bool Undef = false;
|
||||
cm::optional<Json::Value> Vendor;
|
||||
};
|
||||
|
||||
struct LocalArgumentsData
|
||||
{
|
||||
// local-arguments["include-directories"]
|
||||
std::vector<std::string> IncludeDirectories;
|
||||
// local-arguments["system-include-directories"]
|
||||
std::vector<std::string> SystemIncludeDirectories;
|
||||
// local-arguments["definitions"]
|
||||
std::vector<PreprocessorDefineData> Definitions;
|
||||
cm::optional<Json::Value> Vendor;
|
||||
|
||||
// These are CMake vendor extensions
|
||||
// local-arguments["vendor"]["cmake"]["compile-options"]
|
||||
std::vector<std::string> CompileOptions;
|
||||
// local-arguments["vendor"]["cmake"]["compile-features"]
|
||||
std::vector<std::string> CompileFeatures;
|
||||
};
|
||||
|
||||
struct ModuleData
|
||||
{
|
||||
// module["logical-name"]
|
||||
std::string LogicalName;
|
||||
// module["source-path"]
|
||||
std::string SourcePath;
|
||||
// module["is-interface"]
|
||||
bool IsInterface = true;
|
||||
// module["is-std-library"]
|
||||
bool IsStdLibrary = false;
|
||||
// module["local-arguments"]
|
||||
cm::optional<LocalArgumentsData> LocalArguments;
|
||||
cm::optional<Json::Value> Vendor;
|
||||
};
|
||||
|
||||
int Version = 0;
|
||||
int Revision = 0;
|
||||
// root["version"]
|
||||
int Version = 1;
|
||||
// root["revision"]
|
||||
int Revision = 1;
|
||||
// root["modules"]
|
||||
std::vector<ModuleData> Modules;
|
||||
std::string MetadataFilePath;
|
||||
|
||||
std::unordered_map<std::string, Json::Value> Extensions;
|
||||
// The path to the manifest file, either absolute or relative to the
|
||||
// installation root
|
||||
std::string MetadataFilePath;
|
||||
|
||||
struct ParseResult;
|
||||
|
||||
|
||||
+122
-24
@@ -17,6 +17,7 @@
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
#include "cmBuildDatabase.h"
|
||||
#include "cmCxxModuleMetadata.h"
|
||||
#include "cmExportBuildFileGenerator.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmFileSet.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "cmInstallExportGenerator.h"
|
||||
#include "cmInstallFileSetGenerator.h"
|
||||
#include "cmInstallGenerator.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmOutputConverter.h"
|
||||
@@ -175,6 +177,30 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt,
|
||||
Json::Value& tdi_module_info = tdi_cxx_module_info[obj_path] =
|
||||
Json::objectValue;
|
||||
|
||||
Json::Value& tdi_include_dirs =
|
||||
tdi_module_info["include-directories"] = Json::arrayValue;
|
||||
for (auto const& i : gt->GetIncludeDirectories(config, "CXX")) {
|
||||
tdi_include_dirs.append(i.Value);
|
||||
}
|
||||
|
||||
Json::Value& tdi_defs = tdi_module_info["definitions"] =
|
||||
Json::arrayValue;
|
||||
for (auto const& i : gt->GetCompileDefinitions(config, "CXX")) {
|
||||
tdi_defs.append(i.Value);
|
||||
}
|
||||
|
||||
Json::Value& tdi_opts = tdi_module_info["compile-options"] =
|
||||
Json::arrayValue;
|
||||
for (auto const& i : gt->GetCompileOptions(config, "CXX")) {
|
||||
tdi_opts.append(i.Value);
|
||||
}
|
||||
|
||||
Json::Value& tdi_feats = tdi_module_info["compile-features"] =
|
||||
Json::arrayValue;
|
||||
for (auto const& i : gt->GetCompileFeatures(config)) {
|
||||
tdi_feats.append(i.Value);
|
||||
}
|
||||
|
||||
tdi_module_info["source"] = full_file;
|
||||
tdi_module_info["bmi-only"] = ct == CompileType::BmiOnly;
|
||||
tdi_module_info["relative-directory"] = files_per_dir.first;
|
||||
@@ -343,6 +369,28 @@ Json::Value CollationInformationExports(cmGeneratorTarget const* gt)
|
||||
|
||||
return tdi_exports;
|
||||
}
|
||||
|
||||
std::vector<cmCxxModuleMetadata::PreprocessorDefineData>
|
||||
MakePreprocessorDefines(std::vector<std::string> const& defines)
|
||||
{
|
||||
std::vector<cmCxxModuleMetadata::PreprocessorDefineData> result;
|
||||
result.reserve(defines.size());
|
||||
|
||||
for (auto const& def : defines) {
|
||||
cmCxxModuleMetadata::PreprocessorDefineData data;
|
||||
auto offset = def.find('=');
|
||||
if (offset == def.npos) {
|
||||
data.Name = def;
|
||||
} else {
|
||||
data.Name = def.substr(0, offset);
|
||||
data.Value = def.substr(offset);
|
||||
}
|
||||
result.emplace_back(std::move(data));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cmDyndepCollation::AddCollationInformation(
|
||||
@@ -373,6 +421,10 @@ struct CxxModuleFileSet
|
||||
std::string Type;
|
||||
cmFileSetVisibility Visibility = cmFileSetVisibility::Private;
|
||||
cm::optional<std::string> Destination;
|
||||
std::vector<std::string> IncludeDirectories;
|
||||
std::vector<std::string> Definitions;
|
||||
std::vector<std::string> CompileOptions;
|
||||
std::vector<std::string> CompileFeatures;
|
||||
};
|
||||
|
||||
struct CxxModuleDatabaseInfo
|
||||
@@ -403,6 +455,13 @@ struct CxxModuleExport
|
||||
bool Install;
|
||||
};
|
||||
|
||||
struct CxxModuleExportOutputHelper
|
||||
{
|
||||
CxxModuleExport const* Export;
|
||||
std::unique_ptr<cmGeneratedFileStream> File;
|
||||
cmCxxModuleMetadata Manifest;
|
||||
};
|
||||
|
||||
struct cmCxxModuleExportInfo
|
||||
{
|
||||
std::map<std::string, SourceInfo> ObjectToSource;
|
||||
@@ -489,6 +548,18 @@ cmDyndepCollation::ParseExportInfo(Json::Value const& tdi)
|
||||
if (tdi_fs_dest.isString()) {
|
||||
fsi.Destination = tdi_fs_dest.asString();
|
||||
}
|
||||
for (auto const& j : tdi_cxx_module_info["include-directories"]) {
|
||||
fsi.IncludeDirectories.push_back(j.asString());
|
||||
}
|
||||
for (auto const& j : tdi_cxx_module_info["definitions"]) {
|
||||
fsi.Definitions.push_back(j.asString());
|
||||
}
|
||||
for (auto const& j : tdi_cxx_module_info["compile-options"]) {
|
||||
fsi.CompileOptions.push_back(j.asString());
|
||||
}
|
||||
for (auto const& j : tdi_cxx_module_info["compile-features"]) {
|
||||
fsi.CompileFeatures.push_back(j.asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Json::Value const& tdi_sources = tdi["sources"];
|
||||
@@ -520,25 +591,30 @@ bool cmDyndepCollation::WriteDyndepMetadata(
|
||||
// Prepare the export information blocks.
|
||||
std::string const config_upper =
|
||||
cmSystemTools::UpperCase(export_info.Config);
|
||||
std::vector<
|
||||
std::pair<std::unique_ptr<cmGeneratedFileStream>, CxxModuleExport const*>>
|
||||
exports;
|
||||
std::vector<CxxModuleExportOutputHelper> exports;
|
||||
for (auto const& exp : export_info.Exports) {
|
||||
std::unique_ptr<cmGeneratedFileStream> properties;
|
||||
CxxModuleExportOutputHelper exp_helper;
|
||||
|
||||
std::string const export_dir =
|
||||
cmStrCat(exp.Prefix, '/', exp.CxxModuleInfoDir, '/');
|
||||
std::string const property_file_path =
|
||||
cmStrCat(export_dir, "target-", exp.FilesystemName, '-',
|
||||
export_info.Config, ".cmake");
|
||||
properties = cm::make_unique<cmGeneratedFileStream>(property_file_path);
|
||||
cmStrCat(export_dir, "target-"_s, exp.FilesystemName, '-',
|
||||
export_info.Config, ".cmake"_s);
|
||||
exp_helper.Manifest.MetadataFilePath =
|
||||
cmStrCat(exp.Destination, '/', exp.CxxModuleInfoDir, "/target-"_s,
|
||||
exp.FilesystemName, '-', export_info.Config, ".modules.json"_s);
|
||||
|
||||
exp_helper.File =
|
||||
cm::make_unique<cmGeneratedFileStream>(property_file_path);
|
||||
|
||||
// Set up the preamble.
|
||||
*properties << "set_property(TARGET \"" << exp.Namespace << exp.Name
|
||||
<< "\"\n"
|
||||
<< " PROPERTY IMPORTED_CXX_MODULES_" << config_upper << '\n';
|
||||
*exp_helper.File << "set_property(TARGET \"" << exp.Namespace << exp.Name
|
||||
<< "\"\n"
|
||||
" PROPERTY IMPORTED_CXX_MODULES_"
|
||||
<< config_upper << '\n';
|
||||
|
||||
exports.emplace_back(std::move(properties), &exp);
|
||||
exp_helper.Export = &exp;
|
||||
exports.emplace_back(std::move(exp_helper));
|
||||
}
|
||||
|
||||
std::unique_ptr<cmBuildDatabase> module_database;
|
||||
@@ -718,21 +794,26 @@ bool cmDyndepCollation::WriteDyndepMetadata(
|
||||
build_bmi_path = cmEscape(*m);
|
||||
}
|
||||
|
||||
for (auto const& exp : exports) {
|
||||
for (auto& exp : exports) {
|
||||
std::string iface_source;
|
||||
if (exp.second->Install && file_set.Destination) {
|
||||
auto dest = install_destination(*file_set.Destination);
|
||||
cmCxxModuleMetadata::ModuleData mod;
|
||||
|
||||
if (exp.Export->Install && file_set.Destination) {
|
||||
auto rel =
|
||||
cmStrCat('/', file_set.RelativeDirectory,
|
||||
cmSystemTools::GetFilenameName(file_set.SourcePath));
|
||||
iface_source = cmStrCat(
|
||||
dest.second, '/', cmEscape(file_set.RelativeDirectory),
|
||||
cmEscape(cmSystemTools::GetFilenameName(file_set.SourcePath)));
|
||||
install_destination(*file_set.Destination).second, cmEscape(rel));
|
||||
mod.SourcePath = cmStrCat(*file_set.Destination, rel);
|
||||
} else {
|
||||
iface_source = cmEscape(file_set.SourcePath);
|
||||
mod.SourcePath = file_set.SourcePath;
|
||||
}
|
||||
|
||||
std::string bmi_path;
|
||||
if (exp.second->Install && export_info.BmiInstallation) {
|
||||
if (exp.Export->Install && export_info.BmiInstallation) {
|
||||
bmi_path = install_bmi_path;
|
||||
} else if (!exp.second->Install) {
|
||||
} else if (!exp.Export->Install) {
|
||||
bmi_path = build_bmi_path;
|
||||
}
|
||||
|
||||
@@ -742,12 +823,23 @@ bool cmDyndepCollation::WriteDyndepMetadata(
|
||||
continue;
|
||||
}
|
||||
|
||||
*exp.first << " \"" << cmEscape(p.LogicalName) << '='
|
||||
<< iface_source;
|
||||
mod.LogicalName = p.LogicalName;
|
||||
mod.IsInterface = p.IsInterface;
|
||||
|
||||
auto& local_args = mod.LocalArguments.emplace();
|
||||
local_args.Definitions = MakePreprocessorDefines(file_set.Definitions);
|
||||
local_args.IncludeDirectories = file_set.IncludeDirectories;
|
||||
local_args.CompileOptions = file_set.CompileOptions;
|
||||
local_args.CompileFeatures = file_set.CompileFeatures;
|
||||
|
||||
exp.Manifest.Modules.emplace_back(std::move(mod));
|
||||
|
||||
*exp.File << " \"" << cmEscape(p.LogicalName) << '='
|
||||
<< iface_source;
|
||||
if (!bmi_path.empty()) {
|
||||
*exp.first << ',' << bmi_path;
|
||||
*exp.File << ',' << bmi_path;
|
||||
}
|
||||
*exp.first << "\"\n";
|
||||
*exp.File << "\"\n";
|
||||
}
|
||||
|
||||
if (bmi_install_script) {
|
||||
@@ -800,9 +892,15 @@ bool cmDyndepCollation::WriteDyndepMetadata(
|
||||
}
|
||||
}
|
||||
|
||||
// Add trailing parenthesis for the `set_property` call.
|
||||
for (auto const& exp : exports) {
|
||||
*exp.first << ")\n";
|
||||
|
||||
cmCxxModuleMetadata::SaveToFile(
|
||||
cmStrCat(exp.Export->Prefix, '/', exp.Export->CxxModuleInfoDir,
|
||||
"/target-"_s, exp.Export->FilesystemName, '-',
|
||||
export_info.Config, ".modules.json"_s),
|
||||
exp.Manifest);
|
||||
|
||||
*exp.File << ")\n";
|
||||
}
|
||||
|
||||
// Check that public sources only require public modules.
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -21,7 +25,11 @@
|
||||
},
|
||||
"CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -30,7 +38,11 @@
|
||||
},
|
||||
"CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx/internals",
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -21,7 +25,11 @@
|
||||
},
|
||||
"CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -30,7 +38,11 @@
|
||||
},
|
||||
"CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-compiledb-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-compiledb-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-compiledb-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-compiledb-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-compiledb-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-compiledb-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx/internals",
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx/internals",
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PRIVATE"
|
||||
},
|
||||
"CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"destination": null,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination" : null,
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
"config": "<CONFIG>",
|
||||
"cxx-modules": {
|
||||
"CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx/internals",
|
||||
"include-directories" : [],
|
||||
"name": "internal_partitions",
|
||||
"relative-directory": "sources",
|
||||
"source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
|
||||
@@ -15,8 +19,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module-part.cxx",
|
||||
@@ -24,8 +32,12 @@
|
||||
"visibility": "PUBLIC"
|
||||
},
|
||||
"CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": {
|
||||
"bmi-only": false,
|
||||
"bmi-only" : false,
|
||||
"compile-features" : ["cxx_std_20"],
|
||||
"compile-options" : [],
|
||||
"definitions" : [],
|
||||
"destination": "lib/cxx",
|
||||
"include-directories" : [],
|
||||
"name": "modules",
|
||||
"relative-directory": "",
|
||||
"source": "<SOURCE_DIR>/sources/module.cxx",
|
||||
|
||||
Reference in New Issue
Block a user