1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00
Files
CMake/Source/cmGeneratorExpressionEvaluationFile.h
Brad King deb7b4b658 file(GENERATE): Record CMP0189 at each call site
Policy CMP0189, introduced by commit b3da9c6d60 (GenEx: Evaluate
LINK_LIBRARIES target properties transitively, 2025-02-24,
v4.1.0-rc1~731^2), takes effect at generation time, and so uses the
policy value as of the end of each directory.  However, some projects
may rely on `file(GENERATE)` with the policy's OLD behavior in order
to extract targets' *direct* dependencies from `LINK_LIBRARIES`.
Pending a first-class solution to that problem, make it easier for
projects to port to the policy's NEW behavior in general while
retaining the OLD behavior in an isolated context.

Fixes: #27220
2025-09-23 11:30:22 -04:00

71 lines
2.1 KiB
C++

/* 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 <map>
#include <memory>
#include <string>
#include <vector>
#include "cm_sys_stat.h"
#include "cmGeneratorExpression.h"
#include "cmPolicies.h"
namespace cm {
namespace GenEx {
struct Context;
}
}
class cmGeneratorTarget;
class cmLocalGenerator;
class cmGeneratorExpressionEvaluationFile
{
public:
cmGeneratorExpressionEvaluationFile(
std::string input, std::string target,
std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
bool inputIsContent, std::string newLineCharacter, mode_t permissions,
cmPolicies::PolicyStatus policyStatusCMP0070,
cmPolicies::PolicyStatus policyStatusCMP0189);
void Generate(cmLocalGenerator* lg);
std::vector<std::string> GetFiles() const { return this->Files; }
void CreateOutputFile(cmLocalGenerator* lg, std::string const& config);
private:
void Generate(cmLocalGenerator* lg, std::string const& config,
std::string const& lang,
cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string>& outputFiles, mode_t perm);
std::string GetInputFileName(cmLocalGenerator const* lg);
std::string GetOutputFileName(cm::GenEx::Context const& context,
cmGeneratorTarget* target);
enum PathRole
{
PathForInput,
PathForOutput
};
std::string FixRelativePath(std::string const& filePath, PathRole role,
cmLocalGenerator const* lg);
std::string const Input;
std::string const Target;
std::unique_ptr<cmCompiledGeneratorExpression> const OutputFileExpr;
std::unique_ptr<cmCompiledGeneratorExpression> const Condition;
std::vector<std::string> Files;
bool const InputIsContent;
std::string const NewLineCharacter;
cmPolicies::PolicyStatus PolicyStatusCMP0070;
cmPolicies::PolicyStatus PolicyStatusCMP0189;
mode_t Permissions;
};