Add SPIRV-tools directories to cmake build only when required

Change-Id: I873a9ac79786a34a6c1c0e2c9bd6f596adf56dcc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/194902
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Jaswant Panchumarti <jaswant.panchumarti@kitware.com>
Auto-Submit: Jaswant Panchumarti <jaswant.panchumarti@kitware.com>
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 258e261..9d433b4 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -55,7 +55,12 @@
     add_subdirectory(${DAWN_SPIRV_HEADERS_DIR} "${CMAKE_CURRENT_BINARY_DIR}/spirv-headers")
 endif()
 
-if (NOT TARGET SPIRV-Tools)
+if (NOT TARGET SPIRV-Tools AND
+    (((DAWN_ENABLE_OPENGL OR DAWN_ENABLE_VULKAN)
+        AND DAWN_ENABLE_SPIRV_VALIDATION)
+        OR TINT_BUILD_SPV_READER
+        OR TINT_BUILD_SPV_WRITER
+        OR DAWN_USE_BUILT_DXC))
     set(SPIRV_SKIP_TESTS ON CACHE BOOL "" FORCE)
     set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "" FORCE)
     set(SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "" FORCE)