-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
Use of JSON_DIAGNOSTICS through CMake and find_package() #3106
Comments
I am not maintaining the formula myself, and I have no idea how to fix this. |
I'd like to take a crack at resolving this issue. I've begun to look at the cmake files for this project which is where I think we can resolve this issue. |
The issue here does not seem to be related to Homebrew. Overriding these values in client code may be done as follows: add_executable(foo main.cpp)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES INTERFACE_COMPILE_DEFINITIONS "JSON_DIAGNOSTICS=1;JSON_USE_IMPLICIT_CONVERSIONS=1")
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) @psalvaggio this should resolve your issue and I believe it does not merit a code change. Please correct me if I'm wrong. |
@nlohmann I believe this issue can be closed. Please advise. |
That's essentially how I have solved the issue on my end. Overwriting properties on imported targets generally isn't idiomatic in CMake. I think probably the desired solution would be something like: set(JSON_DIAGNOSTICS 1) # probably needs to be a cache variable
find_package(nlohmann_json)
# nlohmann_json::nlohmann_json now has the correct value in INTERFACE_COMPILE_DEFINITIONS I could probably take a swing at this over the weekend. |
@psalvaggio did you manage to come up with a fix for this as per your desired solution? |
Not yet, I had some higher priority tasks come up over the weekend. It should be pretty easy, just a defining a cache variable with the current hardcoded value as the default and replacing the 1's with the cache variable. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@nitul1991 I have tried your solution, but there is a build error: Okay, this is because I use the json library twice, once in a library, and once in a depending executable. |
I would like to use the JSON_DIAGNOSTICS feature to produce better error messages. I am using the library through Homebrew and in the Targets.cmake file, there is the following:
so this is hard-coded to be off. I can fix this by undoing in in my code, but it would be nice if we could have control over these parameters via some CMake variables, similar to how you can pass hints to some other CMake packages.
I am using Version 3.10.4 installed through Homebrew.
The text was updated successfully, but these errors were encountered: