find_package(Torch REQUIRED) fails - 2.3.1 and nightly

I’m working on pytorch opencl backend and I’m failing to use find_package on latest pytorch versions (I use CPU version)

I installed pytorch in virtual environment (checked for both 2.3.1 and nightly)

I have CMakeLists with line

find_package(Torch REQUIRED)

I run cmake

cmake -DCMAKE_PREFIX_PATH=$VIRTUAL_ENV/lib/python3.12/site-packages/torch/share/cmake/Torch ..

And get an error

CMake Error at /home/artik/Projects/venv/pt_3.12_nightly/lib/python3.12/site-packages/torch/share/cmake/Caffe2/public/mkl.cmake:8 (target_include_directories):
  Cannot specify include directories for imported target "caffe2::mkl".
Call Stack (most recent call first):
  /home/artik/Projects/venv/pt_3.12_nightly/lib/python3.12/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:106 (include)
  /home/artik/Projects/venv/pt_3.12_nightly/lib/python3.12/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:4 (find_package)

It works with older pytorch versions 2.1.1 or 1.1.13

Does anybody know how to solve it?

I updated to cmake 3.26 and it solved