Skip to content

build(deps): Migrate fmt & spdlog dependencies to task-based installation (fixes #720).#870

Merged
kirkrodrigues merged 4 commits into
y-scope:mainfrom
kirkrodrigues:task-fmt-spdlog
Apr 30, 2025
Merged

build(deps): Migrate fmt & spdlog dependencies to task-based installation (fixes #720).#870
kirkrodrigues merged 4 commits into
y-scope:mainfrom
kirkrodrigues:task-fmt-spdlog

Conversation

@kirkrodrigues

@kirkrodrigues kirkrodrigues commented Apr 30, 2025

Copy link
Copy Markdown
Member

Description

As #720 indicates, building & installing spdlog to the system can end up conflicting with the version already installed on the system. At the same time, we can't always use the version installed on the system, since we want to support statically linking spdlog (& fmt), and the installed versions usually don't have static libraries.

Now that we can install cmake-based libraries through tasks, this PR switches to building and installing, to a local directory, fmt & spdlog.

This PR also:

  • Removes Findspdlog.cmake since the custom script is no longer necessary to control static linking since we always static-link with fmt & spdlog now.

    • The script was also buggy leading to errors like this:
      In file included from components/core/src/clp/aws/AwsAuthenticationSigner.cpp:9:
      /home/kirk/projects/builds/kr-clp/deps/core/spdlog-install/include/spdlog/fmt/chrono.h:17:14: fatal error: spdlog/fmt/bundled/chrono.h: No such file or directory
         17 | #    include <spdlog/fmt/bundled/chrono.h>
            |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      compilation terminated.
      
  • Removes the minimum required version from CMakeLists.txt, since it's easier to control the installed versions through the install tasks; moreover, chore(core): lock exact version of spdlog and fmtlib transitive dependency #621 is meant to be a robust way of ensuring compatible versions of fmt & spdlog are installed.

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

  • GH workflows succeed.
  • Building core in Debug mode succeeds.
  • Building core in Release mode succeeds.
  • ldd <binary> for every core binary doesn't show fmt or spdlog as dynamically linked.

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Simplified dependency management for fmt and spdlog libraries by removing static linking enforcement and custom CMake modules.
    • Removed manual installation scripts for fmt and spdlog on Linux and macOS platforms.
    • Integrated fmt and spdlog into automated dependency installation via the build system with proper task dependencies.
  • Documentation
    • Updated developer documentation to include fmt and spdlog as required dependencies.

@kirkrodrigues kirkrodrigues requested review from a team, gibber9809 and wraymo as code owners April 30, 2025 09:48
@coderabbitai

coderabbitai Bot commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change set removes custom static linking logic and installation scripts for the fmt and spdlog libraries, simplifying their integration by relying on standard CMake package discovery. The dependency management configuration now includes fmt and spdlog as managed dependencies, with tasks to install them from source as needed. Installation scripts and CMake modules specific to these libraries are deleted, and related installation steps are removed from platform-specific scripts. Documentation and dependency lists are updated to reflect the new approach, and the build system is adjusted to link against the standard spdlog::spdlog target.

Changes

File(s) Change Summary
components/core/CMakeLists.txt, components/core/src/clp_s/CMakeLists.txt Removed explicit version requirements and static linking enforcement for fmt and spdlog in CMake; updated linkage to use standard spdlog::spdlog target.
components/core/cmake/Modules/Findspdlog.cmake, components/core/tools/scripts/lib_install/fmtlib.sh, components/core/tools/scripts/lib_install/spdlog.sh Deleted custom CMake module and Bash installation scripts for fmt and spdlog.
components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh, components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh, components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh, components/core/tools/scripts/lib_install/macos/install-all.sh Removed installation steps for fmt and spdlog from platform-specific package installation scripts.
docs/src/dev-guide/components-core/index.md Updated documentation to list fmt and spdlog as required source dependencies.
taskfiles/deps/main.yaml Added fmt and spdlog as managed dependencies with corresponding installation tasks; updated dependency chain for core build.

Sequence Diagram(s)

sequenceDiagram
    participant TaskRunner
    participant FmtInstaller
    participant SpdlogInstaller
    participant CMake
    participant BuildTarget

    TaskRunner->>FmtInstaller: Run fmt install task
    FmtInstaller-->>TaskRunner: fmt installed
    TaskRunner->>SpdlogInstaller: Run spdlog install task (depends on fmt)
    SpdlogInstaller-->>TaskRunner: spdlog installed
    TaskRunner->>CMake: Configure build (find_package fmt, spdlog)
    CMake->>BuildTarget: Link against fmt::fmt, spdlog::spdlog
    BuildTarget-->>CMake: Build with dependencies
Loading

Suggested reviewers

  • davidlion
  • LinZhihao-723

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95fa1d8 and 7bf8b3c.

📒 Files selected for processing (1)
  • taskfiles/deps/main.yaml (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • taskfiles/deps/main.yaml
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: centos-stream-9-deps-image
  • GitHub Check: ubuntu-jammy-deps-image

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kirkrodrigues kirkrodrigues requested a review from Copilot April 30, 2025 09:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
taskfiles/deps/main.yaml (1)

240-266: Define spdlog installation task and disable examples: Suggest optional improvement

The spdlog task correctly references fmt settings and disables examples. To further speed up the build and reduce unnecessary artifacts, consider adding a flag to disable test builds as well:

-CMAKE_GEN_ARGS:
-  - "-C {{.G_DEPS_CORE_CMAKE_SETTINGS_DIR}}/{{.G_FMT_LIB_NAME}}.cmake"
-  - "-DCMAKE_BUILD_TYPE=Release"
-  - "-DCMAKE_INSTALL_MESSAGE=LAZY"
-  - "-DCMAKE_POLICY_DEFAULT_CMP0074=NEW"
-  - "-DSPDLOG_BUILD_EXAMPLE=OFF"
-  - "-DSPDLOG_BUILD_EXAMPLE_HO=OFF"
-  - "-DSPDLOG_FMT_EXTERNAL=ON"
+CMAKE_GEN_ARGS:
+  - "-C {{.G_DEPS_CORE_CMAKE_SETTINGS_DIR}}/{{.G_FMT_LIB_NAME}}.cmake"
+  - "-DCMAKE_BUILD_TYPE=Release"
+  - "-DCMAKE_INSTALL_MESSAGE=LAZY"
+  - "-DCMAKE_POLICY_DEFAULT_CMP0074=NEW"
+  - "-DSPDLOG_BUILD_EXAMPLE=OFF"
+  - "-DSPDLOG_BUILD_EXAMPLE_HO=OFF"
+  - "-DSPDLOG_BUILD_TESTS=OFF"
+  - "-DSPDLOG_FMT_EXTERNAL=ON"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between faddfc3 and 95fa1d8.

📒 Files selected for processing (11)
  • components/core/CMakeLists.txt (2 hunks)
  • components/core/cmake/Modules/Findspdlog.cmake (0 hunks)
  • components/core/src/clp_s/CMakeLists.txt (1 hunks)
  • components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh (0 hunks)
  • components/core/tools/scripts/lib_install/fmtlib.sh (0 hunks)
  • components/core/tools/scripts/lib_install/macos/install-all.sh (0 hunks)
  • components/core/tools/scripts/lib_install/spdlog.sh (0 hunks)
  • components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh (0 hunks)
  • components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh (0 hunks)
  • docs/src/dev-guide/components-core/index.md (1 hunks)
  • taskfiles/deps/main.yaml (4 hunks)
💤 Files with no reviewable changes (7)
  • components/core/tools/scripts/lib_install/macos/install-all.sh
  • components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh
  • components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh
  • components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh
  • components/core/cmake/Modules/Findspdlog.cmake
  • components/core/tools/scripts/lib_install/spdlog.sh
  • components/core/tools/scripts/lib_install/fmtlib.sh
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: centos-stream-9-deps-image
  • GitHub Check: ubuntu-jammy-deps-image
  • GitHub Check: build-macos (macos-15, false)
  • GitHub Check: build-macos (macos-15, true)
  • GitHub Check: build-macos (macos-13, false)
  • GitHub Check: build-macos (macos-13, true)
  • GitHub Check: build-macos (macos-14, true)
🔇 Additional comments (9)
components/core/src/clp_s/CMakeLists.txt (1)

211-214: Link spdlog::spdlog to clp_s_TimestampPattern: Approved

The addition of spdlog::spdlog ensures that timestamp pattern components can leverage spdlog for logging. It matches the executable target’s linkage and uses the imported target from the core CMakeLists.

docs/src/dev-guide/components-core/index.md (2)

39-39: Document fmt as a source dependency: Approved

Listing fmt (v8.0.1) under Source Dependencies aligns with the build tasks and CMake integration.


44-44: Document spdlog as a source dependency: Approved

Including spdlog (v1.9.2) is consistent with the task-based installation approach and CMake targets.

components/core/CMakeLists.txt (2)

151-154: Find fmt without version constraint: Approved

Switching to find_package(fmt REQUIRED) without a hardcoded minimum version is intentional, as version control is delegated to the task installation. This streamlines the CMake logic.


171-174: Find spdlog without static flags: Approved

Using find_package(spdlog REQUIRED) and linking spdlog::spdlog relies on the task-generated static library. The removal of custom static-handling logic is consistent with the PR objectives.

taskfiles/deps/main.yaml (4)

20-22: Introduce G_FMT_LIB_NAME variable: Approved

Defining G_FMT_LIB_NAME centralizes the fmt library name for reuse in dependent tasks and CMake settings.


61-63: Add fmt to the core parallel dependency: Approved

Including fmt in core-all-parallel ensures the formatting library is built before other dependencies that rely on it.


65-68: Add spdlog to the core parallel dependency: Approved

spdlog now depends on fmt and is built as part of the core dependency graph. The ordering is correct.


148-161: Define fmt installation task: Approved

The task for downloading, building, and installing fmt (v8.0.1) with -DFMT_TEST=OFF is well configured. It matches the CMake settings import and ensures consistent build behaviour.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the fmt and spdlog dependencies to a task-based installation approach to address conflicts with system-installed versions and enable static linking. Key changes include:

  • Adding new variables and tasks in the dependency taskfile for fmt and spdlog.
  • Removing the outdated Findspdlog.cmake script.
  • Updating developer documentation to reflect the new installation tasks.

Reviewed Changes

Copilot reviewed 2 out of 11 changed files in this pull request and generated 1 comment.

File Description
taskfiles/deps/main.yaml Introduces fmt and spdlog tasks with remote CMake library installation.
docs/src/dev-guide/components-core/index.md Updates documentation to include fmt and spdlog as dependencies.
Files not reviewed (9)
  • components/core/CMakeLists.txt: Language not supported
  • components/core/cmake/Modules/Findspdlog.cmake: Language not supported
  • components/core/src/clp_s/CMakeLists.txt: Language not supported
  • components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh: Language not supported
  • components/core/tools/scripts/lib_install/fmtlib.sh: Language not supported
  • components/core/tools/scripts/lib_install/macos/install-all.sh: Language not supported
  • components/core/tools/scripts/lib_install/spdlog.sh: Language not supported
  • components/core/tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh: Language not supported
  • components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh: Language not supported
Comments suppressed due to low confidence (1)

taskfiles/deps/main.yaml:260

  • [nitpick] For consistency and maintainability, consider defining a variable for spdlog (similar to G_FMT_LIB_NAME for fmt) rather than using a hard-coded string.
LIB_NAME: "spdlog"

Comment thread taskfiles/deps/main.yaml
cmds:
- task: "utils:install-remote-cmake-lib"
vars:
CMAKE_GEN_ARGS:

Copilot AI Apr 30, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Explicitly referencing fmt's CMake settings for spdlog may be confusing. Consider adding a clarifying comment to explain that spdlog is configured to use fmt's settings file due to the dependency relationship.

Suggested change
CMAKE_GEN_ARGS:
CMAKE_GEN_ARGS:
# Use fmt's CMake settings file because spdlog depends on fmt.

Copilot uses AI. Check for mistakes.
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.

3 participants