FindPkgConfig: Package found but fails to set some variables
I have tested two systems with the following:
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules (JSONCPP jsoncpp)
message("PKG_CONFIG_FOUND: ${PKG_CONFIG_FOUND}")
message("PKG_CONFIG_EXECUTABLE: ${PKG_CONFIG_EXECUTABLE}")
message("PKG_CONFIG_VERSION_STRING: ${PKG_CONFIG_VERSION_STRING}")
message("JSONCPP_FOUND: ${JSONCPP_FOUND}")
message("JSONCPP_LIBRARIES: ${JSONCPP_LIBRARIES}")
message("JSONCPP_LIBRARY_DIRS: ${JSONCPP_LIBRARY_DIRS}")
message("JSONCPP_LDFLAGS: ${JSONCPP_LDFLAGS}")
message("JSONCPP_LDFLAGS_OTHER: ${JSONCPP_LDFLAGS_OTHER}")
message("JSONCPP_INCLUDE_DIRS: ${JSONCPP_INCLUDE_DIRS}")
message("JSONCPP_CFLAGS: ${JSONCPP_CFLAGS}")
message("JSONCPP_CFLAGS_OTHER: ${JSONCPP_CFLAGS_OTHER}")
endif()
Output on Arch armv7 / cmake v3.10.0:
PKG_CONFIG_FOUND: TRUE
PKG_CONFIG_EXECUTABLE: /bin/pkg-config
PKG_CONFIG_VERSION_STRING: 0.29.2
JSONCPP_FOUND: 1
JSONCPP_LIBRARIES: jsoncpp
JSONCPP_LIBRARY_DIRS:
JSONCPP_LDFLAGS: -ljsoncpp
JSONCPP_LDFLAGS_OTHER:
JSONCPP_INCLUDE_DIRS:
JSONCPP_CFLAGS:
JSONCPP_CFLAGS_OTHER:
cat /usr/lib/pkgconfig/jsoncpp.pc
libdir=/usr/lib
includedir=/usr/include
Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.8.3
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}
Output on Ubuntu 16.04 x86_64 / cmake v3.5.1:
PKG_CONFIG_FOUND: TRUE
PKG_CONFIG_EXECUTABLE: /usr/bin/pkg-config
PKG_CONFIG_VERSION_STRING: 0.29.1
JSONCPP_FOUND: 1
JSONCPP_LIBRARIES: jsoncpp
JSONCPP_LIBRARY_DIRS:
JSONCPP_LDFLAGS: -ljsoncpp
JSONCPP_LDFLAGS_OTHER:
JSONCPP_INCLUDE_DIRS: /usr/include/jsoncpp
JSONCPP_CFLAGS: -I/usr/include/jsoncpp
JSONCPP_CFLAGS_OTHER:
cat /usr/lib/x86_64-linux-gnu/pkgconfig/jsoncpp.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=/usr/include/jsoncpp
Name: jsoncpp
Description: A C++ library for interacting with JSON
Version: 1.7.2
URL: https://github.com/open-source-parsers/jsoncpp
Libs: -L${libdir} -ljsoncpp
Cflags: -I${includedir}
It seems newer cmake is unable to get JSONCPP_INCLUDE_DIRS & JSONCPP_CFLAGS from pkg-config.