cmake unable to report INCLUDE_DIRS and LIBRARIES

Bug #1653635 reported by Halton Huo
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libjsoncpp (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

$ dpkg -l|grep libjsoncpp
ii libjsoncpp-dev:amd64 1.7.2-1 amd64 library for reading and writing JSON for C++ (devel files)
ii libjsoncpp1:amd64 1.7.2-1 amd64 library for reading and writing JSON for C++

When try to use jsoncpp, the ${jsoncpp_INCLUDE_DIRS} and ${jsoncpp_LIBRARIES} fail to report.

CMakeLists.txt
----------------
cmake_minimum_required(VERSION 2.6.2)
project(jsoncpp_test)

find_package(jsoncpp REQUIRED)
message("FOUND CONFIG: ${jsoncpp_CONFIG}")
message("INCLUDE DIRS: ${jsoncpp_INCLUDE_DIRS}")
message("LIBRARIES: ${jsoncpp_LIBRARIES}")

The actual result is:
--------------------
FOUND CONFIG: /usr/lib/x86_64-linux-gnu/cmake/jsoncpp/jsoncppConfig.cmake
INCLUDE DIRS:
LIBRARIES:

Tags: xenial
tags: added: xenial
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libjsoncpp (Ubuntu):
status: New → Confirmed
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Hello, as workaround, using pkg-config to detect it should work
pkg_search_module(JSONCPP jsoncpp)

Revision history for this message
Timo Röhling (roehling) wrote :

The CMake config exports the `jsoncpp_lib` and `jsoncpp_static` targets, which will automatically perform all required settings when used with `target_link_libraries()`. Manually setting the include paths and link libraries is an anti-pattern.

Changed in libjsoncpp (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.