Skip to content

build: use installed fmt and support multiple Homebrew prefixes#25

Merged
ric2k1 merged 5 commits into
DVLab-NTU:mainfrom
AaronWu-train:main
Mar 24, 2026
Merged

build: use installed fmt and support multiple Homebrew prefixes#25
ric2k1 merged 5 commits into
DVLab-NTU:mainfrom
AaronWu-train:main

Conversation

@AaronWu-train
Copy link
Copy Markdown
Contributor

Summary

This PR improves dependency resolution on macOS by:

  • preferring an installed fmt library via find_package(fmt)
  • keeping the existing git-based fallback for environments without installed fmt
  • supporting multiple Homebrew prefixes for gmp, including both /opt/homebrew and /usr/local
  • updating the Brewfile to ensure fmt is installed in local development environments

Motivation

The previous build setup could fail during CMake linking when the fmt headers used during compilation did not match the fmt library version used during linking.

At the same time, some environments may not have fmt installed locally, so the existing git-based dependency flow should remain available as a fallback.

Separately, gmp may be installed under different Homebrew prefixes depending on the machine and Homebrew setup:

  • /opt/homebrew
  • /usr/local

The build configuration should handle both layouts.

Changes

Prefer installed fmt with fallback support

  • add find_package(fmt) to prefer the installed fmt library when available
  • keep the existing git-clone / FetchContent path as a fallback when fmt is not installed
  • reduce CMake linking errors caused by header/library version mismatches
  • update the Brewfile to install fmt

Support multiple Homebrew prefixes for gmp

  • support both /opt/homebrew and /usr/local when resolving gmp
  • improve macOS dependency lookup for different Homebrew installations

Result

This makes the macOS build process more robust by:

  • preferring the locally installed fmt when available
  • preserving compatibility for environments that still rely on the fetched fmt
  • allowing gmp to be found across different Homebrew prefix layouts
  • making dependency resolution more predictable for local development

Testing

Tested on macOS with Homebrew-based dependencies.

Validated that:

  • CMake can use installed fmt when available
  • the existing fallback path still works when fmt is not installed
  • gmp can be resolved from different Homebrew prefixes

- support both /opt/homebrew and /usr/local prefixes
- improve macOS dependency lookup for different Homebrew versions
- add find_package(fmt) to use the installed fmt library and
  avoid CMake linking errors caused by header/library version mismatches
- update the Brewfile to install fmt
- try find_package(fmt) first to prefer installed fmt
- fall back to FetchContent if fmt is not found
- preserve the existing git-based dependency path for environments without fmt
Remove install fmt in Brewfile
@ric2k1 ric2k1 merged commit 0f7dfd0 into DVLab-NTU:main Mar 24, 2026
2 checks passed
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