-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of the jsoncpp CMake package #455
Comments
I've managed to make it work like this find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)
link_libraries(${JSONCPP_LIBRARIES})
add_executable(myprogram myprogram.cpp)
target_link_libraries(myprogram ${JSONCPP_LIBRARIES}) |
Thanks, Max Headroom. Update the wiki too, if you want. |
thanks @arrufat #include <jsoncpp/json/json.h> right? Does that mean the code is not portable in the sense that if will only compile if run on a distri that packages the headers in this way? |
Yes, I had exactly this issue with Arch Linux and Ubuntu... |
Thanks for the quick response. I've just seen that you can add the discovered include path with
in |
The You need to query the target property and set it manually: get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH}) Linking is done via: target_link_libraries(${PROJECT_NAME} jsoncpp_lib) |
@christian-rauch , If you submit a PR, we'll merge it. We don't maintain the Cmake files anymore; users do that. We use only the Meson files ourselves. |
@cdunn2001 The code snippet that I mentioned has to be used on the user side, e.g. an application that wants to use jsoncpp. If someone is interested in making the usage of jsoncpp in CMake projects easier, there is a way to export header and libraries in such a way that an application can just import the library without dealing with include directories and libraries manually: https://rix0r.nl/blog/2015/08/13/cmake-guide/ |
Thanks. Updated our Wiki. If you submit the change to simplify Cmake, we'd merge it. |
I'm trying to use jsoncpp via |
Did you figured it out ? |
Hi I'm using mac os x(installed jsoncpp using
|
I can't work out how to include this library when installed on Ubuntu 22.04. I've tried the version in the wiki, the one above, and a method I found on stackoverflow. |
From the CMake docs: https://cmake.org/cmake/help/latest/module/FindPkgConfig.html#command:pkg_check_modules
Please switch this: pkg_check_modules(JSONCPP jsoncpp)
target_link_libraries(
utils
${JSONCPP_LINK_LIBRARIES}
) for this: pkg_check_modules(JSONCPP jsoncpp IMPORTED_TARGET GLOBAL)
target_link_libraries(
utils
PkgConfig::JSONCPP
) |
"they" do not maintain the CMake scripts so this will be fun open-source-parsers/jsoncpp#455 (comment)
* Implemented JsonCPP Traits * quick pass to add CI * correct find_packge to use config and not be required * typo in default version * jsoncpp forces out of source builds * disable tests and shared library * add missing build step * try a different target + build less "they" do not maintain the CMake scripts so this will be fun open-source-parsers/jsoncpp#455 (comment) * fix name for traits (missed replaces) * Added missing array_type constructor so that basic_claims can be formed from sets of values * Linters and more tests + fetchcontent gtest * linter * support library names with many separators * linters * run clang format after rendering defaults --------- Co-authored-by: Chris Mc <[email protected]>
Dear jsoncpp developers,
I tried to use the CMake package built by
jsoncpp
(and provided bylibjsoncpp-dev
on Debian / Ubuntu) on a CMake project depending on it.I tried the following discovery via CMake config mode:
But it does not seem to work. I then ran the the following test:
which produced the following output:
meaning the CMake package file is found but none of the expected variables is set.
How are we expected to discover and use
jsoncpp
under CMake then? FYI, using pkg-config works fine, but is not what I would consider a solution.Many thanks,
Ghis
The text was updated successfully, but these errors were encountered: