Only build the deferred_work_queue when threading is enabled. (#18234)

Since iree::base::internal::threading only exists when
IREE_ENABLE_THREADING is on, we have to hide deferred_work_queue behind
threading.

Signed-off-by: Andrew Woloszyn <andrew.woloszyn@gmail.com>
diff --git a/runtime/src/iree/hal/utils/BUILD.bazel b/runtime/src/iree/hal/utils/BUILD.bazel
index 38f170c..0a01f98 100644
--- a/runtime/src/iree/hal/utils/BUILD.bazel
+++ b/runtime/src/iree/hal/utils/BUILD.bazel
@@ -4,7 +4,7 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_runtime_cc_library", "iree_runtime_cc_test")
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_runtime_cc_library", "iree_runtime_cc_test")
 load("//build_tools/bazel:cc_binary_benchmark.bzl", "cc_binary_benchmark")
 
 package(
@@ -202,6 +202,15 @@
     ],
 )
 
+iree_cmake_extra_content(
+    content = """
+if(NOT IREE_ENABLE_THREADING)
+  return()
+endif()
+""",
+    inline = True,
+)
+
 iree_runtime_cc_library(
     name = "deferred_work_queue",
     srcs = ["deferred_work_queue.c"],
diff --git a/runtime/src/iree/hal/utils/CMakeLists.txt b/runtime/src/iree/hal/utils/CMakeLists.txt
index 3da6140..1f58626 100644
--- a/runtime/src/iree/hal/utils/CMakeLists.txt
+++ b/runtime/src/iree/hal/utils/CMakeLists.txt
@@ -238,6 +238,10 @@
     iree::testing::gtest_main
 )
 
+if(NOT IREE_ENABLE_THREADING)
+  return()
+endif()
+
 iree_cc_library(
   NAME
     deferred_work_queue