[gromacs] Fix intel (classic) libstdc++ path (#37822)
* [gromacs] Fix intel (classic) libstdc++ path
Gromacs's `cmake` run will look for `--gcc-toolchain` (e.g. LLVM, icpx) or
`--gcc-name` (e.g. icpc) in `CMAKE_CXX_FLAGS`. Only if it does not find a good
g++ candidate there it will look for `GMX_GPLUSPLUS_PATH`:
cb6b311c39/cmake/FindLibStdCpp.cmake (L97)
Spack installed intel compilers already define a g++ for std libs. But in
`icp{c,x}.cfg` instead of the compile line. If we use the pre-defined g++ we not
only have less chance of mixing g++ versions, but also don't need to explicitly
add `gcc` as dependency to `gromacs`.
* Fix format
* Use a variant
As there is no way to check if a file exists at depends_on stage
* Fix format
* New name and fail if variant is used with other compiler
* Line too long.
This commit is contained in:
parent
c354cc51d0
commit
d91ec8500f
@ -232,6 +232,13 @@ class Gromacs(CMakePackage, CudaPackage):
|
||||
for gmx_ver, plumed_vers in plumed_patches.items():
|
||||
depends_on("plumed@{0}".format(plumed_vers), when="@{0}+plumed".format(gmx_ver))
|
||||
|
||||
variant(
|
||||
"intel_provided_gcc",
|
||||
default=False,
|
||||
description="Use this if Intel compiler is installed through spack."
|
||||
+ "The g++ location is written to icp{c,x}.cfg",
|
||||
)
|
||||
|
||||
depends_on("fftw-api@3")
|
||||
depends_on("cmake@2.8.8:3", type="build")
|
||||
depends_on("cmake@3.4.3:3", type="build", when="@2018:")
|
||||
@ -244,7 +251,8 @@ class Gromacs(CMakePackage, CudaPackage):
|
||||
depends_on("sycl", when="+sycl")
|
||||
depends_on("lapack", when="+lapack")
|
||||
depends_on("blas", when="+blas")
|
||||
depends_on("gcc", when="%oneapi")
|
||||
depends_on("gcc", when="%oneapi ~intel_provided_gcc")
|
||||
depends_on("gcc", when="%intel ~intel_provided_gcc")
|
||||
|
||||
depends_on("hwloc@1.0:1", when="+hwloc@2016:2018")
|
||||
depends_on("hwloc", when="+hwloc@2019:")
|
||||
@ -254,6 +262,14 @@ class Gromacs(CMakePackage, CudaPackage):
|
||||
|
||||
depends_on("nvhpc", when="+cufftmp")
|
||||
|
||||
requires(
|
||||
"%intel",
|
||||
"%oneapi",
|
||||
policy="one_of",
|
||||
when="+intel_provided_gcc",
|
||||
msg="Only attempt to find gcc libs for Intel compiler if Intel compiler is used.",
|
||||
)
|
||||
|
||||
patch("gmxDetectCpu-cmake-3.14.patch", when="@2018:2019.3^cmake@3.14.0:")
|
||||
patch("gmxDetectSimd-cmake-3.14.patch", when="@5.0:2017^cmake@3.14.0:")
|
||||
|
||||
@ -431,8 +447,16 @@ def cmake_args(self):
|
||||
if self.spec.satisfies("@2020:"):
|
||||
options.append("-DGMX_INSTALL_LEGACY_API=ON")
|
||||
|
||||
if self.spec.satisfies("%oneapi"):
|
||||
options.append("-DGMX_GPLUSPLUS_PATH=%s/g++" % self.spec["gcc"].prefix.bin)
|
||||
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%intel"):
|
||||
# If intel-oneapi-compilers was installed through spack the gcc is added to the
|
||||
# configuration file.
|
||||
if self.spec.satisfies("+intel_provided_gcc") and os.path.exists(
|
||||
".".join([os.environ["SPACK_CXX"], "cfg"])
|
||||
):
|
||||
with open(".".join([os.environ["SPACK_CXX"], "cfg"]), "r") as f:
|
||||
options.append("-DCMAKE_CXX_FLAGS={}".format(f.read()))
|
||||
else:
|
||||
options.append("-DGMX_GPLUSPLUS_PATH=%s/g++" % self.spec["gcc"].prefix.bin)
|
||||
|
||||
if "+double" in self.spec:
|
||||
options.append("-DGMX_DOUBLE:BOOL=ON")
|
||||
|
Loading…
Reference in New Issue
Block a user