[Mlir-commits] [mlir] 438f805 - [mlir] Configure mlir so that it can be directly included in a parent cmakelists.txt
Stella Stamenova
llvmlistbot at llvm.org
Wed Jan 19 12:02:50 PST 2022
Author: Stella Stamenova
Date: 2022-01-19T12:02:22-08:00
New Revision: 438f805145212a67d15b5950c4628298d65f7903
URL: https://github.com/llvm/llvm-project/commit/438f805145212a67d15b5950c4628298d65f7903
DIFF: https://github.com/llvm/llvm-project/commit/438f805145212a67d15b5950c4628298d65f7903.diff
LOG: [mlir] Configure mlir so that it can be directly included in a parent cmakelists.txt
The goal is to allow a project to directly include the `CMakeLists.txt` of mlir via something such as `add_directory`. This currently doesn't work because the exported targets then end up being imported in the same top-level project and `cmake` is not happy. LLVM works around this by guarding the exports based on the existence of the `LLVMSupport` library. This change does the same using `MLIRSupport`. In our experience, no targets need to be added to the export in the case.
If there's a preferred way of doing this or a better lib to use as the main target to check for, please let me know.
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D117599
Added:
Modified:
mlir/cmake/modules/MLIRConfig.cmake.in
Removed:
################################################################################
diff --git a/mlir/cmake/modules/MLIRConfig.cmake.in b/mlir/cmake/modules/MLIRConfig.cmake.in
index cab68ba01657c..6324a1d8bd38e 100644
--- a/mlir/cmake/modules/MLIRConfig.cmake.in
+++ b/mlir/cmake/modules/MLIRConfig.cmake.in
@@ -22,7 +22,12 @@ set_property(GLOBAL PROPERTY MLIR_CONVERSION_LIBS "@MLIR_CONVERSION_LIBS@")
set_property(GLOBAL PROPERTY MLIR_TRANSLATION_LIBS "@MLIR_TRANSLATION_LIBS@")
# Provide all our library targets to users.
- at MLIR_CONFIG_INCLUDE_EXPORTS@
+# More specifically, configure MLIR so that it can be directly included in a top
+# level CMakeLists.txt, but also so that it can be imported via `find_package`.
+# This is based on how LLVM handles exports.
+if(NOT TARGET MLIRSupport)
+ @MLIR_CONFIG_INCLUDE_EXPORTS@
+endif()
# By creating these targets here, subprojects that depend on MLIR's
# tablegen-generated headers can always depend on these targets whether building
More information about the Mlir-commits
mailing list