Nice work and really useful. I had troubles on Mac OS x when using find_package(Matlab) in Cmake. I changed one line in your CmakeLists.txt and it worked flawless:
find_package(Matlab COMPONENTS MX_LIBRARY ENG_LIBRARY)
It is also possible to specify the Torch path directly if someone meets issues when including the Pytorch library:
find_package(Torch REQUIRED PATHS […YOUR PATH…]/libtorch)