From 199bca2f54dbdef0cf4e7897563b97416db2b372 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 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 | 6 ++++++ libcJSON.pc.in | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 libcJSON.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c1e8d5..f5c3922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,12 +33,18 @@ add_library(${PROJ_CJSON_UTILS}.shared SHARED ${HEADERS_UTILS} ${SOURCES_UTILS}) set_target_properties(${PROJ_CJSON_UTILS}.shared PROPERTIES OUTPUT_NAME cJSON_utils) target_link_libraries(${PROJ_CJSON_UTILS}.shared ${PROJ_CJSON}.shared) +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(libdir "${CMAKE_INSTALL_PREFIX}/lib") +configure_file("${cJSON_SOURCE_DIR}/libcJSON.pc.in" + "${cJSON_BINARY_DIR}/libcJSON.pc" @ONLY) + install (TARGETS ${PROJ_CJSON} DESTINATION lib${LIB_SUFFIX}) install (TARGETS ${PROJ_CJSON}.shared DESTINATION lib${LIB_SUFFIX}) install (FILES cJSON.h DESTINATION include/cJSON) install (TARGETS ${PROJ_CJSON_UTILS} DESTINATION lib${LIB_SUFFIX}) install (TARGETS ${PROJ_CJSON_UTILS}.shared DESTINATION lib${LIB_SUFFIX}) install (FILES cJSON_Utils.h DESTINATION include/cJSON) +install (FILES ${cJSON_BINARY_DIR}/libcJSON.pc DESTINATION lib/pkgconfig) option(ENABLE_CJSON_TEST "Enable building cJSON test" OFF) if(ENABLE_CJSON_TEST) 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}