summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/build_systems/oneapi.py19
-rw-r--r--var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py6
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py
index 9f009918fd..b7456a5775 100644
--- a/lib/spack/spack/build_systems/oneapi.py
+++ b/lib/spack/spack/build_systems/oneapi.py
@@ -10,7 +10,7 @@ from os.path import basename, dirname, isdir
from llnl.util.filesystem import find_headers, find_libraries, join_path
-from spack.directives import conflicts
+from spack.directives import conflicts, variant
from spack.util.environment import EnvironmentModifications
from spack.util.executable import Executable
@@ -36,6 +36,13 @@ class IntelOneApiPackage(Package):
]:
conflicts(c, msg="This package in only available for x86_64 and Linux")
+ # Add variant to toggle environment modifications from vars.sh
+ variant(
+ "envmods",
+ default=True,
+ description="Toggles environment modifications",
+ )
+
@staticmethod
def update_description(cls):
"""Updates oneapi package descriptions with common text."""
@@ -114,11 +121,13 @@ class IntelOneApiPackage(Package):
$ source {prefix}/{component}/{version}/env/vars.sh
"""
- env.extend(
- EnvironmentModifications.from_sourcing_file(
- join_path(self.component_prefix, "env", "vars.sh")
+ # Only if environment modifications are desired (default is +envmods)
+ if "+envmods" in self.spec:
+ env.extend(
+ EnvironmentModifications.from_sourcing_file(
+ join_path(self.component_prefix, "env", "vars.sh")
+ )
)
- )
class IntelOneApiLibraryPackage(IntelOneApiPackage):
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
index 41b8f12b12..62befb387d 100644
--- a/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-mkl/package.py
@@ -131,8 +131,10 @@ class IntelOneapiMkl(IntelOneApiLibraryPackage):
env.append_path("__INTEL_POST_FFLAGS", flag, separator=" ")
def setup_dependent_build_environment(self, env, dependent_spec):
- env.set("MKLROOT", self.component_prefix)
- env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig)
+ # Only if environment modifications are desired (default is +envmods)
+ if "+envmods" in self.spec:
+ env.set("MKLROOT", self.component_prefix)
+ env.append_path("PKG_CONFIG_PATH", self.component_prefix.lib.pkgconfig)
def _find_mkl_libs(self, shared):
libs = []