file(GENERATE): Add policy CMP0070 to define relative path behavior

Previously `file(GENERATE)` did not define any behavior for relative
paths given to the `OUTPUT` or `INPUT` arguments.  Define behavior
consistent with CMake conventions and add a policy to provide
compatibility for projects that relied on the old accidental behavior.

Fixes: #16786
This commit is contained in:
Brad King
2017-06-08 11:54:03 -04:00
parent 69050f4d16
commit 82be694c7a
17 changed files with 201 additions and 3 deletions

View File

@@ -10,6 +10,7 @@
#include <vector>
#include "cmGeneratorExpression.h"
#include "cmPolicies.h"
#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
@@ -21,7 +22,8 @@ public:
cmGeneratorExpressionEvaluationFile(
const std::string& input,
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent);
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent,
cmPolicies::PolicyStatus policyStatusCMP0070);
void Generate(cmLocalGenerator* lg);
@@ -35,12 +37,21 @@ private:
cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string>& outputFiles, mode_t perm);
enum PathRole
{
PathForInput,
PathForOutput
};
std::string FixRelativePath(std::string const& filePath, PathRole role,
cmLocalGenerator* lg);
private:
const std::string Input;
const CM_AUTO_PTR<cmCompiledGeneratorExpression> OutputFileExpr;
const CM_AUTO_PTR<cmCompiledGeneratorExpression> Condition;
std::vector<std::string> Files;
const bool InputIsContent;
cmPolicies::PolicyStatus PolicyStatusCMP0070;
};
#endif