Repository: spack/spack

Issue:
Installation issue: HDF5 1.10.8/1.13.0 installs cmake files to wrong location
### Steps to reproduce the issue

```console
spack install hdf5@1.10.8
ls ${SPACK_ROOT}/opt/spack/*/*/hdf5-*/share/cmake
```
output should be:
```
hdf5
```
as it is for 1.12.1 for example, but instead for 1.10.8, it is:
```
hdf5-config.cmake  hdf5-config-version.cmake  hdf5-targets.cmake  hdf5-targets-relwithdebinfo.cmake
```

As specified in cmake doc https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure
`<prefix>/share/cmake/` is not part of the Search Procedure, `<prefix>/share/cmake/<name>` is.

### Information on your system

* **Spack:** 0.17.0
* **Python:** 3.6.9
* **Platform:** linux-ubuntu18.04-skylake
* **Concretizer:** clingo


### Additional information

@ChristopherHogan @brtnfld  @byrnHDF  @epourmal  @gheber  @hyoklee  @lkurz  @lrknox  @soumagne

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [ ] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
I see downstream CMake binary variant identification issues with HDF5 as well since end of last week in #28083

I think this was caused by pinning 1.10.8 as new preferred HDF5 version in #27613/#28010.
@lrknox as the author of those PRs, can you please help? :)
Locally, I changed the `preferred` HDF5 back to 1.10.7 and this fixes my issue. I'll push this as hot-fix to #28084.

This looks like an upstream bug and is probably something more general to investigate for the HDF5 maintainers?
cc @ChristopherHogan @brtnfld @byrnHDF @epourmal @gheber @hyoklee @lkurz @lrknox @soumagne

You can re-enable the preferred pinning to HDF5 1.10.8 with a patch in a follow-up PR and we should probably check if 1.13.0 is also affected.
Posted upstream in HdfGroup/hdf5#1320
According to https://github.com/spack/spack/pull/28084#issuecomment-998014187, this will be the default location for `hdf5`'s CMake files at least starting with `hdf5@1.13.0`, so presumably dependent packages will need to change what they search.

That is to say: did you discover this by installing some package which depends on `hdf5`? If so, can you mention that here? We should probably update the constraints in that package as part of merging https://github.com/spack/spack/pull/28091 (once https://github.com/spack/spack/pull/28084 is merged).

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py
--- a/var/spack/repos/builtin/packages/hdf5/package.py
+++ b/var/spack/repos/builtin/packages/hdf5/package.py
@@ -381,6 +381,11 @@ def cmake_args(self):
                 args.append(self.define('CMAKE_Fortran_COMPILER',
                                         spec['mpi'].mpifc))
 
+        # work-around for https://github.com/HDFGroup/hdf5/issues/1320
+        if spec.satisfies('@1.10.8,1.13.0'):
+            args.append(self.define('HDF5_INSTALL_CMAKE_DIR',
+                                    'share/cmake/hdf5'))
+
         return args
 
     @run_after('install')


Test patch: