Skip to content

feat(taskfiles)!: Add cmake:install-deps-and-generate-settings to install all CMake-based dependencies and write their settings files. #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 21, 2025

Conversation

davidlion
Copy link
Member

@davidlion davidlion commented Apr 17, 2025

Description

Adds support for writing CMake settings files to be included by CMake projects when installing dependencies. The original source of the idea and tasks is from y-scope/ystdlib-cpp#39.

Example usage:

tasks:
  all:
    cmds:
      - task: ":utils:cmake:install-deps-and-generate-settings"
        vars:
          CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
          DEP_TASK: "deps:install-all"

  install-all:
    internal: true
    deps:
      - "install-Catch2"
      - "install-fmt"
      - "install-Microsoft.GSL"

  install-Catch2:
    internal: true
    run: "once"
    cmds:
      - task: ":utils:cmake:install-remote-tar"
        vars:
          CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
          NAME: "Catch2"
          WORK_DIR: "{{.G_DEPS_DIR}}/Catch2"
          FILE_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
          URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Tested with local changes in log-surgeon.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced installation process to generate CMake cache variable files with project root details.
    • Added support for specifying a directory to store CMake settings files during installation.
    • Introduced a new task to manage and aggregate CMake dependency settings files efficiently.
  • Chores

    • Updated installation tasks to support improved handling of CMake settings directories and parameters.

@davidlion davidlion requested a review from a team as a code owner April 17, 2025 04:49
Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

## Walkthrough

The changes introduce enhancements to CMake-related task automation. The `install` task now requires a `NAME` parameter and optionally accepts a `CMAKE_SETTINGS_DIR` parameter; when provided, it writes a CMake cache variable file defining `<NAME>_ROOT` in that directory. The `install-remote-tar` task is updated to default its `CMAKE_SETTINGS_DIR` and to pass both `NAME` and `CMAKE_SETTINGS_DIR` to the `install` task. A new internal task `install-deps-and-generate-settings` is added to manage CMake dependencies by recreating the settings directory, running a specified dependency installation task, and generating an aggregated CMake settings file including all `.cmake` files except itself.

## Changes

| File(s)                           | Change Summary                                                                                                                                                                                                                           |
|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| exports/taskfiles/utils/cmake.yaml | - `install` task: Added required `NAME` and optional `CMAKE_SETTINGS_DIR` parameters; writes `<NAME>.cmake` file with root path variable.<br>- `install-remote-tar` task: Defaults `CMAKE_SETTINGS_DIR` to `${WORK_DIR}/cmake-settings`; passes `NAME` and `CMAKE_SETTINGS_DIR` to `install`.<br>- Added new internal `install-deps-and-generate-settings` task: Recreates settings directory, runs dependency installation task (`DEP_TASK`), and generates combined CMake settings file excluding itself. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant TaskRunner
    participant InstallTask
    participant InstallDepsTask

    User->>TaskRunner: Run install-deps-and-generate-settings (CMAKE_SETTINGS_DIR, DEP_TASK)
    TaskRunner->>InstallDepsTask: Remove & recreate CMAKE_SETTINGS_DIR
    InstallDepsTask->>TaskRunner: Run DEP_TASK (dependency installation)
    InstallDepsTask->>InstallDepsTask: Generate combined settings.cmake including all .cmake files except itself
    InstallDepsTask->>User: Done

    User->>TaskRunner: Run install (NAME, CMAKE_SETTINGS_DIR)
    TaskRunner->>InstallTask: install
    InstallTask->>InstallTask: Write <NAME>.cmake with <NAME>_ROOT variable in CMAKE_SETTINGS_DIR
    InstallTask->>User: Done

Possibly related PRs

  • y-scope/yscope-dev-utils#22: Extends the install-remote-tar task by adding CMake settings management parameters and introduces new tasks for generating CMake dependency settings, building directly on the tasks modified here.

  • y-scope/yscope-dev-utils#27: Renames and restructures CMake tasks in the same file without changing logic or adding new tasks, related by file and task names but differing in scope.

Suggested reviewers

  • kirkrodrigues

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between aae90ca867a0e32f812a7b53948f7d4454fdb03c and 7b1717c0743bb3fee6033219c61d5ad6bfd2667b.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `exports/taskfiles/utils/cmake.yaml` (5 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* exports/taskfiles/utils/cmake.yaml

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMxJqAApcNEQAa1j4SMQAShAuAEFaegADBmY0NJIORBJcbG4wJW5EErD8FAxEFJ90XuayJQwGeGl0DHoAdwp1D1xYEng+WtxxDCJkTOzoyEnU+2wBZnUaejkwhchsWr5aNAl4Wi94fCx920gMRwFKSAAWACMnQuHlkYEQTG4JAA9LIIfgoU0SBIwHgssh/Nx8Ih1PgXBoYAhkB94BhcBRFNgGGMHNwsRRQrE8bsZmsiJAAMIAWUqHhWbM2WTG82ojEwkB+nQYXmwSjO8m5vJ4FJ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g11Ny31BjGkua6a5IF4VEyadVBshtMVRBxWEym+LnRnllEc3or8GG8sM1KkWGyOFbIVVeJVKAVVeDVaXcuBg1YGBdna+gLcLEEDfb7egKCA5UGDo4JuUMbaRzUNHJ2cdvMa3RVZc+jxEDn38A8EpdBz46gZLHeOPmAAMxWABsu5dwMBwtSMrABWAA7B2P4xWAT7j+PuWgDXivFGK3VgAHCQAEAg0A4VEGV/ru5RuFaSxAf4OEcK0BwnV2I+4Gu0FiPVgEZWGC7mK914rOEBD9diJt4rfwyt/A62V/cdWcINe2zNnzI3aYCBwv1rrAgqvneK6tjbdWGAAhwgCBg+40B/Aa/uWIfwSD7n3P10r/X+tPeS/uRbu4kfFHux2AQdW0DFf6zhKrZXaDUkWwCBru5YgCGKyQYraASD9fW38FHc2utXd3HVgbp2ScHda38A8jOhsNfe7D+nU3YiDZq/uXcrOoBoAZ/uYrDl+tlaa7T3cOFJdA7QA13HB4/gneZ38OrfxYi0Bp1VuXkA9cU4pwwfbAvVBU7amV4rlXgf7gYGVgEtA8e0DKwIc3OEytq4EDN2bUAUHqDS7QDLWXRiTFy1rfQQA=== -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=y-scope/yscope-dev-utils&utm_content=41):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
exports/taskfiles/utils/cmake.yaml (1)

242-251: 🛠️ Refactor suggestion

Harden setup-deps script execution

Currently, if there are no .cmake files, the glob will remain literal (dir/*.cmake), and errors in the dependency task won’t abort the loop. Consider enabling nullglob and errexit:

 cmds:
-  - "rm -rf {{.CMAKE_SETTINGS_DIR}}"
-  - "mkdir -p {{.CMAKE_SETTINGS_DIR}}"
+  - "set -euo pipefail; shopt -s nullglob"
+  - "rm -rf {{.CMAKE_SETTINGS_DIR}}"
+  - "mkdir -p {{.CMAKE_SETTINGS_DIR}}"
   - task: "::{{.DEP_TASK}}"
   - >-
     for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do

This ensures the script stops on failures and skips the loop when no files are present.

🧹 Nitpick comments (3)
exports/taskfiles/utils/cmake.yaml (3)

89-96: Refine documentation for install task parameters

The descriptions for NAME and [CMAKE_SETTINGS_DIR] should align with the style of other tasks (use backticks for code elements, include punctuation). Consider reordering parameters to match the requires.vars block and add a brief note on the conditional behaviour when CMAKE_SETTINGS_DIR is empty.


148-152: Fix install-remote-tar parameter docs

The @param [CMAKE_SETTINGS_DIR] entry is slightly misaligned and should explicitly mention its default. For consistency:

  # @param {string} [CMAKE_SETTINGS_DIR={{.WORK_DIR}}/cmake-settings]
  #   Directory to write each project's CMake settings file.

219-232: Add description for optional CMAKE_SETTINGS_FILE

The @param {string} [CMAKE_SETTINGS_FILE] tag is declared but has no description. Please document its purpose (e.g., “Path to the combined settings file, defaults to ${CMAKE_SETTINGS_DIR}/settings.cmake”).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20fe6d7 and 00633c2.

📒 Files selected for processing (1)
  • exports/taskfiles/utils/cmake.yaml (5 hunks)
🔇 Additional comments (2)
exports/taskfiles/utils/cmake.yaml (2)

181-187: Passing NAME and CMAKE_SETTINGS_DIR to install

This block correctly propagates the new NAME and CMAKE_SETTINGS_DIR variables to the install task, enabling the generation of project-specific CMake settings files as intended.


233-241: Initialize setup-deps task correctly

The setup-deps task is well-defined with internal, a clear label, defaulting CMAKE_SETTINGS_FILE, and requiring the proper variables. This aligns with the new dependency aggregation feature.

Comment on lines +101 to 107
CMAKE_SETTINGS_DIR: >-
{{default "" .CMAKE_SETTINGS_DIR}}
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
requires:
vars: ["BUILD_DIR", "INSTALL_PREFIX"]
vars: ["BUILD_DIR", "INSTALL_PREFIX", "NAME"]
cmds:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Requiring NAME is a breaking change

Adding NAME to the required variables for the install task will break existing invocations that didn’t supply this value. You may want to:

  • Make NAME optional (with a default or empty fallback).
  • Or require NAME only when CMAKE_SETTINGS_DIR is set (using templating logic).

@davidlion davidlion changed the title feat(taskfile): Add cmake:setup-deps to install all dependencies and write their settings files. feat(taskfiles)!: Add cmake:setup-deps to install all dependencies and write their settings files. Apr 17, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
exports/taskfiles/utils/cmake.yaml (2)

110-111: Requiring NAME is a breaking change.

This enforces a new mandatory NAME parameter. Existing workflows without NAME will break. Consider making NAME optional (with a default) or conditionally requiring it only when CMAKE_SETTINGS_DIR is set.


119-126: Refactor echo block to a here‑doc.

Chaining multiple echo lines in YAML can quickly become hard to maintain. A here‑doc preserves formatting and is clearer:

-       echo "set({{.NAME}}_ROOT
-         \"{{.INSTALL_PREFIX}}\"
-         CACHE PATH
-         \"Path to {{.NAME}} settings.\"
-       )" >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
+       cat <<EOF >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
+       set({{.NAME}}_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Path to {{.NAME}} settings.")
+       EOF
🧹 Nitpick comments (5)
exports/taskfiles/utils/cmake.yaml (5)

88-90: Clarify the install task description formatting.

The newly added lines explain CMAKE_SETTINGS_DIR behaviour well, but consider converting these into a bullet list under the existing paragraph to improve readability and avoid long wrapped comment lines.


97-100: Document default values in parameter docs.

The @param entries for NAME and CMAKE_SETTINGS_DIR don’t show their defaults. Please update them to mention that CMAKE_SETTINGS_DIR defaults to empty (or a specific path when used) or point to the vars section below.


223-238: Enhance setup-deps documentation.

The new task’s docstring is detailed, but:

  • Change “Setup” (noun) to “set up” (verb) in the header.
  • Format the 1., 2., 3. steps as Markdown list items without leading capitals on continuation lines.
  • Clarify that CMAKE_SETTINGS_FILE defaults to settings.cmake under the directory.

243-245: Consider renaming the default combined file to all.cmake.

Most consumers expect a name like all.cmake to aggregate multiple includes, matching common conventions. You could default CMAKE_SETTINGS_FILE to {{.CMAKE_SETTINGS_DIR}}/all.cmake.


255-259: Increase portability of the include‑loop.

Currently using Bash‑specific [[ ]] and unquoted globs. To make this POSIX‑compliant and safer with spaces, consider:

- for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do
-   if [[ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]]; then
-     echo "include(\"$file\")" >> "{{.CMAKE_SETTINGS_FILE}}";
-   fi
- done
+ for file in "{{.CMAKE_SETTINGS_DIR}}"/*.cmake; do
+   [ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ] && \
+     printf 'include("%s")\n' "$file" >> "{{.CMAKE_SETTINGS_FILE}}"
+ done
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bafab28 and 92d388d.

📒 Files selected for processing (1)
  • exports/taskfiles/utils/cmake.yaml (5 hunks)
🔇 Additional comments (5)
exports/taskfiles/utils/cmake.yaml (5)

105-106: Valid default for CMAKE_SETTINGS_DIR.

Using an empty default for CMAKE_SETTINGS_DIR is correct to make the feature opt‑in. It cleanly disables the settings‑file generation when unspecified.


185-186: Default for remote‑tar settings directory is appropriate.

Using {{printf "%s/cmake-settings" .WORK_DIR}} ensures all projects share a predictable default. This aligns with the install task’s option and the examples.


217-221: Pass through CMAKE_SETTINGS_DIR and NAME correctly.

These lines correctly inject the settings directory and project name into the install task. This ensures downstream tasks will generate the proper <NAME>.cmake files.


248-249: Clean and recreate settings directory.

The rm -rf then mkdir -p sequence reliably resets the directory. This pattern is clear and intentional for idempotent task runs.


253-253: Qualified DEP_TASK invocation is correct.

Prefixing with :: ensures the dependency task is resolved from the project root, avoiding ambiguity.

# included in CMAKE_SETTINGS_FILE.
# @param {string} [CMAKE_SETTINGS_FILE={{.CMAKE_SETTINGS_DIR}}/all.cmake] The file in which to
# combine each dependency's settings file.
setup-deps:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about install-deps-and-generate-settings?

@davidlion davidlion requested a review from kirkrodrigues April 21, 2025 04:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
exports/taskfiles/utils/cmake.yaml (2)

109-111: Requiring NAME is a breaking change
This mirrors an earlier concern: making NAME mandatory will break existing install invocations that didn’t supply it. Consider making NAME optional or only required when CMAKE_SETTINGS_DIR is non‑empty.


119-126: 🛠️ Refactor suggestion

Improve CMake settings file generation block
The current multi‑line echo inside a folded >- block risks formatting issues and is hard to maintain. Using a literal block with cat <<EOF or a here‑doc preserves newlines and indentation more clearly. For example:

-      - >-
-        {{- if .CMAKE_SETTINGS_DIR}}
-          echo "set({{.NAME}}_ROOT
-            \"{{.INSTALL_PREFIX}}\"
-            CACHE PATH
-            \"Package root for {{.NAME}}.\"
-          )" >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
-        {{- end}}
+      - |-
+        {{- if .CMAKE_SETTINGS_DIR}}
+          cat <<-EOF >> "{{.CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
+          set({{.NAME}}_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for {{.NAME}}.")
+          EOF
+        {{- end}}
🧹 Nitpick comments (4)
exports/taskfiles/utils/cmake.yaml (4)

88-93: Clarify install task documentation
The new comments explaining CMAKE_SETTINGS_DIR behaviour could be streamlined and aligned with the style of other tasks. For example, start with a concise summary sentence and use consistent Markdown‑style bullets for optional features.


97-99: Document default behaviour for CMAKE_SETTINGS_DIR
It would help users to explicitly note that omitting CMAKE_SETTINGS_DIR (defaulting to "") disables settings file generation. Consider enhancing the @param description:

- # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
- # file should be stored.
+ # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
+ # file should be stored. Defaults to `""`, which skips writing any settings file.

223-238: Refine install-deps-and-generate-settings doc comments
The new task documentation could be more concise and consistent with other taskfiles. Suggestions:

  • Use “Set up” instead of “Setup” for the verb in the summary.
  • Format lists as Markdown bullets (-) without extra indentation.
  • Keep the @param defaults in sync with the code.

254-259: Enhance portability of settings file inclusion loop
The for file in *.cmake loop may expand the literal pattern if no files exist. Consider guarding against missing matches and using portable syntax, for example:

for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do
  [ -e "$file" ] || continue
  if [ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]; then
    printf 'include("%s")\n' "$file" >> "{{.CMAKE_SETTINGS_FILE}}"
  fi
done
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d744355 and aae90ca.

📒 Files selected for processing (1)
  • exports/taskfiles/utils/cmake.yaml (5 hunks)
🔇 Additional comments (4)
exports/taskfiles/utils/cmake.yaml (4)

105-106: Default CMAKE_SETTINGS_DIR fallback
Using {{default "" .CMAKE_SETTINGS_DIR}} cleanly disables file generation when unset. This aligns nicely with the conditional block below.


185-186: Default CMAKE_SETTINGS_DIR in install-remote-tar
Providing ${WORK_DIR}/cmake-settings as the default aligns with the overall workflow and user expectations. This change is sensible.


217-222: Pass CMAKE_SETTINGS_DIR and NAME to install task
The updated install-remote-tar invocation correctly wires both CMAKE_SETTINGS_DIR and NAME through to the install task.


248-253: Clean and prepare settings directory then run DEP_TASK
Using rm -rf followed by mkdir -p and a fully qualified ::{{.DEP_TASK}} invocation is clear and effective for resetting the environment.

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the PR title, how about:

feat(taskfiles)!: Add `cmake:install-deps-and-generate-settings` to install all CMake-based dependencies and write their settings files.

@davidlion davidlion changed the title feat(taskfiles)!: Add cmake:setup-deps to install all dependencies and write their settings files. feat(taskfiles)!: Add cmake:install-deps-and-generate-settings to install all CMake-based dependencies and write their settings files. Apr 21, 2025
@davidlion davidlion merged commit e300d1b into y-scope:main Apr 21, 2025
1 check passed
@davidlion davidlion deleted the cmake-dep-helpers branch April 21, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants