Skip to content

libtorch: CMake 4.1: Error evaluating generator expression: TARGET_PROPERTY:torch,INTERFACE_LINK_LIBRARIES #160167

@miriameng

Description

@miriameng

🐛 Describe the bug

When using CMake 4.1, simply calling find_package(Torch CONFIG REQUIRED) results in the error below:

...
CMake Error at C:/Users/miriam/OneDrive/Desktop/libtorch-2.8.0/share/cmake/Caffe2/Caffe2Targets.cmake:126 (set_target_properties):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:torch,INTERFACE_LINK_LIBRARIES>

  $<TARGET_PROPERTY:...> expression in link libraries evaluation depends on
  target property which is transitive over the link libraries, creating a
  recursion.
Call Stack (most recent call first):
  C:/Users/miriam/OneDrive/Desktop/libtorch-2.8.0/share/cmake/Caffe2/Caffe2Config.cmake:121 (include)
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:893 (_find_package)
  C:/Users/miriam/OneDrive/Desktop/libtorch-2.8.0/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:893 (_find_package)
  train/CMakeLists.txt:3 (find_package)
...

The root cause is this PR from CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10391
Can someone please fix this?

Versions

libtorch-2.8.0
CMake 4.1

cc @malfet @seemethere @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @zou3519

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: buildBuild system issuesmodule: cpp-extensionsRelated to torch.utils.cpp_extensionmodule: windowsWindows support for PyTorchtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions