[cmake] really use pkg_check_modules results for json-c

Although, the `pkg_check_modules` function is used when finding the
json-c library, the results are never used. Let's add the `HINTS` params
for the `find_path` and `find_library` functions.
This commit is contained in:
Ondrej Holy 2024-05-15 15:31:22 +02:00 committed by akallabeth
parent 9aca06e0b7
commit 15c78a27f2
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5

View File

@ -7,18 +7,21 @@
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_JSON json-c)
pkg_check_modules(PC_JSONC json-c)
endif()
find_path(JSONC_INCLUDE_DIR NAMES json-c/json.h json/json.h)
find_library(JSONC_LIBRARY NAMES json-c)
find_path(JSONC_INCLUDE_DIR NAMES json.h
HINTS ${PC_JSONC_INCLUDE_DIRS}
PATH_SUFFIXES json-c)
find_library(JSONC_LIBRARY NAMES json-c
HINTS ${PC_JSONC_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JSONC DEFAULT_MSG JSONC_LIBRARY JSONC_INCLUDE_DIR)
if(JSONC_FOUND)
set(JSONC_LIBRARIES ${JSONC_LIBRARY})
set(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR}/json-c)
set(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR})
endif()
mark_as_advanced(JSONC_LIBRARY JSONC_INCLUDE_DIR)