[mlir][python] Install generated dialect sources.
authorStella Laurenzo <stellaraccident@gmail.com>
Wed, 30 Dec 2020 02:06:24 +0000 (18:06 -0800)
committerStella Laurenzo <stellaraccident@gmail.com>
Wed, 30 Dec 2020 04:15:07 +0000 (20:15 -0800)
Differential Revision: https://reviews.llvm.org/D93928

mlir/lib/Bindings/Python/CMakeLists.txt

index 0f51ce5..83e978a 100644 (file)
@@ -71,4 +71,23 @@ if (NOT LLVM_ENABLE_IDE)
     COMPONENT MLIRBindingsPythonSources)
 endif()
 
+# Dialect sources are generated. Install separately.
+# Note that __pycache__ directories may have been left by tests and other
+# executions. And __init__.py is handled as a regular source file.
+install(
+  DIRECTORY ${PROJECT_BINARY_DIR}/python/mlir/dialects
+  DESTINATION python/mlir
+  COMPONENT MLIRBindingsPythonDialects
+  FILES_MATCHING PATTERN "*.py"
+  PATTERN "__pycache__" EXCLUDE
+  PATTERN "__init__.py" EXCLUDE
+)
+
+if (NOT LLVM_ENABLE_IDE)
+  add_llvm_install_targets(
+    install-MLIRBindingsPythonDialects
+    DEPENDS MLIRBindingsPythonSources
+    COMPONENT MLIRBindingsPythonDialects)
+endif()
+
 add_subdirectory(Transforms)