summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-08-15 18:53:15 (GMT)
committerRaul Tambre <raul@tambre.ee>2020-08-20 14:41:52 (GMT)
commit27a912193bfe77e400784b152b1cd67003915c37 (patch)
tree5919a51c400894c9891720f44b842d347a892b31 /Source/cmFileCommand.cxx
parent2a8f363a54c77bf1f110deabf1933e71a93ef3f4 (diff)
downloadCMake-27a912193bfe77e400784b152b1cd67003915c37.zip
CMake-27a912193bfe77e400784b152b1cd67003915c37.tar.gz
CMake-27a912193bfe77e400784b152b1cd67003915c37.tar.bz2
file(GENERATE): Add TARGET argument
Adds TARGET argument to file(GENERATE) to make resolving generator expressions requiring a target possible. Implements #21101, fixes #21074.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx35
1 files changed, 25 insertions, 10 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8d20d35..550ad6e 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2240,6 +2240,7 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
}
void AddEvaluationFile(const std::string& inputName,
+ const std::string& targetName,
const std::string& outputExpr,
const std::string& condition, bool inputIsContent,
cmExecutionStatus& status)
@@ -2255,7 +2256,8 @@ void AddEvaluationFile(const std::string& inputName,
conditionGe.Parse(condition);
status.GetMakefile().AddEvaluationFile(
- inputName, std::move(outputCge), std::move(conditionCge), inputIsContent);
+ inputName, targetName, std::move(outputCge), std::move(conditionCge),
+ inputIsContent);
}
bool HandleGenerateCommand(std::vector<std::string> const& args,
@@ -2269,23 +2271,36 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
+
std::string condition;
- if (args.size() > 5) {
- if (args[5] != "CONDITION") {
+ std::string target;
+
+ for (std::size_t i = 5; i < args.size();) {
+ const std::string& arg = args[i++];
+
+ if (args.size() - i == 0) {
status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
- if (args.size() != 7) {
- status.SetError("Incorrect arguments to GENERATE subcommand.");
+
+ const std::string& value = args[i++];
+
+ if (value.empty()) {
+ status.SetError(
+ arg + " of sub-command GENERATE must not be empty if specified.");
return false;
}
- condition = args[6];
- if (condition.empty()) {
- status.SetError("CONDITION of sub-command GENERATE must not be empty if "
- "specified.");
+
+ if (arg == "CONDITION") {
+ condition = value;
+ } else if (arg == "TARGET") {
+ target = value;
+ } else {
+ status.SetError("Unknown argument to GENERATE subcommand.");
return false;
}
}
+
std::string output = args[2];
const bool inputIsContent = args[3] != "INPUT";
if (inputIsContent && args[3] != "CONTENT") {
@@ -2294,7 +2309,7 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
}
std::string input = args[4];
- AddEvaluationFile(input, output, condition, inputIsContent, status);
+ AddEvaluationFile(input, target, output, condition, inputIsContent, status);
return true;
}