在https://pytorch.org/cppdocs/installing.html之后,我有
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
include_directories(
"${TORCH_INCLUDE_DIRS}" # libtorch headers
)
add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)
这可行,但链接到共享的 Torch 库;我怎样才能链接到静态的呢?