summaryrefslogtreecommitdiff
path: root/mlir/cmake/modules/MLIRConfig.cmake.in
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/cmake/modules/MLIRConfig.cmake.in')
-rw-r--r--mlir/cmake/modules/MLIRConfig.cmake.in35
1 files changed, 35 insertions, 0 deletions
diff --git a/mlir/cmake/modules/MLIRConfig.cmake.in b/mlir/cmake/modules/MLIRConfig.cmake.in
new file mode 100644
index 000000000000..190aa193d1db
--- /dev/null
+++ b/mlir/cmake/modules/MLIRConfig.cmake.in
@@ -0,0 +1,35 @@
+# This file allows users to call find_package(MLIR) and pick up our targets.
+
+@MLIR_CONFIG_CODE@
+
+find_package(LLVM REQUIRED CONFIG
+ HINTS "@MLIR_CONFIG_LLVM_CMAKE_DIR@")
+
+set(MLIR_EXPORTED_TARGETS "@MLIR_EXPORTS@")
+set(MLIR_CMAKE_DIR "@MLIR_CONFIG_CMAKE_DIR@")
+set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
+set(MLIR_TABLEGEN_EXE "@MLIR_TABLEGEN_EXE@")
+
+# For mlir_tablegen()
+set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
+set(MLIR_MAIN_SRC_DIR "@MLIR_MAIN_SRC_DIR@")
+
+set_property(GLOBAL PROPERTY MLIR_ALL_LIBS "@MLIR_ALL_LIBS@")
+set_property(GLOBAL PROPERTY MLIR_DIALECT_LIBS "@MLIR_DIALECT_LIBS@")
+set_property(GLOBAL PROPERTY MLIR_CONVERSION_LIBS "@MLIR_CONVERSION_LIBS@")
+
+# Provide all our library targets to users.
+include("@MLIR_CONFIG_EXPORTS_FILE@")
+
+# By creating these targets here, subprojects that depend on MLIR's
+# tablegen-generated headers can always depend on these targets whether building
+# in-tree with MLIR or not.
+if(NOT TARGET mlir-tablegen-targets)
+ add_custom_target(mlir-tablegen-targets)
+endif()
+if(NOT TARGET mlir-headers)
+ add_custom_target(mlir-headers)
+endif()
+if(NOT TARGET mlir-doc)
+ add_custom_target(mlir-doc)
+endif()