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

Test if json_fwd.hpp exists #8345

Merged
merged 1 commit into from
Jun 8, 2021
Merged

Conversation

linev
Copy link
Member

@linev linev commented Jun 4, 2021

On some platforms external nlohmann/json.hpp installed without
such special include. In this case full version has to be used.

Provide special define when compile EVE7 which indicates if
json_fwd.hpp can be used. In the macros such define is not
exported and therefore full version of nlohmann/json.hpp
will be used.

Better solution then #8343

@linev linev requested review from amadio, ellert and oshadura June 4, 2021 18:38
@linev linev self-assigned this Jun 4, 2021
@linev linev requested a review from osschar as a code owner June 4, 2021 18:38
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on mac1014/python3.
Running on macphsft17.dyndns.cern.ch:/build/jenkins/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu16/nortcxxmod.
Running on sft-ubuntu-1604-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Failing tests:

Copy link
Member

@amadio amadio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in my other comment, the default behavior when nothing is defined should be to include the full header. This is the more common way to handle issues like this and will work if for some reason whoever includes the header links without using the CMake target. That said, given the problem with installed nlohman_json not having the header, it's probably better not to try to include it at all.

@@ -18,7 +18,11 @@

#include <memory>

#ifdef MISSING_JSON_FWD_HPP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not work after ROOT is compiled when someone includes this header. The logic should probably be inverted (fallback to json.hpp should be default if nothing is defined), and MISSING_JSON_FWD_HPP should probably be HAVE_JSON_FWD_HPP and be generated in a header and used from there rather than added to the command line with -D as is being done now.

if(EXISTS "${dir}/nlohmann/json_fwd.hpp")
set(found_fwd true)
endif()
endforeach()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really worth it going to such great lengths just to avoid including the full header? I am beginning to think it's probably not.

On some platforms external nlohmann/json.hpp installed without
such special include. In this case full version has to be used.

Provide special define when compile EVE7 which indicates if
json_fwd.hpp can be used. In the macros such define is not
exported and therefore full version of nlohmann/json.hpp
will be used.
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@linev linev requested a review from amadio June 7, 2021 08:08
@linev
Copy link
Member Author

linev commented Jun 7, 2021

@amadio

I provide special define which enables usage of json_fwd.hpp include when it is found.
Means if such defines not exported correctly, full version will be used.

There was a reason why such "minified" version of json parser is used,
probably Matevz (@osschar) can comment on this.
And we prefer to keep using it.

@amadio
Copy link
Member

amadio commented Jun 7, 2021

Ok, this new way should work. However, it will only actually use the forward declaration header when building ROOT and when linking against ROOT using the CMake target. If one uses ${ROOT_LIBRARIES} (still common practice, unfortunately), the full header will be used. I still think this is more trouble than it's worth (speeding up compilation a bit), but should be fine to merge now, at least.

Copy link
Contributor

@osschar osschar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, yess, this is good!

@linev linev merged commit 1c38aa0 into root-project:master Jun 8, 2021
@linev linev deleted the json_fwd_fix branch June 8, 2021 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants