Repository: spack/spack

Issue:
Installation issue: lammps +rocm. Missing configuration parameters for CMake.
### Steps to reproduce the issue

```console
$ Input spec
--------------------------------
 -   lammps%gcc@11+mpi+rocm amdgpu_target=gfx90a

Concretized
--------------------------------
 -   lammps@20230802.2%gcc@11.4.0~adios~amoeba~asphere~atc~awpmd~bocs~body~bpm~brownian~cg-dna~cg-spica~class2~colloid~colvars~compress~coreshell~cuda~cuda_mps~dielectric~diffraction~dipole~dpd-basic~dpd-meso~dpd-react~dpd-smooth~drude~eff~electrode~extra-compute~extra-dump~extra-fix~extra-molecule~extra-pair~fep~ffmpeg~granular~h5md~intel~interlayer~ipo~jpeg~kim~kokkos+kspace~latboltz~lepton+lib~machdyn~manifold+manybody~mc~meam~mesont~mgpt~misc~ml-hdnnp~ml-iap~ml-pod~ml-rann~ml-snap~mofff+molecule~molfile+mpi~netcdf~opencl+openmp~openmp-package~opt~orient~peri~phonon~plugin~plumed~png~poems~ptm~python~qeq~qtb~reaction~reaxff~replica+rigid+rocm~shock~smtbq~sph~spin~srd~tally~uef~voronoi~vtk~yaff amdgpu_target=gfx90a build_system=cmake build_type=Release fftw_precision=double generator=make gpu_precision=mixed lammps_sizes=smallbig arch=linux-ubuntu22.04-icelake
[+]      ^cmake@3.27.9%gcc@11.4.0~doc+ncurses+ownlibs build_system=generic build_type=Release arch=linux-ubuntu22.04-icelake
[+]          ^curl@8.6.0%gcc@11.4.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-ubuntu22.04-icelake
[+]              ^nghttp2@1.57.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^openssl@3.2.1%gcc@11.4.0~docs+shared build_system=generic certs=mozilla arch=linux-ubuntu22.04-icelake
[+]                  ^ca-certificates-mozilla@2023-05-30%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]          ^ncurses@6.4%gcc@11.4.0~symlinks+termlib abi=none build_system=autotools patches=7a351bc arch=linux-ubuntu22.04-icelake
[+]          ^zlib-ng@2.1.6%gcc@11.4.0+compat+new_strategies+opt+pic+shared build_system=autotools arch=linux-ubuntu22.04-icelake
[+]      ^fftw@3.3.10%gcc@11.4.0+mpi~openmp~pfft_patches+shared build_system=autotools precision=double,float arch=linux-ubuntu22.04-icelake
[+]      ^gcc-runtime@11.4.0%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]      ^gmake@4.4.1%gcc@11.4.0~guile build_system=generic arch=linux-ubuntu22.04-icelake
[+]      ^hip@6.0.2%gcc@11.4.0~cuda~ipo+rocm build_system=cmake build_type=Release generator=make patches=1f65dfe,5bb9b0e,7668b2a,9165154,aee7249 arch=linux-ubuntu22.04-icelake
[+]          ^comgr@6.0.2%gcc@11.4.0~asan~ipo build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^glx@1.4%gcc@11.4.0 build_system=bundle arch=linux-ubuntu22.04-icelake
[+]              ^mesa@23.2.1%gcc@11.4.0+glx+llvm+opengl~opengles+osmesa~strip build_system=meson buildtype=release default_library=shared arch=linux-ubuntu22.04-icelake
[+]                  ^bison@3.8.2%gcc@11.4.0~color build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^flex@2.6.3%gcc@11.4.0+lex~nls build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^glproto@1.4.17%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^libunwind@1.6.2%gcc@11.4.0~block_signals~conservative_checks~cxx_exceptions~debug~debug_frame+docs~pic+tests+weak_backtrace~xz~zlib build_system=autotools components=none libs=shared,static arch=linux-ubuntu22.04-icelake
[+]                  ^libx11@1.8.7%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^inputproto@2.3.2%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^kbproto@1.0.7%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^xextproto@7.3.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^xproto@7.0.31%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^xtrans@1.5.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^libxcb@1.16%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libxau@1.0.11%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libxdmcp@1.1.4%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^xcb-proto@1.16.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^libxext@1.3.5%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^libxt@1.3.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libice@1.1.1%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libsm@1.2.4%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^llvm@17.0.6%gcc@11.4.0+clang~cuda~flang+gold~ipo+libomptarget~libomptarget_debug~link_llvm_dylib+lld+lldb+llvm_dylib+lua~mlir+polly~python~split_dwarf~z3~zstd build_system=cmake build_type=Release compiler-rt=runtime generator=ninja libcxx=runtime libunwind=runtime openmp=runtime shlib_symbol_version=none targets=all version_suffix=none arch=linux-ubuntu22.04-icelake
[+]                      ^binutils@2.42%gcc@11.4.0~gas+gold~gprofng+headers~interwork+ld~libiberty~lto~nls~pgo+plugins build_system=autotools compress_debug_sections=zlib libs=shared,static arch=linux-ubuntu22.04-icelake
[+]                      ^lua@5.3.6%gcc@11.4.0~pcfile+shared build_system=makefile fetcher=curl arch=linux-ubuntu22.04-icelake
[+]                          ^unzip@6.0%gcc@11.4.0 build_system=makefile patches=f6f6236 arch=linux-ubuntu22.04-icelake
[+]                      ^swig@4.1.1%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                          ^pcre2@10.42%gcc@11.4.0~jit+multibyte build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^py-mako@1.2.4%gcc@11.4.0 build_system=python_pip arch=linux-ubuntu22.04-icelake
[+]                      ^py-markupsafe@2.1.3%gcc@11.4.0 build_system=python_pip arch=linux-ubuntu22.04-icelake
[+]                  ^xrandr@1.5.2%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libxrandr@1.5.4%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                          ^renderproto@0.11.1%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libxrender@0.9.11%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^randrproto@1.5.0%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^hipcc@6.0.2%gcc@11.4.0~ipo build_system=cmake build_type=Release generator=make patches=f497181 arch=linux-ubuntu22.04-icelake
[+]          ^hipify-clang@6.0.2%gcc@11.4.0~asan~ipo build_system=cmake build_type=Release generator=make patches=54b8b39 arch=linux-ubuntu22.04-icelake
[+]          ^hsakmt-roct@6.0.2%gcc@11.4.0~asan~ipo+shared build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^numactl@2.0.14%gcc@11.4.0 build_system=autotools patches=4e1d78c,62fc8a8,ff37630 arch=linux-ubuntu22.04-icelake
[+]              ^m4@1.4.19%gcc@11.4.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-ubuntu22.04-icelake
[+]                  ^diffutils@3.10%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^perl@5.38.0%gcc@11.4.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=linux-ubuntu22.04-icelake
[+]              ^berkeley-db@18.1.40%gcc@11.4.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-ubuntu22.04-icelake
[+]              ^bzip2@1.0.8%gcc@11.4.0~debug~pic+shared build_system=generic arch=linux-ubuntu22.04-icelake
[+]              ^gdbm@1.23%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^perl-file-which@1.27%gcc@11.4.0 build_system=perl arch=linux-ubuntu22.04-icelake
[+]          ^perl-uri-encode@1.1.1%gcc@11.4.0 build_system=perl arch=linux-ubuntu22.04-icelake
[+]              ^perl-module-build@0.4232%gcc@11.4.0 build_system=perl arch=linux-ubuntu22.04-icelake
[+]          ^py-cppheaderparser@2.7.4%gcc@11.4.0 build_system=python_pip arch=linux-ubuntu22.04-icelake
[+]              ^py-pip@23.1.2%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]              ^py-ply@3.11%gcc@11.4.0 build_system=python_pip arch=linux-ubuntu22.04-icelake
[+]              ^py-wheel@0.41.2%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]          ^rocm-core@6.0.2%gcc@11.4.0~ipo build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^rocminfo@6.0.2%gcc@11.4.0~ipo build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^roctracer-dev-api@6.0.2%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]      ^hipcub@6.0.2%gcc@11.4.0~asan~cuda~ipo+rocm amdgpu_target=auto build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^rocm-cmake@6.0.2%gcc@11.4.0~ipo build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^rocprim@6.0.2%gcc@11.4.0~ipo amdgpu_target=auto build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]      ^hsa-rocr-dev@6.0.2%gcc@11.4.0~asan+image~ipo+shared build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]          ^elfutils@0.190%gcc@11.4.0~debuginfod+exeprefix+nls build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^gettext@0.22.4%gcc@11.4.0+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^tar@1.34%gcc@11.4.0 build_system=autotools zip=pigz arch=linux-ubuntu22.04-icelake
[+]                      ^pigz@2.8%gcc@11.4.0 build_system=makefile arch=linux-ubuntu22.04-icelake
[+]              ^libiconv@1.17%gcc@11.4.0 build_system=autotools libs=shared,static arch=linux-ubuntu22.04-icelake
[+]              ^xz@5.4.6%gcc@11.4.0~pic build_system=autotools libs=shared,static arch=linux-ubuntu22.04-icelake
[+]              ^zstd@1.5.5%gcc@11.4.0+programs build_system=makefile compression=none libs=shared,static arch=linux-ubuntu22.04-icelake
[+]          ^pkgconf@1.9.5%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^xxd-standalone@8.2.1201%gcc@11.4.0 build_system=makefile arch=linux-ubuntu22.04-icelake
[+]      ^llvm-amdgpu@6.0.2%gcc@11.4.0~ipo~link_llvm_dylib~llvm_dylib+rocm-device-libs build_system=cmake build_type=Release generator=ninja patches=53f9500,b4774ca arch=linux-ubuntu22.04-icelake
[+]          ^ninja@1.11.1%gcc@11.4.0+re2c build_system=generic arch=linux-ubuntu22.04-icelake
[+]              ^re2c@2.2%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake
[+]          ^python@3.11.7%gcc@11.4.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,ebdca64,f2fd060 arch=linux-ubuntu22.04-icelake
[+]              ^expat@2.6.2%gcc@11.4.0+libbsd build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^libbsd@0.12.1%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                      ^libmd@1.0.4%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^libxcrypt@4.4.35%gcc@11.4.0~obsolete_api build_system=autotools patches=4885da3 arch=linux-ubuntu22.04-icelake
[+]              ^readline@8.2%gcc@11.4.0 build_system=autotools patches=bbf97f1 arch=linux-ubuntu22.04-icelake
[+]              ^sqlite@3.43.2%gcc@11.4.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^util-linux-uuid@2.38.1%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^z3@4.12.4%gcc@11.4.0~gmp~ipo~python build_system=cmake build_type=Release generator=make arch=linux-ubuntu22.04-icelake
[+]      ^openmpi@5.0.2%gcc@11.4.0~atomics~cuda~gpfs~internal-hwloc~internal-libevent~internal-pmix~java~legacylaunchers~lustre~memchecker~openshmem~orterunprefix~romio+rsh~static+vt+wrapper-rpath build_system=autotools fabrics=none romio-filesystem=none schedulers=none arch=linux-ubuntu22.04-icelake
[+]          ^autoconf@2.72%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^automake@1.16.5%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^hwloc@2.9.1%gcc@11.4.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools libs=shared,static arch=linux-ubuntu22.04-icelake
[+]              ^libpciaccess@0.17%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^util-macros@1.19.3%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^libxml2@2.10.3%gcc@11.4.0+pic~python+shared build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^libevent@2.1.12%gcc@11.4.0+openssl build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^libtool@2.4.7%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^findutils@4.9.0%gcc@11.4.0 build_system=autotools patches=440b954 arch=linux-ubuntu22.04-icelake
[+]          ^openssh@9.7p1%gcc@11.4.0+gssapi build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^krb5@1.20.1%gcc@11.4.0+shared build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^libedit@3.1-20230828%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^pmix@5.0.1%gcc@11.4.0~docs+pmi_backwards_compatibility~python~restful build_system=autotools arch=linux-ubuntu22.04-icelake
[+]      ^rocm-openmp-extras@6.0.2%gcc@11.4.0~asan build_system=generic patches=d8f1c2a arch=linux-ubuntu22.04-icelake
[+]          ^gawk@5.3.0%gcc@11.4.0~nls build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^gmp@6.2.1%gcc@11.4.0+cxx build_system=autotools libs=shared,static patches=69ad2e2 arch=linux-ubuntu22.04-icelake
[+]              ^libsigsegv@2.14%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^mpfr@4.2.1%gcc@11.4.0 build_system=autotools libs=shared,static arch=linux-ubuntu22.04-icelake
[+]                  ^autoconf-archive@2023.02.20%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]                  ^texinfo@7.0.3%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^libdrm@2.4.115%gcc@11.4.0~docs build_system=generic arch=linux-ubuntu22.04-icelake
[+]              ^libpthread-stubs@0.4%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]              ^meson@1.3.2%gcc@11.4.0 build_system=python_pip patches=0f0b1bd arch=linux-ubuntu22.04-icelake
[+]          ^libffi@3.4.6%gcc@11.4.0 build_system=autotools arch=linux-ubuntu22.04-icelake
[+]          ^perl-data-dumper@2.173%gcc@11.4.0 build_system=perl arch=linux-ubuntu22.04-icelake
[+]          ^py-setuptools@69.2.0%gcc@11.4.0 build_system=generic arch=linux-ubuntu22.04-icelake


```


### Error message

<details><summary>Error message</summary>

<pre>
CMake Error at Modules/DetectHIPInstallation.cmake:3 (message):
     31      HIP support requires HIP_PATH to be defined.
     32
     33      Either pass the HIP_PATH as a CMake option via -DHIP_PATH=...  or set the
     34      HIP_PATH environment variable.

</pre></details>


### Information on your system

* **Spack:** 0.22.0.dev0 (e8ae9a403ca7db7738d36bf41bf99977b9c88a84)
* **Python:** 3.10.12
* **Platform:** linux-ubuntu22.04-icelake
* **Concretizer:** clingo


### Additional information

Spack maintainers of lammps: @rbberger

### 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
- [X] 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:
Fixed in `lammps@20240207` but I'll add a workaround for the stable versions.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/lammps/package.py b/var/spack/repos/builtin/packages/lammps/package.py
--- a/var/spack/repos/builtin/packages/lammps/package.py
+++ b/var/spack/repos/builtin/packages/lammps/package.py
@@ -31,12 +31,24 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension):
     #   marked deprecated=True
     # * patch releases older than a stable release should be marked deprecated=True
     version("develop", branch="develop")
-    version("20240207", sha256="d518f32de4eb2681f2543be63926411e72072dd7d67c1670c090b5baabed98ac")
+    version(
+        "20240207.1", sha256="3ba62c2a1ed463fceedf313a1c3ea2997994aa102379a8d35b525ea424f56776"
+    )
+    version(
+        "20240207",
+        sha256="d518f32de4eb2681f2543be63926411e72072dd7d67c1670c090b5baabed98ac",
+        deprecated=True,
+    )
     version("20231121", sha256="704d8a990874a425bcdfe0245faf13d712231ba23f014a3ebc27bc14398856f1")
+    version(
+        "20230802.3",
+        sha256="6666e28cb90d3ff01cbbda6c81bdb85cf436bbb41604a87f2ab2fa559caa8510",
+        preferred=True,
+    )
     version(
         "20230802.2",
         sha256="3bcecabc9cad08d0a4e4d989b52d29c58505f7ead8ebacf43c9db8d9fd3d564a",
-        preferred=True,
+        deprecated=True,
     )
     version(
         "20230802.1",
@@ -358,6 +370,7 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension):
     )
 
     stable_versions = {
+        "20230802.3",
         "20230802.2",
         "20230802.1",
         "20230802",
@@ -862,6 +875,11 @@ def cmake_args(self):
 
         if "+rocm" in spec:
             args.append(self.define("CMAKE_CXX_COMPILER", spec["hip"].hipcc))
+            if "@:20231121" in spec:
+                if "^hip@:5.4" in spec:
+                    args.append(self.define("HIP_PATH", f"{spec['hip'].prefix}/hip"))
+                elif "^hip@5.5:" in spec:
+                    args.append(self.define("HIP_PATH", spec["hip"].prefix))
 
         return args
 


Test patch: