root
root copied to clipboard
[CMake] Move towards target-based CMake and partly fix picking up headers from an installed ROOT
Partial fix of #8708. In a setup where ROOT was installed in a system directory, ROOT was picking up headers from that directory instead of its own.
How to reproduce:
echo '#error This is the wrong header' > /my/include/directory/RooSpan.h(or a few other headers).- Install some builtins into that directory, e.g. VDT
cmake -DCMAKE_PREFIX_PATH=/my/include/directory/ <root>to create a dependency to that include directory.- Build.
The problem only becomes visible when A depends on B and C, and B depends on something in /system/include/, and C is installed in those system includes as well. This generates a compile command such as:
-I.../core/x -I.../core/y -I.../core/... -I.../A/include -I.../B/include -I/system/include/ -I.../C/include ...
In this PR:
- Includes for VDT and XROOTD are fixed by making them
IMPORTED SYSTEMtargets, so their includes have lowest precedence. - Some cheating where include directories are copied around between targets is removed. CMake should handle this.
- Some dependency and target management is simplified (or rather modernised with target-based cmake)
- A broken dependency in RooFit is fixed, which was previously hidden by the cheating with include directories.
- Teach cling to deal with
-isystem(https://its.cern.ch/jira/browse/ROOT-10414)
What remains to be done:
It is likely that more builtins (or rather FindXXX have to be converted to IMPORTED targets, so they don't provoke this error again. A broken configuration can be detected by
- Having CMake pick up a dependency in some common directory
- Either
- Placing a lot of
#error-ROOT headers in there or - Searching
compile_commands.jsonfor-I/my/include/directory/
- Fixing the
FindXXXfor this dependency.
Can the roofit part be split into a dedicated PR / removed here?
Can the roofit part be split into a dedicated PR / removed here?
Yes, partly. I pushed the tutorial part by mistake (and removed it here). The CMake-related things in RF need to stay here.
Test Results
2 files 2 suites 21h 0m 41s ⏱️ 2 675 tests 2 675 ✅ 0 💤 0 ❌ 5 325 runs 5 325 ✅ 0 💤 0 ❌
Results for commit 4026295b.
:recycle: This comment has been updated with latest results.
Timeout - too late for 6.30.00
Removing the 6.32 milestone, as this change is too big for making it into the release. But at least we'll have it for the next one :slightly_smiling_face:
Hi Jonas,
thanks for looking into this, but at the moment there is no need for you to rebase. I rebase those commits every once in a while, so I will push the latest-greatest stuff soon when I'm done with a few other tasks. 🙂
Awesome, thanks for commenting! Then I'll stop messing with this PR.
Note that I already merged some of your commits, because there were other big changes for XRootD in the build system already: https://github.com/root-project/root/pull/14901
Note that I already merged some of your commits, because there were other big changes for XRootD in the build system already:
OK, no problem, that will solve itself during a rebase!
External tests are running:
- https://gitlab.cern.ch/sft/lcgcmake/-/merge_requests/2813
- https://github.com/cms-sw/root/pull/219