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
VDT Finding Fix, master branch (2023.12.05.) #14178
VDT Finding Fix, master branch (2023.12.05.) #14178
Conversation
This way, a default location would be provided for VDT, which the user could still override if they wanted to.
Starting build on |
Build failed on windows10/default. Errors:
|
Thanks a lot for the PR! Side note: to fully fix the linked issue, I think we also need something similar for when nlohmanjson is builtin. Maybe @linev knows more. |
Thanks a lot, @krasznaa, for the quick fix.
Strangely enough, with that policy set it works for me with and without your fix, maybe because we already set $ROOT_ROOT in the build environment. Do I understand it correctly that your fix covers the case where ROOT is discovered via $ROOT_DIR only? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks Attila!
@@ -108,6 +108,9 @@ if(ROOT_minuit2_omp_FOUND) | |||
find_dependency(Threads) | |||
endif() | |||
if(ROOT_vdt_FOUND AND NOT TARGET VDT::VDT) | |||
if(ROOT_builtin_vdt_FOUND) | |||
set(Vdt_ROOT "${_thisdir}/.." CACHE PATH "Location of (the builtin) VDT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 102, we could add sth along this line: else() set (nlohmann_json... "${_thisdir}/.." CACHE PATH "Location of (the builtin) nlohmann-json")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that we need special rule here for builtin nlohmann/json.hpp
.
Only when external nlohmann_json
is used, it linked as PUBLIC
dependency and need to be there when
correspondent library linked by user application. This is how it defined in REve:
if(builtin_nlohmannjson)
target_include_directories(ROOTEve PRIVATE ${CMAKE_SOURCE_DIR}/builtins)
else()
target_link_libraries(ROOTEve PUBLIC nlohmann_json::nlohmann_json)
endif()
So to say - builtin version should not be seen by user cmake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @linev, but find_package (ROOT) fails (using ubu22 binary release) because it does not find where nlohmann json is, even if I do not need nlohman_json at all in my software.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to understand that kind of changes you want to have for nlohmann_json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😕 Have a look at line 100-102. The logic is actually the opposite for nlohmann_json. CMake only calls find_dependency(nlohmann_json...)
if it's not built-in. For a built-in nlohmann_json the CMake setup does nothing. As it expects that the normal ROOT include path would make the nlohmann/json.hpp
file visible as well. 🤔
But this also means that apparently the binary downloaded by @ferdymercury does not have nlohmann_json included in it. If it did, ROOT would not be looking for it.
Long story short, I didn't think that we needed to do anything with the JSON dependency. Also because that's not something that would've changed recently. I only modified how VDT is handled in 6.30. The JSON dependency did not change wrt. 6.28 as far as I can see. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For adding some info, here a 'diff' of old 6.28 and new 3.30 ROOT versions wrt nlohmann:
grep -r nlohmann_json /tmp/oldroot/*
/tmp/oldroot/cmake/ROOTConfig.cmake: find_dependency(nlohmann_json 3.10.5)
/tmp/oldroot/include/nlohmann/json.hpp:#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
/tmp/oldroot/include/nlohmann/json.hpp:#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
/tmp/oldroot/include/nlohmann/json.hpp: friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
/tmp/oldroot/include/nlohmann/json.hpp: friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
/tmp/oldroot/include/nlohmann/json.hpp: inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
/tmp/oldroot/include/nlohmann/json.hpp: inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
grep: /tmp/oldroot/lib/ROOTDataFrame.pcm: binary file matches
/tmp/oldroot/README/ReleaseNotes/v628/index.md:* [[#11236](https://github.com/root-project/root/issues/11236)] - build failure because of `nlohmann_json`
grep -r nlohmann_json /tmp/newroot/*
/tmp/newroot/cmake/ROOTConfig-targets.cmake: INTERFACE_LINK_LIBRARIES "ROOT::Core;ROOT::Geom;ROOT::Physics;ROOT::EG;ROOT::TreePlayer;ROOT::RCsg;ROOT::ROOTWebDisplay;nlohmann_json::nlohmann_json"
/tmp/newroot/cmake/ROOTConfig-targets.cmake: INTERFACE_LINK_LIBRARIES "nlohmann_json::nlohmann_json"
/tmp/newroot/cmake/ROOTConfig.cmake: find_dependency(nlohmann_json 3.10.5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I myself would re-write the JSON dependency handling in the same way as VDT is handled now... But that we should do in a separate PR.
And yes, it very much seems that in the 6.30 binary builtin_nlohmannjson
was turned off for some reason. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to understand that kind of changes you want to have for
nlohmann_json
?
Hmmm, I would like to use find_package(ROOT)
with binary release 6.30.02 without forcing me to install nlohmann_json externally. (Or if I do need to install externally, then mention that in the prerequisites website).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yes, it very much seems that in the 6.30 binary
builtin_nlohmannjson
was turned off for some reason. 🤔
Oh, I see. The same happened with builtin_afterimage. If this was done on purpose, then we should add nlohmann_json to the prerequisites, as I did with afterimage: https://github.com/root-project/web/pull/936/files
This is a very good point. 🤔 Indeed, this update still requires Still. Since one may use |
While ROOT already requires CMake >= 3.12, I guess as of 6.30 it requires that any projects depending on ROOT also need to require 3.12 as a minimum (or set the policy explicitly) (regardless of what the CMake version actually is). Not sure whether this is documented somewhere, at least to me it wasn't 100% obvious. A lot of packages don't seem to define a minimum version at all... |
It is indeed a requirement for the users. The way that CMake works, even if you use the very latest CMake version, if your code has let's say cmake_minimum_required(VERSION 3.10) in it, then CMake will try to behave exactly like version 3.10 did. To have Now... One could add |
Maybe if we depend on this behaviour to find VDT, we could set only 0074 in the ROOTConfig.cmake? (can we unset it at the end of the ROOTConfig.cmake?) |
Starting build on |
So, I added an attempt for doing this in the least invasive way. 🤔 With this latest setting, the configuration cmake_minimum_required(VERSION 3.10)
project(ROOTFindTester VERSION 0.0.1 LANGUAGES CXX)
find_package(ROOT 6.30 CONFIG REQUIRED) succeeds.
Wile previously it failed.
|
Build failed on windows10/default. Errors:
|
OK I merge this and then we'll see. And for |
This Pull request:
Explicitly set
Vdt_ROOT
whenbuiltin_vdt
was used for the build. This way, a default location would be provided for VDT, which the user could still override if they wanted to.Changes or fixes:
This fixes the issue reported in #14163. Following up from the changes introduced in #11844.
Note that this fix requires CMake 3.12+, with CMP0074 set to
NEW
. 🤔 Supporting older CMake versions, or that policy set toOLD
would also be possible, but would require a lot more lines of code. (FindVdt.cmake
would need to learn about a new hint variable itself.)Still, if people here feel very strongly about it, it would be possible to go that route as well. 🤔
Checklist:
This PR fixes: #14163