diff --git a/var/spack/repos/builtin/packages/extrae/package.py b/var/spack/repos/builtin/packages/extrae/package.py
index cbc849e8f2c6f7c41723060cdff528dd7058a1f9..11f151b636432860fb894717e706cd765b2e1bb8 100644
--- a/var/spack/repos/builtin/packages/extrae/package.py
+++ b/var/spack/repos/builtin/packages/extrae/package.py
@@ -73,10 +73,6 @@ class Extrae(AutotoolsPackage):
     depends_on("mpi")
     depends_on("libunwind")
 
-    # TODO: replace this with an explicit list of components of Boost,
-    # for instance depends_on('boost +filesystem')
-    # See https://github.com/spack/spack/pull/22303 for reference
-    depends_on(Boost.with_default_variants)
     depends_on("libdwarf")
     depends_on("elf", type="link")
     depends_on("libxml2")
@@ -92,6 +88,10 @@ class Extrae(AutotoolsPackage):
     variant("dyninst", default=False, description="Use dyninst for dynamic code installation")
     with when("+dyninst"):
         depends_on("dyninst@10.1.0:")
+        # TODO: replace this with an explicit list of components of Boost,
+        # for instance depends_on('boost +filesystem')
+        # See https://github.com/spack/spack/pull/22303 for reference
+        depends_on(Boost.with_default_variants)
         depends_on("elfutils", when="@4.1.2:")
         depends_on("intel-oneapi-tbb", when="@4.1.2:")
 
@@ -127,7 +127,6 @@ def configure_args(self):
         args = [
             "--with-mpi=%s" % mpiroot,
             "--with-unwind=%s" % spec["libunwind"].prefix,
-            "--with-boost=%s" % spec["boost"].prefix,
             "--with-dwarf=%s" % spec["libdwarf"].prefix,
             "--with-elf=%s" % spec["elf"].prefix,
             "--with-xml-prefix=%s" % spec["libxml2"].prefix,
@@ -141,7 +140,10 @@ def configure_args(self):
         )
 
         if spec.satisfies("+dyninst"):
-            args += ["--with-dyninst={spec['dyninst'].prefix}"]
+            args += [
+                f"--with-dyninst={spec['dyninst'].prefix}",
+                f"--with-boost={spec['boost'].prefix}",
+            ]
 
             if spec.satisfies("@4.1.2:"):
                 args += [