Fix out-of-tree cmake build of torch-mlir-dialects
#726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This follows up on #623 for out-of-tree builds of torch-mlir, which added building
torch-mir-dialects
as a subdirectory.We found that we needed some more
cmake
adaptions to make this work. We're initially opening this PR as a draft to gather opinions as to whether this approach suits at least the short-termtorch-mlir-dialects
goals.Our goal is to support both in-tree and out-of-tree builds of
torch-mlir
with minimum hassle, for instance by using the same variable names in both setups. Specifically inexternals/llvm-external-projects/torch-mlir-dialects/CMakeLists.txt
:MLIR_FOUND
to detect that it is being build as a subdirectory and the llvm+mlir cmake infrastructure is already set up (via find_package in the parent build) as opposed to an in-tree build.llvm-project
makes available throughfind_package(MLIR REQUIRED CONFIG)
, under the assumption that those are the more "standardized" names.Further optional items we could contribute if you're interested: