@@ -51,7 +51,12 @@ 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 AND JSONC_INCLUDE_DIRS AND JSONC_LIBRARIES)
54
+ if (JSONC_FOUND AND JSONC_INCLUDE_DIRS)
55
+ # Ensure we have the full path to the library, not just 'json-c'
56
+ find_library (JSONC_LIB NAMES json-c PATHS ${JSONC_LIBRARY_DIRS} /usr/lib/x86_64-linux-gnu /usr/lib /lib)
57
+ if (JSONC_LIB)
58
+ set (JSONC_LIBRARIES "${JSONC_LIB} " )
59
+ endif ()
55
60
if (NOT TARGET json-c::json-c)
56
61
add_library (json-c::json-c INTERFACE IMPORTED )
57
62
set_target_properties (json-c::json-c PROPERTIES
@@ -60,31 +65,15 @@ else()
60
65
)
61
66
endif ()
62
67
set (jsonc_libs json-c::json-c)
63
- message ("json-c [${JSONC_VERSION} ] is ${JSONC_LINK_LIBRARIES } " )
68
+ message ("json-c [${JSONC_VERSION} ] is ${JSONC_LIBRARIES } " )
64
69
else ()
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 ()
70
+ find_package (json-c REQUIRED)
71
+ if (TARGET json-c::json-c)
72
+ set (jsonc_libs json-c::json-c)
80
73
else ()
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 ()
74
+ message (FATAL_ERROR "Could not find required library [json-c]" )
87
75
endif ()
76
+
88
77
endif ()
89
78
endif ()
90
79
if (NOT jsonc_libs)
0 commit comments