Exclude some targets when compiler or test builds are off.
diff --git a/bindings/tflite/CMakeLists.txt b/bindings/tflite/CMakeLists.txt
index 4624d5a..918e48a 100644
--- a/bindings/tflite/CMakeLists.txt
+++ b/bindings/tflite/CMakeLists.txt
@@ -50,6 +50,10 @@
   PUBLIC
 )
 
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+
 iree_cc_test(
   NAME
     smoke_test
diff --git a/bindings/tflite/testdata/CMakeLists.txt b/bindings/tflite/testdata/CMakeLists.txt
index a84f376..c348838 100644
--- a/bindings/tflite/testdata/CMakeLists.txt
+++ b/bindings/tflite/testdata/CMakeLists.txt
@@ -14,6 +14,10 @@
 
 iree_add_all_subdirs()
 
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+
 iree_bytecode_module(
   NAME
     add_dynamic
diff --git a/iree/runtime/demo/BUILD b/iree/runtime/demo/BUILD
index 41c891f..81ba119 100644
--- a/iree/runtime/demo/BUILD
+++ b/iree/runtime/demo/BUILD
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
 load("//build_tools/bazel:run_binary_test.bzl", "run_binary_test")
 
 package(
@@ -24,6 +25,15 @@
 # Hello World!
 #===------------------------------------------------------------------------===#
 
+iree_cmake_extra_content(
+    content = """
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+""",
+    inline = True,
+)
+
 cc_binary(
     name = "hello_world_embedded",
     srcs = ["hello_world_explained.c"],
diff --git a/iree/runtime/demo/CMakeLists.txt b/iree/runtime/demo/CMakeLists.txt
index 564602d..0852fd3 100644
--- a/iree/runtime/demo/CMakeLists.txt
+++ b/iree/runtime/demo/CMakeLists.txt
@@ -10,6 +10,10 @@
 
 iree_add_all_subdirs()
 
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+
 iree_cc_binary(
   NAME
     hello_world_embedded
diff --git a/iree/runtime/testdata/BUILD b/iree/runtime/testdata/BUILD
index 0a59cec..b5b76c8 100644
--- a/iree/runtime/testdata/BUILD
+++ b/iree/runtime/testdata/BUILD
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
 load("//iree/tools:compilation.bzl", "iree_bytecode_module")
 
 package(
@@ -20,6 +21,15 @@
     licenses = ["notice"],  # Apache 2.0
 )
 
+iree_cmake_extra_content(
+    content = """
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+""",
+    inline = True,
+)
+
 iree_bytecode_module(
     name = "simple_mul_module",
     src = "simple_mul.mlir",
diff --git a/iree/runtime/testdata/CMakeLists.txt b/iree/runtime/testdata/CMakeLists.txt
index 3f74c09..9d25169 100644
--- a/iree/runtime/testdata/CMakeLists.txt
+++ b/iree/runtime/testdata/CMakeLists.txt
@@ -10,6 +10,10 @@
 
 iree_add_all_subdirs()
 
+if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
+  return()
+endif()
+
 iree_bytecode_module(
   NAME
     simple_mul_module