@@ -51,7 +51,7 @@ if (TARGET json-c::json-c)
51
51
set (jsonc_libs json-c::json-c )
52
52
else ()
53
53
pkg_check_modules (JSONC json-c )
54
- if (JSONC_FOUND )
54
+ if (JSONC_FOUND AND JSONC_INCLUDE_DIRS AND JSONC_LIBRARIES )
55
55
if (NOT TARGET json-c::json-c )
56
56
add_library (json-c::json-c INTERFACE IMPORTED )
57
57
set_target_properties (json-c::json-c PROPERTIES
@@ -62,11 +62,28 @@ else()
62
62
set (jsonc_libs json-c::json-c )
63
63
message ("json-c [${JSONC_VERSION} ] is ${JSONC_LINK_LIBRARIES} " )
64
64
else ()
65
- find_package (json-c REQUIRED )
66
- if (TARGET json-c::json-c )
67
- set (jsonc_libs json-c::json-c )
65
+ # Try Homebrew default path on macOS
66
+ if (APPLE )
67
+ find_path (JSONC_INCLUDE_DIRS json-c/json.h PATHS /opt/homebrew/include /usr/local/include )
68
+ find_library (JSONC_LIBRARIES json-c PATHS /opt/homebrew/lib /usr/local/lib )
69
+ if (JSONC_INCLUDE_DIRS AND JSONC_LIBRARIES )
70
+ add_library (json-c::json-c INTERFACE IMPORTED )
71
+ set_target_properties (json-c::json-c PROPERTIES
72
+ INTERFACE_INCLUDE_DIRECTORIES "${JSONC_INCLUDE_DIRS} "
73
+ INTERFACE_LINK_LIBRARIES "${JSONC_LIBRARIES} "
74
+ )
75
+ set (jsonc_libs json-c::json-c )
76
+ message ("json-c (manual Homebrew) is ${JSONC_LIBRARIES} " )
77
+ else ()
78
+ message (FATAL_ERROR "Could not find required library [json-c] (tried pkg-config and Homebrew paths)" )
79
+ endif ()
68
80
else ()
69
- message (FATAL_ERROR "Could not find required library [json-c]" )
81
+ find_package (json-c REQUIRED )
82
+ if (TARGET json-c::json-c )
83
+ set (jsonc_libs json-c::json-c )
84
+ else ()
85
+ message (FATAL_ERROR "Could not find required library [json-c]" )
86
+ endif ()
70
87
endif ()
71
88
endif ()
72
89
endif ()
0 commit comments