Skip to content

Commit

Permalink
cmake/json: Remove find_package call. Use pkg-config instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkaraman committed Jan 28, 2025
1 parent 532744e commit 99d36df
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/modules/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ file(GLOB MODULE_SOURCES "*.c")

add_library(${module_name} SHARED ${MODULE_SOURCES})

find_package(json-c CONFIG)

if(NOT json-c_FOUND)
message(STATUS "json-c not found. looking with pkg-config")
find_package(PkgConfig REQUIRED)
pkg_check_modules(json-c REQUIRED IMPORTED_TARGET json-c)
add_library(json-c::json-c ALIAS PkgConfig::json-c)
endif()
# TODO: When we have a proper cmake config file for json-c for most OS, we can
# use that instead of pkg-config.
# json-c v 0.14 and 0.15 have wrong include directories in their cmake config
# files. uncomment the following line when we have a proper cmake config file
# for json-c for most OS.
# find_package(json-c 0.16 CONFIG)

# if(NOT json-c_FOUND)
message(STATUS "json-c not found. looking with pkg-config")
find_package(PkgConfig REQUIRED)
pkg_check_modules(json-c REQUIRED IMPORTED_TARGET json-c)
add_library(json-c::json-c ALIAS PkgConfig::json-c)
# endif()

target_link_libraries(${module_name} PRIVATE json-c::json-c)

0 comments on commit 99d36df

Please sign in to comment.