Skip to content
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

Could not find a package configuration file provided by "nlohmann_json" #2482

Closed
GorrieXIV opened this issue Nov 27, 2020 · 2 comments
Closed

Comments

@GorrieXIV
Copy link

Hi there,

Really excited to start using this library in my project, but running into this issue while trying to build.

I've specified nlohmann_json/3.9.1 in my conanfile, which is found and installed without issue when running conan install. I then have the following snippet in my CMakeLists.txt:

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

Set(nlohmann_json_INSTALL_DIR ${CONAN_NLOHMANN_JSON_ROOT})
find_package(nlohmann_json 3.9.1 REQUIRED)

This is the exact same way I pull in Boost in a different project, however when running cmake, conan_basic_setup() runs without issue, which sets CONAN_NLOHMANN_JSON_ROOT, but then the script fails on find_package with the following output:

CMake Error at CMakeLists.txt:30 (find_package):
By not providing "Findnlohmann_json.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"nlohmann_json", but CMake did not find one.

Could not find a package configuration file provided by "nlohmann_json"
(requested version 3.9.1) with any of the following names:

nlohmann_jsonConfig.cmake
nlohmann_json-config.cmake

Add the installation prefix of "nlohmann_json" to CMAKE_PREFIX_PATH or set
"nlohmann_json_DIR" to a directory containing one of the above files. If
"nlohmann_json" provides a separate development package or SDK, be sure it
has been installed.

-- Configuring incomplete, errors occurred!

Is there some merit to the recommendation in this error? I shouldn't need to change CMAKE_PREFIX_PATH.

Please advise if I am doing something wrong or if there may be a less obvious issue at hand. Thanks!

@k-styles
Copy link

@GorrieXIV Have you written a cmake file for this? If yes, can you provide it over here,

@falbrechtskirchinger
Copy link
Contributor

Have you checked the documentation?
https://json.nlohmann.me/integration/package_managers/#conan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants