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

Cmake target_link_libraries unable to find nlohmann_json since version 3.2.0 #1243

Closed
SylvainCorlay opened this issue Sep 18, 2018 · 6 comments
Assignees
Milestone

Comments

@SylvainCorlay
Copy link

SylvainCorlay commented Sep 18, 2018

We updated from 3.1.2 to 3.2.0. The update causes the target_link_libraries cmake command to not properly include nlohmann_json, while find_package(nlohmann_json REQUIRED) did not result in an error.

After some investigation, it seems that the issue was the addition of namespaces to target names which is a backward incompatible change.

@SylvainCorlay
Copy link
Author

cc @chuckatkins.

@nlohmann
Copy link
Owner

Thanks for reporting and sorry for the inconvenience!

The change that introduced the namespace was introduced by @chuckatkins in #1048, and I assumed that the change is fine given that Chuck is with Kitware. Maybe he can comment on the reasons for adding a namespace as I apparently did not understand the repercussions of the change.

@SylvainCorlay
Copy link
Author

Yes, this is good cmake practice. Just giving a heads up because it is a breaking change for anyone using cmake to build against nlohmann_json.

@chuckatkins
Copy link
Contributor

Indeed sorry about the breaking change. The namespace was to transition to more modern CMake practices if namespaced target names being external and non-namespaced target names being "local". Ideally, you'll want to transition to using the namespaced target name when consuming it externally through the config file. In the meantime though, I think I have a quick workaround that can provide both.

@chuckatkins
Copy link
Contributor

I'll put a version check in place so it's treated as a backward compatibility thing. That way if someone calls find_package(nlohmann_json) then both targets will get pulled in but if they call find_package(nlohmann_json 3.2.0) then it will only be the namespaced target. @SylvainCorlay would that work for you?

@SylvainCorlay
Copy link
Author

On our side we started requiring 3.2.0 and adopting the new syntax, so it is not necessary for us. Maybe a note in the release notes?

I maintain the conda package and we have patched some recipes that depend on it to pin on 3.1.2.

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

No branches or pull requests

3 participants