diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-04-22 22:12:32 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-07-06 15:37:50 (GMT) |
commit | 9ecd3e771b0dbdbfcfa035f5d2b0383a5b739014 (patch) | |
tree | fbc6e4df42cf8152fd4a2cdc3b7ad6cac8a74e2a /Source/cmGlobalNinjaGenerator.cxx | |
parent | 89f39b6539b264638892937cfe042f8b46ec7d07 (diff) | |
download | CMake-9ecd3e771b0dbdbfcfa035f5d2b0383a5b739014.zip CMake-9ecd3e771b0dbdbfcfa035f5d2b0383a5b739014.tar.gz CMake-9ecd3e771b0dbdbfcfa035f5d2b0383a5b739014.tar.bz2 |
cmGlobalNinjaGenerator: generate install rules for BMI files
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 100 |
1 files changed, 98 insertions, 2 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a2fed17..f55e58f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2494,6 +2494,17 @@ struct CxxModuleFileSet cm::optional<std::string> Destination; }; +struct CxxModuleBmiInstall +{ + std::string Component; + std::string Destination; + bool ExcludeFromAll; + bool Optional; + std::string Permissions; + std::string MessageLevel; + std::string ScriptLocation; +}; + struct CxxModuleExport { std::string Name; @@ -2507,6 +2518,7 @@ struct CxxModuleExport struct cmGlobalNinjaGenerator::CxxModuleExportInfo { std::map<std::string, CxxModuleFileSet> ObjectToFileSet; + cm::optional<CxxModuleBmiInstall> BmiInstallation; std::vector<CxxModuleExport> Exports; std::string Config; }; @@ -2695,6 +2707,12 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( exports.emplace_back(std::move(properties), &exp); } + std::unique_ptr<cmGeneratedFileStream> bmi_install_script; + if (export_info.BmiInstallation) { + bmi_install_script = cm::make_unique<cmGeneratedFileStream>( + export_info.BmiInstallation->ScriptLocation); + } + auto cmEscape = [](cm::string_view str) { return cmOutputConverter::EscapeForCMake( str, cmOutputConverter::WrapQuotes::NoWrap); @@ -2796,11 +2814,24 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( continue; } - // Write out properties for any exports. + // Write out properties and install rules for any exports. for (auto const& p : object.Provides) { + bool bmi_dest_is_abs = false; + std::string bmi_destination; + if (export_info.BmiInstallation) { + auto dest = + install_destination(export_info.BmiInstallation->Destination); + bmi_dest_is_abs = dest.first; + bmi_destination = cmStrCat(dest.second, '/'); + } + + std::string install_bmi_path; std::string build_bmi_path; auto m = mod_files.find(p.LogicalName); if (m != mod_files.end()) { + install_bmi_path = + cmStrCat(bmi_destination, + cmEscape(cmSystemTools::GetFilenameName(m->second))); build_bmi_path = cmEscape(m->second); } @@ -2816,7 +2847,9 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( } std::string bmi_path; - if (!exp.second->Install) { + if (exp.second->Install && export_info.BmiInstallation) { + bmi_path = install_bmi_path; + } else if (!exp.second->Install) { bmi_path = build_bmi_path; } @@ -2833,6 +2866,54 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( } *exp.first << "\"\n"; } + + if (bmi_install_script) { + auto const& bmi_install = *export_info.BmiInstallation; + + *bmi_install_script << "if (CMAKE_INSTALL_COMPONENT STREQUAL \"" + << cmEscape(bmi_install.Component) << '\"'; + if (!bmi_install.ExcludeFromAll) { + *bmi_install_script << " OR NOT CMAKE_INSTALL_COMPONENT"; + } + *bmi_install_script << ")\n"; + *bmi_install_script << " file(INSTALL\n" + " DESTINATION \""; + if (!bmi_dest_is_abs) { + *bmi_install_script << "${CMAKE_INSTALL_PREFIX}/"; + } + *bmi_install_script << cmEscape(bmi_install.Destination) + << "\"\n" + " TYPE FILE\n"; + if (bmi_install.Optional) { + *bmi_install_script << " OPTIONAL\n"; + } + if (!bmi_install.MessageLevel.empty()) { + *bmi_install_script << " " << bmi_install.MessageLevel << "\n"; + } + if (!bmi_install.Permissions.empty()) { + *bmi_install_script << " PERMISSIONS" << bmi_install.Permissions + << "\n"; + } + *bmi_install_script << " FILES \"" << m->second << "\")\n"; + if (bmi_dest_is_abs) { + *bmi_install_script + << " list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n" + " \"" + << cmEscape(cmSystemTools::GetFilenameName(m->second)) + << "\")\n" + " if (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n" + " message(WARNING\n" + " \"ABSOLUTE path INSTALL DESTINATION : " + "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n" + " endif ()\n" + " if (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n" + " message(FATAL_ERROR\n" + " \"ABSOLUTE path INSTALL DESTINATION forbidden (by " + "caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n" + " endif ()\n"; + } + *bmi_install_script << "endif ()\n"; + } } } @@ -2935,6 +3016,21 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, export_info.Exports.push_back(exp); } } + auto const& bmi_installation = tdi["bmi-installation"]; + if (bmi_installation.isObject()) { + CxxModuleBmiInstall bmi_install; + + bmi_install.Component = bmi_installation["component"].asString(); + bmi_install.Destination = bmi_installation["destination"].asString(); + bmi_install.ExcludeFromAll = bmi_installation["exclude-from-all"].asBool(); + bmi_install.Optional = bmi_installation["optional"].asBool(); + bmi_install.Permissions = bmi_installation["permissions"].asString(); + bmi_install.MessageLevel = bmi_installation["message-level"].asString(); + bmi_install.ScriptLocation = + bmi_installation["script-location"].asString(); + + export_info.BmiInstallation = bmi_install; + } Json::Value const& tdi_cxx_modules = tdi["cxx-modules"]; if (tdi_cxx_modules.isObject()) { for (auto i = tdi_cxx_modules.begin(); i != tdi_cxx_modules.end(); ++i) { |