build: use installed fmt and support multiple Homebrew prefixes#25
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves dependency resolution on macOS by:
fmtlibrary viafind_package(fmt)fmtgmp, including both/opt/homebrewand/usr/localBrewfileto ensurefmtis installed in local development environmentsMotivation
The previous build setup could fail during CMake linking when the
fmtheaders used during compilation did not match thefmtlibrary version used during linking.At the same time, some environments may not have
fmtinstalled locally, so the existing git-based dependency flow should remain available as a fallback.Separately,
gmpmay be installed under different Homebrew prefixes depending on the machine and Homebrew setup:/opt/homebrew/usr/localThe build configuration should handle both layouts.
Changes
Prefer installed
fmtwith fallback supportfind_package(fmt)to prefer the installedfmtlibrary when availableFetchContentpath as a fallback whenfmtis not installedBrewfileto installfmtSupport multiple Homebrew prefixes for
gmp/opt/homebrewand/usr/localwhen resolvinggmpResult
This makes the macOS build process more robust by:
fmtwhen availablefmtgmpto be found across different Homebrew prefix layoutsTesting
Tested on macOS with Homebrew-based dependencies.
Validated that:
fmtwhen availablefmtis not installedgmpcan be resolved from different Homebrew prefixes