Repository: spack/spack

Issue:
[dd4hep] prepend_path ROOT_INCLUDE_PATH
Including the headers in ROOT_INCLUDE_PATH ensures that they are found by the cling autoloader. This avoids warnings such as:
```
Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState:
   Missing FileEntry for DDRec/ISurface.h
   requested to autoload type dd4hep::rec::ISurface
```
A similar approach is applied in [gaudi](https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/gaudi/package.py#L116).


Discussion:
It seems that this was previously working because Spack was populating the CPATH (which is also searched by root) for all packages, but it has since stopped (https://github.com/spack/spack/commit/e3f97b37e64d4de70baf8e58fcd747b021d8f2f9#diff-259adc895c0b2e8fca42ffb99d8051eec0712c868d12d8da255d32f1663acdc7). There will probably be a few more packages where explicitly setting the ROOT_INCLUDE_PATH is required
Thanks @vvolkl for identifying that. I was just wondering why this stopped working for me (typically I can attribute it to using views at `/usr/local`, so `/usr/local/include` easily ends up in the required search paths).

Maybe this is something that should go into ROOT's `setup_dependent_run_environment` (https://spack.readthedocs.io/en/latest/spack.html#spack.package.PackageBase.setup_dependent_build_environment) as
```
    def setup_dependent_build_environment(self, env, dependent_spec):
        #...
        env.prepend_path('ROOT_INCLUDE_PATH', dependent_spec.prefix.include)
```
I really like this suggestion - it will add a few packages that don't really need it to the ROOT_INCLUDE_PATH, but it will massively simplify the maintenance of the recipes for those that do. Could you add this to the ROOT recipe?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/gaudi/package.py b/var/spack/repos/builtin/packages/gaudi/package.py
--- a/var/spack/repos/builtin/packages/gaudi/package.py
+++ b/var/spack/repos/builtin/packages/gaudi/package.py
@@ -113,7 +113,6 @@ def setup_run_environment(self, env):
         # environment as in Gaudi.xenv
         env.prepend_path('PATH', self.prefix.scripts)
         env.prepend_path('PYTHONPATH', self.prefix.python)
-        env.prepend_path('ROOT_INCLUDE_PATH', self.prefix.include)
 
     def url_for_version(self, version):
         major = str(version[0])
diff --git a/var/spack/repos/builtin/packages/root/package.py b/var/spack/repos/builtin/packages/root/package.py
--- a/var/spack/repos/builtin/packages/root/package.py
+++ b/var/spack/repos/builtin/packages/root/package.py
@@ -617,6 +617,7 @@ def setup_dependent_build_environment(self, env, dependent_spec):
         env.prepend_path('PYTHONPATH', self.prefix.lib)
         env.prepend_path('PATH', self.prefix.bin)
         env.append_path('CMAKE_MODULE_PATH', self.prefix.cmake)
+        env.prepend_path('ROOT_INCLUDE_PATH', dependent_spec.prefix.include)
         if "+rpath" not in self.spec:
             env.prepend_path('LD_LIBRARY_PATH', self.prefix.lib)
 
@@ -625,5 +626,6 @@ def setup_dependent_run_environment(self, env, dependent_spec):
         env.set('ROOT_VERSION', 'v{0}'.format(self.version.up_to(1)))
         env.prepend_path('PYTHONPATH', self.prefix.lib)
         env.prepend_path('PATH', self.prefix.bin)
+        env.prepend_path('ROOT_INCLUDE_PATH', dependent_spec.prefix.include)
         if "+rpath" not in self.spec:
             env.prepend_path('LD_LIBRARY_PATH', self.prefix.lib)


Test patch: