You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While debugging the build issue on #8322 w.r.t mkl, I undercover a complex interaction between #8322, #8248 (to install mkl), and https://github.com/pytorch/pytorch/blob/main/cmake/public/mkl.cmake from PyTorch. The error is as follows:
```
CMake Error at /opt/conda/envs/py_3.10/lib/cmake/mkl/MKLConfig.cmake:744 (add_library): <-- This file comes from conda mkl
add_library cannot create imported target "MKL::MKL" because another target
with the same name already exists.
Call Stack (most recent call first):
/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/share/cmake/Caffe2/public/mkl.cmake:1 (find_package) <-- this is from PyTorch
/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:106 (include)
/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
CMakeLists.txt:753 (find_package)
```
The conclusion is that, with mkl installed, there should be just one `find_package(Torch)` call because the mkl target is defined globally. The `torch` target, on the other hand, is only defined locally.
So, this change adds `if(NOT TARGET torch)` check to only call `find_package(Torch)` if needed.
### Testing
The change on top of #8322 looks like this f705b01https://github.com/pytorch/executorch/actions/runs/13278590926?pr=8399
0 commit comments