mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
Add `install_prep/<component>` convenience targets to the Ninja
generators to build dependencies of install components, and
`install_prep/all` to build the dependencies of all install components.
This is similar in flavor to commit ba6b6fbc24 (Ninja: Add Build
Dependencies for Tests, 2026-04-07), but here for the install command.
Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
Issue: #27643
86 lines
2.7 KiB
C++
86 lines
2.7 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmInstallCxxModuleBmiGenerator.h"
|
|
|
|
#include <ostream>
|
|
#include <utility>
|
|
|
|
#include "cmDiagnosticContext.h"
|
|
#include "cmGeneratorExpression.h"
|
|
#include "cmGeneratorTarget.h"
|
|
#include "cmGlobalGenerator.h"
|
|
#include "cmLocalGenerator.h"
|
|
#include "cmScriptGenerator.h"
|
|
#include "cmStringAlgorithms.h"
|
|
|
|
cmInstallCxxModuleBmiGenerator::cmInstallCxxModuleBmiGenerator(
|
|
std::string target, std::string const& dest, std::string filePermissions,
|
|
std::vector<std::string> const& configurations, std::string const& component,
|
|
MessageLevel message, bool excludeFromAll, bool optional,
|
|
cmDiagnosticContext context)
|
|
: cmInstallGenerator(dest, configurations, component, message,
|
|
excludeFromAll, false, std::move(context))
|
|
, TargetName(std::move(target))
|
|
, FilePermissions(std::move(filePermissions))
|
|
, Optional(optional)
|
|
{
|
|
this->ActionsPerConfig = true;
|
|
}
|
|
|
|
cmInstallCxxModuleBmiGenerator::~cmInstallCxxModuleBmiGenerator() = default;
|
|
|
|
bool cmInstallCxxModuleBmiGenerator::Compute(cmLocalGenerator* lg)
|
|
{
|
|
this->LocalGenerator = lg;
|
|
|
|
this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
|
|
if (!this->Target) {
|
|
// If no local target has been found, find it in the global scope.
|
|
this->Target =
|
|
lg->GetGlobalGenerator()->FindGeneratorTarget(this->TargetName);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void cmInstallCxxModuleBmiGenerator::GetInstallBuildDependencies(
|
|
std::string const& config, std::vector<BuildDependency>& dependencies) const
|
|
{
|
|
if (this->Target && this->Target->HaveInterfaceCxx20ModuleSources() &&
|
|
!this->GetDestination(config).empty()) {
|
|
dependencies.push_back({ this->Target, BuildDependencyType::Normal });
|
|
}
|
|
}
|
|
|
|
std::string cmInstallCxxModuleBmiGenerator::GetScriptLocation(
|
|
std::string const& config) const
|
|
{
|
|
char const* configName = config.c_str();
|
|
if (config.empty()) {
|
|
configName = "noconfig";
|
|
}
|
|
|
|
return cmStrCat(this->Target->GetCMFSupportDirectory(),
|
|
"/install-cxx-module-bmi-", configName, ".cmake");
|
|
}
|
|
|
|
std::string cmInstallCxxModuleBmiGenerator::GetDestination(
|
|
std::string const& config) const
|
|
{
|
|
std::string dest = cmGeneratorExpression::Evaluate(
|
|
this->Destination, this->LocalGenerator, config);
|
|
this->CheckAbsoluteDestination(dest, this->LocalGenerator);
|
|
return dest;
|
|
}
|
|
|
|
void cmInstallCxxModuleBmiGenerator::GenerateScriptForConfig(
|
|
std::ostream& os, std::string const& config, Indent indent)
|
|
{
|
|
auto const& loc = this->GetScriptLocation(config);
|
|
if (loc.empty()) {
|
|
return;
|
|
}
|
|
os << indent << "include(" << cmScriptGenerator::Quote(loc)
|
|
<< " OPTIONAL)\n";
|
|
}
|