[mlir] Leverage CMake interface libraries for mlir python
authorStella Stamenova <stilis@microsoft.com>
Tue, 28 Jun 2022 17:39:13 +0000 (10:39 -0700)
committerStella Stamenova <stilis@microsoft.com>
Tue, 28 Jun 2022 17:42:58 +0000 (10:42 -0700)
commitac521d9ecde70bc8ad11d9e605b43658014fb5af
tree9e68ee70a8899e77af0c673134e96425b4dfd1db
parentf68454ee8fd5188986c2ef2741352bab9d57d6c1
[mlir] Leverage CMake interface libraries for mlir python

This is already partially the case, but we can rely more heavily on interface libraries and how they are imported/exported in other to simplify the implementation of the mlir python functions in Cmake.

This change also makes a couple of other changes:
1) Add a new CMake function which handles "pure" sources. This was done inline previously
2) Moves the headers associated with CAPI libraries to the libraries themselves. These were previously managed in a separate source target. They can now be added directly to the CAPI libraries using DECLARED_HEADERS.
3) Cleanup some dependencies that showed up as an issue during the refactor

This is a big CMake change that should produce no impact on the build of mlir and on the produced *build tree*. However, this change fixes an issue with the *install tree* of mlir which was previously unusable for projects like torch-mlir because both the "pure" and "extension" targets were pointing to either the build or source trees.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D128230
mlir/cmake/modules/AddMLIRPython.cmake
mlir/lib/Dialect/Affine/Analysis/CMakeLists.txt
mlir/python/CMakeLists.txt