CMakeLists.txt 829 Bytes
Newer Older
1
2
3
4
5
6
7
8
cmake_minimum_required(VERSION 3.10)
project(hello-world)

# The first thing do is to tell cmake to find the TorchVision library.
# The package pulls in all the necessary torch libraries,
# so there is no need to also add `find_package(Torch)` here.
find_package(TorchVision REQUIRED)

9
10
11
12
# This due to LibTorch's version is the one included in the Python
# package that links to Python.
find_package(Python3 COMPONENTS Development)

13
14
15
16
17
add_executable(hello-world main.cpp)

# We now need to link the TorchVision library to our executable.
# We can do that by using the TorchVision::TorchVision target,
# which also adds all the necessary torch dependencies.
18
target_compile_features(hello-world PUBLIC cxx_range_for)
19
target_link_libraries(hello-world TorchVision::TorchVision)
Philip Meier's avatar
Philip Meier committed
20
set_property(TARGET hello-world PROPERTY CXX_STANDARD 17)