root icon indicating copy to clipboard operation
root copied to clipboard

[CMake] Move towards target-based CMake and partly fix picking up headers from an installed ROOT

Open hageboeck opened this issue 4 years ago • 10 comments

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:

  1. echo '#error This is the wrong header' > /my/include/directory/RooSpan.h (or a few other headers).
  2. Install some builtins into that directory, e.g. VDT
  3. cmake -DCMAKE_PREFIX_PATH=/my/include/directory/ <root> to create a dependency to that include directory.
  4. 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 SYSTEM targets, 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

  1. Having CMake pick up a dependency in some common directory
  2. Either
  • Placing a lot of #error-ROOT headers in there or
  • Searching compile_commands.json for -I/my/include/directory/
  1. Fixing the FindXXX for this dependency.

hageboeck avatar Jul 21 '21 14:07 hageboeck

Can the roofit part be split into a dedicated PR / removed here?

Axel-Naumann avatar Feb 10 '23 15:02 Axel-Naumann

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.

hageboeck avatar Feb 10 '23 15:02 hageboeck

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.

github-actions[bot] avatar Mar 23 '23 15:03 github-actions[bot]

Timeout - too late for 6.30.00

Axel-Naumann avatar Oct 13 '23 13:10 Axel-Naumann

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:

guitargeek avatar May 21 '24 23:05 guitargeek

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. 🙂

hageboeck avatar May 22 '24 12:05 hageboeck

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

guitargeek avatar May 22 '24 12:05 guitargeek

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!

hageboeck avatar May 22 '24 14:05 hageboeck

External tests are running:

  • https://gitlab.cern.ch/sft/lcgcmake/-/merge_requests/2813
  • https://github.com/cms-sw/root/pull/219

hageboeck avatar Feb 26 '25 16:02 hageboeck