Libtorch C++ build 'Could NOT find Torch (missing: TORCH_LIBRARY)'

os: Windows 10
ide: clion

====================[ Build | app | Debug ]=====================================
D:\software\cygwin64\bin\cmake.exe --build /cygdrive/d/cpp_extension/app/cmake-build-debug --target app -- -j 6
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
CMake Error at /usr/share/cmake-3.14.5/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Torch (missing: TORCH_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.14.5/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  D:/cpp_extension/libtorch/share/cmake/Torch/TorchConfig.cmake:135 (find_package_handle_standard_args)
  CMakeLists.txt:5 (find_package)


-- Configuring incomplete, errors occurred!
See also "/cygdrive/d/cpp_extension/app/cmake-build-debug/CMakeFiles/CMakeOutput.log".
make: *** [Makefile:176: cmake_check_build_system] Error 1

cmakelist

cmake_minimum_required(VERSION 3.14)
project(app)

set(CMAKE_PREFIX_PATH "D:\\cpp_extension\\libtorch")
find_package(Torch REQUIRED)

add_executable(app main.cpp)
target_link_libraries(app "${TORCH_LIBRARIES}")
set_property(TARGET app PROPERTY CXX_STANDARD 14)

@albanD Is there any solution?

Hi,

I am afraid I don’t know, especially for Windows build system :confused:

thanks, libtorch maybe be buit by MSVC. so it did not support cygwin :sob: