From 29bb435eccdb59b9b3966d2769b45ff4bfbcb7d8 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Tue, 30 Apr 2024 15:49:46 +0200 Subject: [PATCH] [cmake] add JSON library find modules * Add module for cJSON * Add module for json-c --- cmake/FindJSONC.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cmake/FindJSONC.cmake diff --git a/cmake/FindJSONC.cmake b/cmake/FindJSONC.cmake new file mode 100644 index 000000000..bb0d19464 --- /dev/null +++ b/cmake/FindJSONC.cmake @@ -0,0 +1,24 @@ +# - Try to find JSON-C +# Once done this will define +# +# JSONC_FOUND - JSON-C was found +# JSONC_INCLUDE_DIRS - JSON-C include directories +# JSONC_LIBRARIES - libraries needed for linking + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_JSON json-c) +endif() + +find_path(JSONC_INCLUDE_DIR NAMES json-c/json.h json/json.h) +find_library(JSONC_LIBRARY NAMES json-c) + +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) +endif() + +mark_as_advanced(JSONC_LIBRARY JSONC_INCLUDE_DIR)