Repository navigation
tests fail: cannot find -lnlohmann_json #101
Description
Activity
nlohmann_jsonis an optional dependency but is still required for the test target.This was reported earlier this week. We should either specify that it is required for the test target or skipp the corresponding tests when missing.
... or skipp the corresponding tests when missing.
It is always missing as a .so library, because it is a headers-only library.
I don't think so. This is just that when it does not find a target, cmake assumes that you are trying to link with a library.
Why can't it find the target?
nlohmann-json-3.1.2is installed.@yurivict Any chance you installed
nlohmann-jsonfrom themasterbranch? Thenlohmann-jsonproject adapted it's targets to the more modern namespaced style with this PR nlohmann/json#1048 . However there has been no release since then. The travis etc. tests work because they use the targetnlohmann-json(from version 3.1.2) if you pull from the master branch you need to link against the new targetnlohmann_json::nlohmann_json. I've got an upcomming PR that fixes those issues.nlohmann-jsonis of version3.1.2.Are you building from the
xtlroot project? Or are you building in thetestsubdirectory? There is another bug in the relatedCMakeLists.txtwhere it won't try to find thenlohmann_jsonpackage, will also be fixed with the PR.Building in the
testsubdirectory.That'll be the issue, you could try changing
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) project(xtl-test) find_package(xtl REQUIRED CONFIG) set(XTL_INCLUDE_DIR ${xtl_INCLUDE_DIRS}) endif ()
in
CMakeLists.txttoif (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) project(xtl-test) find_package(xtl REQUIRED CONFIG) find_package(nlohmann_json QUIET) set(XTL_INCLUDE_DIR ${xtl_INCLUDE_DIRS}) endif ()
That'll be the issue, you could try changing ...
This helped, thank you!
nlohmann-jsonis a headers-only library:and there should never be
-lnlohmann_jsonfor it.