CMakeLists.txt 829 B

1234567891011121314151617181920
  1. cmake_minimum_required(VERSION 3.10)
  2. project(hello-world)
  3. # The first thing do is to tell cmake to find the TorchVision library.
  4. # The package pulls in all the necessary torch libraries,
  5. # so there is no need to also add `find_package(Torch)` here.
  6. find_package(TorchVision REQUIRED)
  7. # This due to LibTorch's version is the one included in the Python
  8. # package that links to Python.
  9. find_package(Python3 COMPONENTS Development)
  10. add_executable(hello-world main.cpp)
  11. # We now need to link the TorchVision library to our executable.
  12. # We can do that by using the TorchVision::TorchVision target,
  13. # which also adds all the necessary torch dependencies.
  14. target_compile_features(hello-world PUBLIC cxx_range_for)
  15. target_link_libraries(hello-world TorchVision::TorchVision)
  16. set_property(TARGET hello-world PROPERTY CXX_STANDARD 17)