| cmake_minimum_required(VERSION 3.8) | |
| project(midigpt_torch) | |
| set(SRCS | |
| src/torch_library.cpp | |
| "include/torch_library.h") | |
| set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../libtorch/") | |
| find_package(Torch REQUIRED) | |
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") | |
| add_library(midigpt_torch | |
| ${SRCS}) | |
| target_link_libraries(midigpt_torch PRIVATE "${TORCH_LIBRARIES}") | |
| if (MSVC) | |
| file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll") | |
| add_custom_command(TARGET example-app | |
| POST_BUILD | |
| COMMAND ${CMAKE_COMMAND} -E copy_if_different | |
| ${TORCH_DLLS} | |
| $<TARGET_FILE_DIR:example-app>) | |
| endif (MSVC) |