Repository: spack/spack

Issue:
precice@2.2.0: build fails on ubuntu20.04: cmake: fails to find PETSc
`precice@2.2.0` build fails using:
* `spack@develop` (ac66624196691a9b3d8ea6d3d8749e3b570be7ad from `Wed Mar 3 14:44:04 2021 +0100`)
* `Ubuntu 20.04` (x86_64 and ppc64le)
* `GCC 9.3.0`

Concrete spec: [precice-j6sv4e.spec.yaml.txt](https://github.com/spack/spack/files/6077408/precice-j6sv4e.spec.yaml.txt)
Build log: [precice-build-out.txt](https://github.com/spack/spack/files/6077405/precice-build-out.txt)
CMakeOutput log: [precice-CMakeOutput.log](https://github.com/spack/spack/files/6077419/precice-CMakeOutput.log)
CMakeError log: [precice-CMakeError.log](https://github.com/spack/spack/files/6077428/precice-CMakeError.log)

```
$> spack install -f ./precice-j6sv4e.spec.yaml
...
==> Installing precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt
==> Using cached archive: /opt/spack/var/spack/cache/_source-cache/archive/f8/f8c4e0810dcaeb6a40a0fcab64b95c899f0121c968e0730416d4d2a97d39d0c4.tar.gz
==> No patches needed for precice
==> precice: Executing phase: 'cmake'
==> Error: ProcessError: Command exited with status 1:
    'cmake' '-G' 'Unix Makefiles' '-DCMAKE_INSTALL_PREFIX:STRING=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF' '-DCMAKE_INSTALL_RPATH:STRING=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt/lib64;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/boost-1.74.0-ljiuly435eu2xpa4fd33t726opeifp53/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/bzip2-1.0.8-5m22qwv5akdogbbq3qbuhilvippzqeli/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/mpich-3.3.2-mb6jkgq76xsbjprimh454xg62vkjehlg/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/hwloc-2.4.1-7dajyfwwzoajvsrbbziwfwixr2fz3tdv/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libpciaccess-0.16-ux5xkhgfhhmitpkxfuf5h6ooudsiwhd4/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-a5l2lj7dfurshwzxv62t7rw2lv6lnfhr/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libiconv-1.16-w6zptbclncs3jsnl3i4qtg72fgheiwdf/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/xz-5.2.5-kamfyq4jqy3je7qoimrp2tgs6gqswzcf/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5pqi6svirhovljrkp3uyfiytz3m/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libfabric-1.11.2-hfw7le26w2h37lt3oakbqysxzu6kl6cb/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/petsc-3.14.4-yc3v3oeypwdlql6tsjhuf2syrsbmqdwe/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/hdf5-1.10.7-q23j772ywai2iiogw56x4qz4szokavl2/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/numactl-2.0.14-vw2cdve2xpvtcq2r32ogoptxd4cyjfre/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/hypre-2.20.0-d2mbzsu5gzi4t6wv52hr76654nli3dci/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/openblas-0.3.10-6mtluiuaonduocjmfeh2txgxeihpn4jj/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/metis-5.1.0-lxkd2thzi5xc5z3aqvw4eodot57r53y5/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/parmetis-4.0.3-efbt3ctukgwh65yk35cproiprqk5gqpo/lib;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/superlu-dist-6.4.0-hu7wt7bhbcl4fpfahlekwwfcqgve7w2m/lib' '-DCMAKE_PREFIX_PATH:STRING=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/boost-1.74.0-ljiuly435eu2xpa4fd33t726opeifp53;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cmake-3.18.4-2fevpur6k4cwjshhmj27aorisxwxqsqh;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/eigen-3.3.8-4x7u72o55ir2zjcgx4z6kyl3r4qkv5v6;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-a5l2lj7dfurshwzxv62t7rw2lv6lnfhr;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/mpich-3.3.2-mb6jkgq76xsbjprimh454xg62vkjehlg;/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/petsc-3.14.4-yc3v3oeypwdlql6tsjhuf2syrsbmqdwe' '-DBUILD_SHARED_LIBS:BOOL=ON' '-DPRECICE_MPICommunication:BOOL=ON' '-DTPL_ENABLE_BOOST=ON' '-DBOOST_ROOT=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/boost-1.74.0-ljiuly435eu2xpa4fd33t726opeifp53' '-DTPL_ENABLE_EIGEN3=ON' '-DEIGEN3_INCLUDE_DIR=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/eigen-3.3.8-4x7u72o55ir2zjcgx4z6kyl3r4qkv5v6/include/eigen3' '-DTPL_ENABLE_LIBXML2=ON' '-DLIBXML2_INCLUDE_DIRS=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-a5l2lj7dfurshwzxv62t7rw2lv6lnfhr/include/libxml2' '-DLIBXML2_LIBRARIES=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/libxml2-2.9.10-a5l2lj7dfurshwzxv62t7rw2lv6lnfhr/lib/libxml2.so' '-DTPL_ENABLE_PETSC:BOOL=ON' '-DPETSC_DIR=/opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/petsc-3.14.4-yc3v3oeypwdlql6tsjhuf2syrsbmqdwe' '-DPETSC_ARCH=.' '-DPRECICE_PythonActions:BOOL=OFF' '/tmp/root/spack-stage/spack-stage-precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt/spack-src'

1 error found in build log:
     110    MPICH FC:	/opt/spack/lib/spack/env/gcc/gfortran   -O2
     111    -- Checking requirements for TPL override of PETSC
     112    --   * PETSC_DIR - defined
     113    --   * PETSC_ARCH - defined
     114    -- Checking requirements for TPL override of PETSC - success
     115    -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
  >> 116    CMake Error at /opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cmake-3.18.4-2fevpur6k4cwjshhmj27aorisxwxqsqh/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:
            165 (message):
     117      Could NOT find PETSc (missing: PETSc_FOUND PETSc_INCLUDE_DIRS
     118      PETSc_LIBRARIES) (Required is at least version "3.12")
     119    Call Stack (most recent call first):
     120      /opt/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/cmake-3.18.4-2fevpur6k4cwjshhmj27aorisxwxqsqh/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_F
            AILURE_MESSAGE)
     121      cmake/modules/FindPETSc.cmake:229 (find_package_handle_standard_args)
     122      CMakeLists.txt:216 (find_package)

See build log for details:
  /tmp/root/spack-stage/spack-stage-precice-2.2.0-j6sv4e6cpdfqlbgvew2n5qptrde4evzt/spack-build-out.txt
```

This doesn't seem to affect my builds of precice on `RHEL 7`, `RHEL 8`, or `Ubuntu 18.04`.

@fsimonis @MakisH 





Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/precice/package.py b/var/spack/repos/builtin/packages/precice/package.py
--- a/var/spack/repos/builtin/packages/precice/package.py
+++ b/var/spack/repos/builtin/packages/precice/package.py
@@ -43,6 +43,7 @@ class Precice(CMakePackage):
 
     depends_on('cmake@3.5:', type='build')
     depends_on('cmake@3.10.2:', type='build', when='@1.4:')
+    depends_on('pkgconfig', type='build', when='@2.2:')
     depends_on('boost@1.60.0:')
     depends_on('boost@1.65.1:', when='@1.4:')
     depends_on('boost@:1.72.99', when='@:2.0.2')


Test patch: