Fix macOS linker error: replace pkg-config JsonCpp detection with CMake target linking#109
Merged
Merged
Conversation
…ONFIG QUIET) Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix macOS linker error for JsonCpp in CMakeLists.txt
Fix macOS linker error: replace pkg-config JsonCpp detection with CMake target linking
Feb 22, 2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a macOS linker error where pkg-config resolves JsonCpp to an unresolvable -ljsoncpp flag. The solution replaces the pkg-config detection with CMake's config-based package discovery, which provides proper imported targets with transitive include and link dependencies.
Changes:
- Simplified JsonCpp detection to use
find_package(jsoncpp CONFIG QUIET)instead of a pkg-config + fallback chain - Replaced raw library flag linking (
${JSONCPP_LIBRARIES}) with CMake target linking (jsoncpp_lib) for bothailee_nodeandailee_adapters - Consolidated compile definitions and linking into single conditional blocks guarded by
jsoncpp_FOUND
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
On Apple Silicon macOS,
pkg_check_modules(JSONCPP jsoncpp)resolvesJSONCPP_LIBRARIESto the raw flag-ljsoncpp, which the macOS linker cannot resolve. Homebrew-installed JsonCpp exposes a proper CMake config package with thejsoncpp_libtarget.Changes
pkg_check_modules+find_packagefallback chain with a singlefind_package(jsoncpp CONFIG QUIET)${JSONCPP_LIBRARIES}from bothailee_nodeandailee_adapters; link viajsoncpp_libtarget inside aif(jsoncpp_FOUND)guard instead${JSONCPP_INCLUDE_DIRS}from globalinclude_directories; thejsoncpp_libtarget propagates its own includes transitivelyAILEE_HAS_JSONCPP=1into the sameif(jsoncpp_FOUND)block, removing the now-redundantif(JSONCPP_FOUND OR jsoncpp_FOUND)checksBefore:
After:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.