-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[CMake] Don't use find_package(ROOT REQUIRED) in test/ subdirectory
#20640
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
base: master
Are you sure you want to change the base?
Conversation
dfdc11a to
62d7351
Compare
cmake/modules/RootNewMacros.cmake
Outdated
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.
Is it necessary to remove this file? Could it be possible that someone in the world is still using it? Should we perhaps change the deprecation message to specify a ROOT release when this will be removed?
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.
Not strictly necessary, but it's a bit confusing to keep as it's called RootNewMacros.cmake, with "New" in the name, but deprecated and replaced by RootMacros.cmake without "New". I would like to keep confusing situations like this behind for good.
Users will have seen the deprecation message for 6 years now. I think people will understand if we remove it now.
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 you think this is controversial, I can bring it forward in a separate PR!
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.
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.
...only if it exists 🙂 Otherwise, they automatically get the new RootMacros.cmake via the find_package(ROOT REQUIRED) before in the file. So they actually to the right thing, to even be backwards compatible with ROOT before 6.20.
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.
Oh right, sorry, I overlooked at it...
Test Results 22 files 22 suites 3d 19h 46m 25s ⏱️ Results for commit 994c94c. ♻️ This comment has been updated with latest results. |
| # This shows nicely how to compile and link applications | ||
| # using the ROOT libraries on all supported platforms. |
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.
Can we update the PR description and commit log on where we now document and/or demonstrate the modern way to build you application that uses ROOT?
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.
Well, anywhere where we use ROOT_EXECUTABLE or ROOT_STANDARD_LIBRARY_PACKAGE I guess? I don't see what made this test/CMakeLists.txt a good place "to show nicely how to compile and link applications using the ROOT libraries on all supported platforms". That comment seemed pretty random to me.
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.
Rather than random, it is historical. Once upon a time, this was a tidy smallish standalone (Makefile then CMake) example that build dictionaries, libraries and executables that use ROOT. I can see that over time we drifted away from that (seemingly breaking the standalone part and getting a bit complex). However unless (but I assume we actually do have one) we have a replacement documentation, then this would be the closest we have to a documentation. (If we don't have the documentation and nice examples, then this PR can still proceed but we need to open an issue to remind us to write that documentation).
Well, anywhere where we use ROOT_EXECUTABLE or ROOT_STANDARD_LIBRARY_PACKAGE
Humm .. that does not sound enough, it also needs at least the call to find_package(ROOT) and a good set of usage of the CMake function we recommend using. i.e. enough for a CMake beginner to get started.
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.
Okay, I see now! The entry-point documentation for using ROOT via CMake is here now:
https://root.cern/manual/integrate_root_into_my_cmake_project/#full-example-event-project
Do you see anything missing from there? I think it's good that we advocate the custom macros like ROOT_EXECTUABLE too much, and instead show how to use standard CMake, just like the example on the website does.
test/CMakeLists.txt
Outdated
| if(mathmore) | ||
| list(APPEND stress_hist_fit_extra_libs MathMore) | ||
| endif() |
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.
Why is this now needed?
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.
Because of this conditional include here:
https://github.com/root-project/root/blob/master/math/mathcore/inc/Math/DistFunc.h#L39
But let me try to replace this include
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.
That include was already there before this PR, so why don't we need the dependency before ...
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.
Same reason as #20640 (comment)
| ROOT_GENERATE_DICTIONARY(G__TBench ${CMAKE_CURRENT_SOURCE_DIR}/TBench.h MODULE TBench LINKDEF benchLinkDef.h DEPENDENCIES MathCore Tree) | ||
| ROOT_LINKER_LIBRARY(TBench TBench.cxx G__TBench.cxx LIBRARIES Core MathCore RIO Tree) | ||
| ROOT_EXECUTABLE(bench bench.cxx LIBRARIES Core TBench) | ||
| ROOT_EXECUTABLE(bench bench.cxx LIBRARIES Core TBench RIO) |
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.
Why is RIO needed/wanted when it wasn't before?
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.
Before, we implicitly linked all main ROOT libraries via find_package(ROOT REQUIRED). But I want to avoid calling that when building ROOT itself, as that seems pretty weird to me. So now, we have to link all required libraries explicitly.
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.
But I want to avoid calling that when building ROOT itself
+1
we implicitly linked all main ROOT libraries via find_package(ROOT REQUIRED)
humm ... what? ... If I read that correctly (probably didn't), this would be mean that for any user of find_package(ROOT) "all" their libraries would linked against libCore and friends? i.e. Can you remind what is the side effect of find_package that make the dependency on RIO (and apparently mathMore) optional/redundant?
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.
You are right, that sounds like it can't be true. I looked into it again, and I think I found the real reason:
https://github.com/root-project/root/blob/master/cmake/modules/RootMacros.cmake#L1420
if(NOT (PROJECT_NAME STREQUAL "ROOT"))
# only for non-ROOT executable use $ROOTSYS/include
include_directories(BEFORE ${CMAKE_BINARY_DIR}/include)So it was the removal of project(test) in this PR that resulted ${CMAKE_BINARY_DIR}/include in not being appended anymore, and this is why the include directories need to be explicitly added per package via the CMake target_link_library mechanism.
Has been deprecated since ROOT 6.20 and can now be removed.
62d7351 to
c2d7c6c
Compare
As Sergey said in the comment in `test/CMakeLists.txt`, this test project stopped working standalone. But, it still uses `find_package(ROOT)` to find ROOT, even though it's not installed yet as we are building ROOT itself at the same time. Apparently that works, and sets the flags like `ROOT_opengl_FOUND`, but we should not rely on this and use the build-time configuration flags instead.
c2d7c6c to
994c94c
Compare
|
@pcanal, I addressed all your inline comments |
As Sergey said in the comment in
test/CMakeLists.txt, this testproject stopped working standalone. But, it still uses
find_package(ROOT)to find ROOT, even though it's not installed yet aswe are building ROOT itself at the same time.
Apparently that works, and sets the flags like
ROOT_opengl_FOUND, butwe should not rely on this and use the build-time configuration flags
instead.