Repository: spack/spack

Issue:
Installation issue: elmerfem fails (current develop branch)
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
# on develop
$ spack install elmerfem

==> elmerfem: Executing phase: 'cmake'
==> Error: ProcessError: Command exited with status 1:
    'cmake' '-G' 'Unix Makefiles' '-DCMAKE_INSTALL_PREFIX:STRING=/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF' '-DCMAKE_INSTALL_RPATH:STRING=/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf/lib64;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-fortran-4.5.3-v4jm5r6eicdgbvoo2ldiycgxxigw6ycr/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-c-4.7.4-vfn255hd3tpzv5jve6g3sddu3dkesnqj/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/hdf5-1.10.6-wwvdwlgqronkp3ip6ln7sjolsh6xtgmw/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/openmpi-3.1.6-tg6m4mmn2p3vxbdpopsqgfesihlm3g5f/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/hwloc-1.11.11-s54td4k4foxz3kdukoesox46risjltch/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/libpciaccess-0.16-jal4hhtw4kll2ddp2sj3rju7mopudjah/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/libxml2-2.9.10-ja2c23qtqvz2bhub56nntekn5jbrg2im/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/libiconv-1.16-cxpnllg3l7aq5tq3eqyncb4wru2sshhe/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/xz-5.2.5-6n3p5dewvc4gjdeetluk433gclaiashe/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/zlib-1.2.11-r2llgrncecwh3hlaqtn7e6x7nwdzap3m/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/numactl-2.0.12-oxfddl22tqxzrxhv4emx4m6awbbif5jx/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netlib-scalapack-2.1.0-kmsqrzlnzerrcvy46yea5wki35ct7eyh/lib;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/openblas-0.3.10-khruhsfwsdi2bujtfeneetmplvjieqfh/lib' '-DCMAKE_PREFIX_PATH:STRING=/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/cmake-3.18.2-c7yyfswabl45pn2gxusualjljpgnaiqw;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/openmpi-3.1.6-tg6m4mmn2p3vxbdpopsqgfesihlm3g5f;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-fortran-4.5.3-v4jm5r6eicdgbvoo2ldiycgxxigw6ycr;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/openblas-0.3.10-khruhsfwsdi2bujtfeneetmplvjieqfh;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netlib-scalapack-2.1.0-kmsqrzlnzerrcvy46yea5wki35ct7eyh' '-DWITH_ElmerIce=ON' '-DWITH_CONTRIB=ON' '-DWITH_MPI=ON' '-DWITH_OpenMP=ON' '-DWITH_Mumps=OFF' '-DWITH_Hypre=OFF' '-DWITH_Trilinos=OFF' '-DWITH_LUA=OFF' '-DWITH_Zoltan=OFF' '/tmp/swmgr/spack-stage/spack-stage-elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf/spack-src'

1 error found in build log:
     120    --   NetCDF_INC:       /gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-c-4.7.4-vfn255hd3tpzv5jve6g3sddu3dkesnqj/inclu
            de
     121    --   NetCDF_LIBS:     /gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-c-4.7.4-vfn255hd3tpzv5jve6g3sddu3dkesnqj/lib/li
            bnetcdf.so;/gpfs/packages/spack/spack/opt/spack/linux-rhel7-broadwell/gcc-8.2.0/netcdf-fortran-4.5.3-v4jm5r6eicdgbvoo2ldiycgxxigw6ycr/lib/libnetc
            dff.so
     122    -- Found 112 modules from /tmp/swmgr/spack-stage/spack-stage-elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf/spack-src/fem/src/modules
     123    -- Found 1 modules from /tmp/swmgr/spack-stage/spack-stage-elmerfem-8.4-ckcwki7bakroo43ygj7swnrmvj6ne6rf/spack-src/fem/src/modules/contrib
     124    --  ELMERSOLVER_RPATH_STRING_MOD $ORIGIN/../lib/elmersolver
     125    --  ELMERLIB_RPATH_STRING $ORIGIN/
  >> 126    CMake Error at fem/tests/CMakeLists.txt:17 (FOREACH):
     127      FOREACH Invalid integer: 'depth'
     128    Call Stack (most recent call first):
     129      fem/tests/CMakeLists.txt:29 (SUBDIRLIST)
     130
     131
     132    -- Configuring incomplete, errors occurred!


The whole log file contained these lines, before the errors above.  Not sure if relevant.

-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:54 (CMAKE_POLICY):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


fatal: Not a git repository (or any parent up to mount point /tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-- Checking whether GFortran version >= 4.8 -- yes
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED




...
```



### Information on your system

<!-- Please include the output of `spack debug report` -->

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt]()
* [spack-build-env.txt]()

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [ ] 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:
Upstream release (8.4) is broken, and that's the default version chosen by this recipe.  If you install `elmerfem@devel` the compile succeeds.  (That pulls from the `devel` branch, though, of course.)

https://github.com/ElmerCSC/elmerfem/issues/237

This could be patched in Spack, or conceivably `devel` could be made the default version.  Not sure what's best.


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/elmerfem/package.py b/var/spack/repos/builtin/packages/elmerfem/package.py
--- a/var/spack/repos/builtin/packages/elmerfem/package.py
+++ b/var/spack/repos/builtin/packages/elmerfem/package.py
@@ -3,8 +3,6 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
-from spack import *
-
 
 class Elmerfem(CMakePackage):
     """Elmer is an open source multiphysical simulation software. It
@@ -17,8 +15,10 @@ class Elmerfem(CMakePackage):
 
     version('ice',   branch='elmerice')
     version('devel', branch='devel')
+    version('9.0', sha256='08c5bf261e87ff37456c1aa0372db3c83efabe4473ea3ea0b8ec66f5944d1aa0')
     version('8.4', sha256='cc3ce807d76798361592cc14952cdc3db1ad8f9bac038017514033ce9badc5b3')
 
+    variant('gui', default=False, description='Enable GUI support.')
     variant('mpi', default=True, description='Enable MPI support.')
     variant('openmp', default=True, description='Enable OpenMP support.')
     variant('mumps', default=False, description='Enable MUMPS support.')
@@ -28,6 +28,9 @@ class Elmerfem(CMakePackage):
     variant('lua', default=False, description='Enable Lua support.')
     variant('scatt2d', default=False, description='Build Scattered2DDataInterpolator solver.')
 
+    depends_on('qt@5:+opengl', when='+gui')
+    depends_on('qwt', when='+gui')
+    depends_on('paraview+qt', when='+gui')
     depends_on('mpi')
     depends_on('netcdf-fortran')
     depends_on('blas')
@@ -47,6 +50,14 @@ def cmake_args(self):
 
         args = ['-DWITH_ElmerIce=ON', '-DWITH_CONTRIB=ON']
 
+        if '+gui' in spec:
+            args.append('-DWITH_ELMERGUI:BOOL=TRUE')
+            args.append('-DWITH_QT5:BOOL=TRUE')
+            args.append('-DWITH_QWT:BOOL=TRUE')
+            args.append('-DWITH_PARAVIEW:BOOL=TRUE')
+        else:
+            args.append('-DWITH_ELMERGUI:BOOL=FALSE')
+
         if '+mpi' in spec:
             args.append('-DWITH_MPI=ON')
         else:
@@ -112,6 +123,16 @@ def cmake_args(self):
 
         return args
 
+    def patch(self):
+        if self.spec.satisfies('@8.4'):
+            # from commit f02cb33acd59 upstream
+            filter_file('FOREACH(D RANGE 1 depth)',
+                        'FOREACH(D RANGE 1 ${depth})',
+                        'fem/tests/CMakeLists.txt',
+                        string=True)
+
     def setup_run_environment(self, env):
         env.set('ELMER_HOME', self.prefix)
         env.set('ELMER_Fortran_COMPILER', self.compiler.fc)
+        if '+gui' in self.spec:
+            env.set('ELMERGUI_HOME', self.prefix.share.ElmerGUI)


Test patch: