[MLIR] Move from add_dependencies() to DEPENDS

add_llvm_library and add_llvm_executable may need to create new targets with
appropriate dependencies.  As a result, it is not sufficient in some
configurations (namely LLVM_BUILD_LLVM_DYLIB=on) to only call
add_dependencies().  Instead, the explicit TableGen dependencies must
be passed to add_llvm_library() or add_llvm_executable() using the DEPENDS
keyword.

Differential Revision: https://reviews.llvm.org/D74930
diff --git a/mlir/examples/toy/Ch2/CMakeLists.txt b/mlir/examples/toy/Ch2/CMakeLists.txt
index 7154902..ea03e4e 100644
--- a/mlir/examples/toy/Ch2/CMakeLists.txt
+++ b/mlir/examples/toy/Ch2/CMakeLists.txt
@@ -9,10 +9,13 @@
   parser/AST.cpp
   mlir/MLIRGen.cpp
   mlir/Dialect.cpp
+
+  DEPENDS
+  ToyCh2OpsIncGen
+
   )
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
-add_dependencies(toyc-ch2 ToyCh2OpsIncGen)
 target_link_libraries(toyc-ch2
   PRIVATE
     MLIRAnalysis
diff --git a/mlir/examples/toy/Ch3/CMakeLists.txt b/mlir/examples/toy/Ch3/CMakeLists.txt
index 823edfd..e1bfe1b 100644
--- a/mlir/examples/toy/Ch3/CMakeLists.txt
+++ b/mlir/examples/toy/Ch3/CMakeLists.txt
@@ -14,10 +14,12 @@
   mlir/MLIRGen.cpp
   mlir/Dialect.cpp
   mlir/ToyCombine.cpp
+
+  DEPENDS
+  ToyCh3OpsIncGen
+  ToyCh3CombineIncGen
   )
 
-add_dependencies(toyc-ch3 ToyCh3OpsIncGen)
-add_dependencies(toyc-ch3 ToyCh3CombineIncGen)
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
diff --git a/mlir/examples/toy/Ch4/CMakeLists.txt b/mlir/examples/toy/Ch4/CMakeLists.txt
index c9b0e71..a78bedf 100644
--- a/mlir/examples/toy/Ch4/CMakeLists.txt
+++ b/mlir/examples/toy/Ch4/CMakeLists.txt
@@ -15,12 +15,14 @@
   mlir/Dialect.cpp
   mlir/ShapeInferencePass.cpp
   mlir/ToyCombine.cpp
+
+  DEPENDS
+  ToyCh4OpsIncGen
+  ToyCh4ShapeInferenceInterfaceIncGen
+  ToyCh4CombineIncGen
+  MLIRCallOpInterfacesIncGen
   )
 
-add_dependencies(toyc-ch4 ToyCh4OpsIncGen)
-add_dependencies(toyc-ch4 ToyCh4ShapeInferenceInterfaceIncGen)
-add_dependencies(toyc-ch4 ToyCh4CombineIncGen)
-add_dependencies(toyc-ch4 MLIRCallOpInterfacesIncGen)
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
diff --git a/mlir/examples/toy/Ch5/CMakeLists.txt b/mlir/examples/toy/Ch5/CMakeLists.txt
index 4c2cf49..6b9ded3 100644
--- a/mlir/examples/toy/Ch5/CMakeLists.txt
+++ b/mlir/examples/toy/Ch5/CMakeLists.txt
@@ -16,12 +16,14 @@
   mlir/LowerToAffineLoops.cpp
   mlir/ShapeInferencePass.cpp
   mlir/ToyCombine.cpp
+
+  DEPENDS
+  ToyCh5ShapeInferenceInterfaceIncGen
+  ToyCh5OpsIncGen
+  ToyCh5CombineIncGen
+  MLIRCallOpInterfacesIncGen
   )
 
-add_dependencies(toyc-ch5 ToyCh5ShapeInferenceInterfaceIncGen)
-add_dependencies(toyc-ch5 ToyCh5OpsIncGen)
-add_dependencies(toyc-ch5 ToyCh5CombineIncGen)
-add_dependencies(toyc-ch5 MLIRCallOpInterfacesIncGen)
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
diff --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt
index e46200d..727331f 100644
--- a/mlir/examples/toy/Ch6/CMakeLists.txt
+++ b/mlir/examples/toy/Ch6/CMakeLists.txt
@@ -18,12 +18,14 @@
   mlir/LowerToLLVM.cpp
   mlir/ShapeInferencePass.cpp
   mlir/ToyCombine.cpp
+
+  DEPENDS
+  ToyCh6ShapeInferenceInterfaceIncGen
+  ToyCh6OpsIncGen
+  ToyCh6CombineIncGen
+  MLIRCallOpInterfacesIncGen
   )
 
-add_dependencies(toyc-ch6 ToyCh6ShapeInferenceInterfaceIncGen)
-add_dependencies(toyc-ch6 ToyCh6OpsIncGen)
-add_dependencies(toyc-ch6 ToyCh6CombineIncGen)
-add_dependencies(toyc-ch6 MLIRCallOpInterfacesIncGen)
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
diff --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt
index 7f67cc9..cc1e9bf 100644
--- a/mlir/examples/toy/Ch7/CMakeLists.txt
+++ b/mlir/examples/toy/Ch7/CMakeLists.txt
@@ -18,12 +18,14 @@
   mlir/LowerToLLVM.cpp
   mlir/ShapeInferencePass.cpp
   mlir/ToyCombine.cpp
+
+  DEPENDS
+  ToyCh7ShapeInferenceInterfaceIncGen
+  ToyCh7OpsIncGen
+  ToyCh7CombineIncGen
+  MLIRCallOpInterfacesIncGen
   )
 
-add_dependencies(toyc-ch7 ToyCh7ShapeInferenceInterfaceIncGen)
-add_dependencies(toyc-ch7 ToyCh7OpsIncGen)
-add_dependencies(toyc-ch7 ToyCh7CombineIncGen)
-add_dependencies(toyc-ch7 MLIRCallOpInterfacesIncGen)
 include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
diff --git a/mlir/lib/Analysis/CMakeLists.txt b/mlir/lib/Analysis/CMakeLists.txt
index c66086f..4fbd16c 100644
--- a/mlir/lib/Analysis/CMakeLists.txt
+++ b/mlir/lib/Analysis/CMakeLists.txt
@@ -24,8 +24,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Analysis
-  )
-add_dependencies(MLIRAnalysis
+
+  DEPENDS
   MLIRCallOpInterfacesIncGen
   MLIRControlFlowInterfacesIncGen
   MLIRTypeInferOpInterfaceIncGen
@@ -46,8 +46,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Analysis
-  )
-add_dependencies(MLIRLoopAnalysis
+
+  DEPENDS
   MLIRCallOpInterfacesIncGen
   MLIRControlFlowInterfacesIncGen
   MLIRTypeInferOpInterfaceIncGen
diff --git a/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt b/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
index 0ae0e97..75d82e8 100644
--- a/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
@@ -4,10 +4,10 @@
 
 add_mlir_conversion_library(MLIRGPUtoNVVMTransforms
   LowerGpuOpsToNVVMOps.cpp
-  )
 
-add_dependencies(MLIRGPUtoNVVMTransforms
-  MLIRGPUToNVVMIncGen)
+  DEPENDS
+  MLIRGPUToNVVMIncGen
+  )
 
 target_link_libraries(MLIRGPUtoNVVMTransforms
   PUBLIC
diff --git a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
index c766469..a0c5b6a 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
@@ -5,10 +5,10 @@
 add_mlir_conversion_library(MLIRGPUtoSPIRVTransforms
   ConvertGPUToSPIRV.cpp
   ConvertGPUToSPIRVPass.cpp
-  )
 
-add_dependencies(MLIRGPUtoSPIRVTransforms
-  MLIRGPUToSPIRVIncGen)
+  DEPENDS
+  MLIRGPUToSPIRVIncGen
+  )
 
 target_link_libraries(MLIRGPUtoSPIRVTransforms
   PUBLIC
diff --git a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
index fcb1da8..308f1b0 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
@@ -10,10 +10,10 @@
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/IR
-  )
 
-add_dependencies(MLIRStandardToSPIRVTransforms
-  MLIRStandardToSPIRVIncGen)
+  DEPENDS
+  MLIRStandardToSPIRVIncGen
+  )
 
 target_link_libraries(MLIRStandardToSPIRVTransforms
   PUBLIC
diff --git a/mlir/lib/Dialect/AffineOps/CMakeLists.txt b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
index 5746377..f065608 100644
--- a/mlir/lib/Dialect/AffineOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
@@ -5,8 +5,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/AffineOps
-  )
-add_dependencies(MLIRAffineOps
+
+  DEPENDS
   MLIRAffineOpsIncGen
   MLIRLoopLikeInterfaceIncGen
   )
diff --git a/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt b/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
index 0ccf794..66016c7 100644
--- a/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
@@ -4,6 +4,9 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/FxpMathOps
+
+  DEPENDS
+  MLIRFxpMathOpsIncGen
   )
 
 target_link_libraries(MLIRFxpMathOps
@@ -14,6 +17,3 @@
   MLIRSupport
   MLIRStandardOps
   )
-add_dependencies(MLIRFxpMathOps
-  MLIRFxpMathOpsIncGen
-  )
diff --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt
index 4ca74e9..120e347 100644
--- a/mlir/lib/Dialect/GPU/CMakeLists.txt
+++ b/mlir/lib/Dialect/GPU/CMakeLists.txt
@@ -7,8 +7,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/GPU
-)
-add_dependencies(MLIRGPU
+
+  DEPENDS
   MLIRGPUOpsIncGen
   )
 target_link_libraries(MLIRGPU
@@ -21,4 +21,5 @@
   MLIRStandardOps
   MLIRSupport
   MLIRTransformUtils
-  LLVMSupport)
+  LLVMSupport
+  )
diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
index 60b5bdc..8c030f3 100644
--- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
@@ -3,8 +3,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
-  )
-add_dependencies(MLIRLLVMIR
+
+  DEPENDS
   MLIRControlFlowInterfacesIncGen
   MLIRLLVMOpsIncGen
   MLIRLLVMConversionsIncGen
@@ -25,8 +25,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
-  )
-add_dependencies(MLIRNVVMIR
+
+  DEPENDS
   MLIRNVVMOpsIncGen
   MLIRNVVMConversionsIncGen
   )
@@ -44,8 +44,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
-  )
-add_dependencies(MLIRROCDLIR
+
+  DEPENDS
   MLIRROCDLOpsIncGen
   MLIRROCDLConversionsIncGen
   )
diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
index 4a7aaad..7a864ad 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
@@ -7,11 +7,9 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Linalg
+
   DEPENDS
   intrinsics_gen
-  )
-
-add_dependencies(MLIRLinalgTransforms
   MLIRLinalgTransformPatternsIncGen
   )
 target_link_libraries(MLIRLinalgTransforms
diff --git a/mlir/lib/Dialect/LoopOps/CMakeLists.txt b/mlir/lib/Dialect/LoopOps/CMakeLists.txt
index f41e22d..2d0fdc8 100644
--- a/mlir/lib/Dialect/LoopOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/LoopOps/CMakeLists.txt
@@ -5,8 +5,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps
-  )
-add_dependencies(MLIRLoopOps
+
+  DEPENDS
   MLIRLoopLikeInterfaceIncGen
   MLIRLoopOpsIncGen
   )
diff --git a/mlir/lib/Dialect/OpenMP/CMakeLists.txt b/mlir/lib/Dialect/OpenMP/CMakeLists.txt
index deec87c..68a939e 100644
--- a/mlir/lib/Dialect/OpenMP/CMakeLists.txt
+++ b/mlir/lib/Dialect/OpenMP/CMakeLists.txt
@@ -3,9 +3,11 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/OpenMP
-  )
 
-add_dependencies(MLIROpenMP MLIROpenMPOpsIncGen)
+  DEPENDS
+  MLIROpenMPOpsIncGen
+  )
 target_link_libraries(MLIROpenMP
   PUBLIC
-  MLIRIR)
+  MLIRIR
+  )
diff --git a/mlir/lib/Dialect/QuantOps/CMakeLists.txt b/mlir/lib/Dialect/QuantOps/CMakeLists.txt
index f7fbd6c0..1ae171d 100644
--- a/mlir/lib/Dialect/QuantOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/QuantOps/CMakeLists.txt
@@ -11,8 +11,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/QuantOps
-  )
-add_dependencies(MLIRQuantOps
+
+  DEPENDS
   MLIRQuantOpsIncGen
   )
 target_link_libraries(MLIRQuantOps
diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
index 0e51df3..137e94c 100644
--- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
@@ -13,9 +13,7 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
-  )
 
-add_dependencies(MLIRSPIRV
   MLIRControlFlowInterfacesIncGen
   MLIRSPIRVAvailabilityIncGen
   MLIRSPIRVCanonicalizationIncGen
@@ -23,14 +21,15 @@
   MLIRSPIRVEnumsIncGen
   MLIRSPIRVOpsIncGen
   MLIRSPIRVOpUtilsGen
-  MLIRSPIRVTargetAndABIIncGen)
-
+  MLIRSPIRVTargetAndABIIncGen
+  )
 target_link_libraries(MLIRSPIRV
   PUBLIC
   MLIRIR
   MLIRParser
   MLIRSupport
-  MLIRTransforms)
+  MLIRTransforms
+  )
 
 add_subdirectory(Serialization)
 add_subdirectory(Transforms)
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/Serialization/CMakeLists.txt
index 54909be..8f24491 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/Serialization/CMakeLists.txt
@@ -6,14 +6,14 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+  DEPENDS
+  MLIRSPIRVSerializationGen
   )
-
-add_dependencies(MLIRSPIRVSerialization
-  MLIRSPIRVSerializationGen)
-
 target_link_libraries(MLIRSPIRVSerialization
   PUBLIC
   MLIRIR
   MLIRSPIRV
   MLIRSupport
-  MLIRTranslation)
+  MLIRTranslation
+  )
diff --git a/mlir/lib/Dialect/StandardOps/CMakeLists.txt b/mlir/lib/Dialect/StandardOps/CMakeLists.txt
index 578e90b..54a9a8a 100644
--- a/mlir/lib/Dialect/StandardOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/StandardOps/CMakeLists.txt
@@ -5,8 +5,8 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps
-  )
-add_dependencies(MLIRStandardOps
+
+  DEPENDS
   MLIRCallOpInterfacesIncGen
   MLIRControlFlowInterfacesIncGen
   MLIRStandardOpsIncGen
diff --git a/mlir/lib/Dialect/VectorOps/CMakeLists.txt b/mlir/lib/Dialect/VectorOps/CMakeLists.txt
index 87f3ca3..425eec3 100644
--- a/mlir/lib/Dialect/VectorOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/VectorOps/CMakeLists.txt
@@ -6,15 +6,16 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/VectorOps
+
+  DEPENDS
+  MLIRVectorOpsIncGen
+  MLIRVectorTransformPatternsIncGen
   )
-
-add_dependencies(MLIRVectorOps MLIRVectorOpsIncGen)
-add_dependencies(MLIRVectorOps MLIRVectorTransformPatternsIncGen)
-
 target_link_libraries(MLIRVectorOps
   PUBLIC
   MLIRIR
   MLIRStandardOps
   MLIRAffineOps
   MLIRLoopOps
-  MLIRLoopAnalysis)
+  MLIRLoopAnalysis
+  )
diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt
index 4f473f6..68ccaec 100644
--- a/mlir/lib/IR/CMakeLists.txt
+++ b/mlir/lib/IR/CMakeLists.txt
@@ -4,12 +4,13 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/IR
-  )
-add_dependencies(MLIRIR
+
+  DEPENDS
   MLIRCallOpInterfacesIncGen
   MLIROpAsmInterfacesIncGen
   )
 target_link_libraries(MLIRIR
   PUBLIC
   MLIRSupport
-  LLVMSupport)
+  LLVMSupport
+  )
diff --git a/mlir/lib/Quantizer/CMakeLists.txt b/mlir/lib/Quantizer/CMakeLists.txt
index 23dca84..f5ec9a4 100644
--- a/mlir/lib/Quantizer/CMakeLists.txt
+++ b/mlir/lib/Quantizer/CMakeLists.txt
@@ -25,17 +25,20 @@
   Configurations/FxpMathConfig.cpp
 
   ADDITIONAL_HEADER_DIRS
-  )
 
-add_dependencies(MLIRQuantizerFxpMathConfig
+  DEPENDS
   MLIRFxpMathOpsIncGen
   )
+
 target_link_libraries(MLIRQuantizerFxpMathConfig
   PUBLIC
   MLIRIR
   MLIRFxpMathOps
   MLIRQuantOps
   MLIRQuantizerSupport
+  MLIRStandardOps
+  MLIRSupport
+  LLVMSupport
   )
 
 # Transforms.
diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt
index 8ead50c..35b24e0 100644
--- a/mlir/lib/Transforms/CMakeLists.txt
+++ b/mlir/lib/Transforms/CMakeLists.txt
@@ -26,11 +26,12 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
+
+  DEPENDS
+  MLIRLoopLikeInterfaceIncGen
+  MLIRStandardOpsIncGen
   )
 
-add_dependencies(MLIRTransforms
-  MLIRLoopLikeInterfaceIncGen
-  MLIRStandardOpsIncGen)
 target_link_libraries(MLIRTransforms
   PUBLIC
   MLIRAffineOps
diff --git a/mlir/lib/Transforms/Utils/CMakeLists.txt b/mlir/lib/Transforms/Utils/CMakeLists.txt
index 79564b2..3893e4e 100644
--- a/mlir/lib/Transforms/Utils/CMakeLists.txt
+++ b/mlir/lib/Transforms/Utils/CMakeLists.txt
@@ -9,9 +9,11 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
+
+  DEPENDS
+  MLIRStandardOpsIncGen
   )
 
-add_dependencies(MLIRTransformUtils MLIRStandardOpsIncGen)
 target_link_libraries(MLIRTransformUtils
   PUBLIC
   MLIRAffineOps
diff --git a/mlir/test/lib/TestDialect/CMakeLists.txt b/mlir/test/lib/TestDialect/CMakeLists.txt
index 1a5f669..e666f97 100644
--- a/mlir/test/lib/TestDialect/CMakeLists.txt
+++ b/mlir/test/lib/TestDialect/CMakeLists.txt
@@ -14,14 +14,15 @@
 add_llvm_library(MLIRTestDialect
   TestDialect.cpp
   TestPatterns.cpp
-)
-add_dependencies(MLIRTestDialect
+
+  DEPENDS
   MLIRControlFlowInterfacesIncGen
   MLIRTestOpsIncGen
   MLIRTypeInferOpInterfaceIncGen
 )
 target_link_libraries(MLIRTestDialect
   PUBLIC
+  MLIRAnalysis
   MLIRDialect
   MLIRIR
   MLIRLinalgTransforms
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt
index 054fac2..e98623c 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -22,15 +22,18 @@
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
+
+  DEPENDS
+  MLIRStandardOpsIncGen
+  MLIRTestLinalgTransformPatternsIncGen
+  MLIRTestVectorTransformPatternsIncGen
 )
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../TestDialect)
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../TestDialect)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../DeclarativeTransforms)
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../DeclarativeTransforms)
-add_dependencies(MLIRTestTransforms MLIRStandardOpsIncGen)
-add_dependencies(MLIRTestTransforms MLIRTestLinalgTransformPatternsIncGen)
-add_dependencies(MLIRTestTransforms MLIRTestVectorTransformPatternsIncGen)
+
 target_link_libraries(MLIRTestTransforms
   PUBLIC
   MLIRAffineOps
diff --git a/mlir/tools/mlir-cuda-runner/CMakeLists.txt b/mlir/tools/mlir-cuda-runner/CMakeLists.txt
index 40cbced..f669cfb 100644
--- a/mlir/tools/mlir-cuda-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cuda-runner/CMakeLists.txt
@@ -69,8 +69,10 @@
 
   add_llvm_tool(mlir-cuda-runner
     mlir-cuda-runner.cpp
-  )
-  add_dependencies(mlir-cuda-runner cuda-runtime-wrappers)
+
+    DEPENDS
+    cuda-runtime-wrappers
+    )
   target_include_directories(mlir-cuda-runner
     PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
   )