<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58570>58570</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] Configuring a CMake project that imports MLIR fails
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
strikef
</td>
</tr>
</table>
<pre>
Hello,
I'm working on a project based on MLIR.
This project is configured and built using CMake, and derives LLVM/MLIR's configurations from the cmake modules.
Recently, I started to get errors from CMake while trying to configure the project.
```
CMake Error at CMakeLists.txt:106 (add_library):
Cannot find source file:
<installed-mlir>/mlir/Dialect/SparseTensor/IR/Enums.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
.hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
```
This is weird, as `Enums.h` should be inside `<installed-mlir>/include/mlir/Dialect/SparseTensor/IR/Enums.h`.
I looked into this issue, and found that `MLIRTargets.cmake` is actually misconfigured.
```
set_target_properties(MLIRSparseTensorEnums PROPERTIES
INTERFACE_SOURCES "${_IMPORT_PREFIX}/mlir/Dialect/SparseTensor/IR/Enums.h"
)
```
After inserting `/include` into the path, the project would successfully configure and build alright.
e78247112ac2599bd682e16429bfceada4ac803d seems to be the commit where this issue first appeared.
Also, [these comments](https://github.com/llvm/llvm-project/commit/d8cb5d3c6e1883166d8d2a8dbb4b497a8fd37f4a) seem to be related to the issue that I stated above.
Many thanks in advance!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VUlv6zYQ_jXyhXiCTO0HHxLHRg3ETeD4Fb0ZlDiy2FCiQFJZ_n2HlJUFSFukBSrI46HImflmZaX46-oXkFIFdB1EN0F0tQto3pFnpR9FfyaqJ4wMWv0BtSUVM8Ddp_3t7hBOx4-tMG8HkK1V34jzqPEg6zmpRiE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