From d5baeff85f9a5b6b1733d30a0e1b835b13ea458d Mon Sep 17 00:00:00 2001 From: Paulo Antonio Alvarez Date: Mon, 17 Oct 2016 22:12:12 -0200 Subject: [PATCH] Add pkg-config file support for libcjson We configure and install a pkg-config file so that our compilation and linking flags can be more easily found using pkg-config. --- CMakeLists.txt | 8 ++++++++ libcjson.pc.in | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 libcjson.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 049f895..0f0ddd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ set(CJSON_VERSION "${CJSON_VERSION_MAJOR}.${CJSON_VERSION_MINOR}.${CJSON_VERSION add_compile_options(-ansi -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings) +#variables for pkg-config +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(libdir "${CMAKE_INSTALL_PREFIX}/lib") + #cJSON set(PROJ_CJSON cJSON) set(CJSON_LIB cjson) @@ -22,8 +26,12 @@ if (NOT WIN32) target_link_libraries(${CJSON_LIB} m) endif() +configure_file("${cJSON_SOURCE_DIR}/libcjson.pc.in" + "${cJSON_BINARY_DIR}/libcjson.pc" @ONLY) + install(TARGETS ${CJSON_LIB} DESTINATION lib${LIB_SUFFIX}) install(FILES cJSON.h DESTINATION include/cjson) +install (FILES ${cJSON_BINARY_DIR}/libcjson.pc DESTINATION lib/pkgconfig) set_target_properties(${CJSON_LIB} PROPERTIES diff --git a/libcjson.pc.in b/libcjson.pc.in new file mode 100644 index 0000000..e04d5ee --- /dev/null +++ b/libcjson.pc.in @@ -0,0 +1,9 @@ +prefix=@prefix@ +libdir=@libdir@ +includedir=${prefix}/include/cJSON + +Name: libcJSON +Version: 1.0 +Description: Ultralightweight JSON parser in ANSI C +Libs: -L${libdir} -lcJSON +Cflags: -I${includedir}