Skip to content

Commit 91463f5

Browse files
committed
Validate APPEND custom commands more strictly
1 parent da4ec26 commit 91463f5

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

docs/cmake-toml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ command-expand-lists = false
335335
uses-terminal = false
336336
```
337337

338-
For each custom command entry, exactly one of `outputs` or `build-event` is required. Relative `outputs`/`byproducts` paths follow CMake and are interpreted from the current binary directory. `build-event` is only valid for non-`interface` targets, and `pre-link` is not supported for `type = "custom"`. In both `add_custom_command(OUTPUT ...)` and `add_custom_target(...)`, `job-pool` cannot be combined with `uses-terminal = true`.
338+
For each custom command entry, exactly one of `outputs` or `build-event` is required. Relative `outputs`/`byproducts` paths follow CMake and are interpreted from the current binary directory. `build-event` is only valid for non-`interface` targets, and `pre-link` is not supported for `type = "custom"`. In both `add_custom_command(OUTPUT ...)` and `add_custom_target(...)`, `job-pool` cannot be combined with `uses-terminal = true`. When `append = true` is used with the `OUTPUT` form, at least one `command`/`commands` entry or `depends` must also be provided.
339339

340340
A table mapping the cmkr features to the relevant CMake construct and the relevant documentation pages:
341341

src/project_parser.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,11 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
10291029
}
10301030
}
10311031

1032-
if (custom_command.commands.empty() && !(custom_command.is_output_form() && custom_command.append)) {
1032+
if (custom_command.is_output_form() && custom_command.append && custom_command.commands.empty() && custom_command.depends.empty()) {
1033+
throw_key_error("append requires at least one command or depends", "append", custom.find("append"));
1034+
}
1035+
1036+
if (custom_command.commands.empty() && !(custom_command.is_output_form() && custom_command.append && !custom_command.depends.empty())) {
10331037
throw_key_error("At least one command is required", "custom-command", custom_command_value);
10341038
}
10351039

0 commit comments

Comments
 (0)