[CMake] Only replace `find_package` if required
This is a replay of #16274 with the "clear build" label for the CI, to see if we can reproduce the build error that were observed after merging said PR
Our CMake code modifies find_package to ignore any ROOT builtins, such that the builtin LLVM doesn't find and use system versions of the builtin dependencies.
This is a bit hacky, but fortunately this needs to be done only when builtins are used.
Therefore, this commit suggests to only do this redefinition of find_package if any builtins are used.
This closes #8633, where it was requested to avoid this hack for the sake of being compatible with the vcpkg package manager.
Although the hack is not completely removed, it is removed for the case where not builtins are used, which is probably what is done when using a C++ package manager to manage dependencies.
Test Results
16 files 16 suites 4d 0h 45m 22s ⏱️ 2 724 tests 2 722 ✅ 1 💤 1 ❌ 41 351 runs 41 350 ✅ 0 💤 1 ❌
For more details on these failures, see this check.
Results for commit cd41d96c.
:recycle: This comment has been updated with latest results.
restarted the failing tests. The failures seemed unrelated.
Unfortunately, the failure on mac13 is not unrelated :(
At least we are left with that one only.
Rebasing and rerunning tests. It seems we are so close to have a mergeable version of this nice PR !