This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Configure mlir so that it can be directly included in a parent cmakelists.txt
ClosedPublic

Authored by stella.stamenova on Jan 18 2022, 1:13 PM.

Details

Summary

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.

Diff Detail

Event Timeline

stella.stamenova requested review of this revision.Jan 18 2022, 1:13 PM
bondhugula added inline comments.
mlir/cmake/modules/MLIRConfig.cmake.in
25–30

It would be useful to have a comment here along the lines of your commit title.

stellaraccident accepted this revision.Jan 18 2022, 9:33 PM

LGTM modulo comments. I vaguely recall this kind of target sniffing having caused me problems in the past but I can't remember the details. Doing the same as llvm, sgtm.

This revision is now accepted and ready to land.Jan 18 2022, 9:33 PM