CMakeLists.txt 1.1 KB

123456789101112131415161718192021222324252627
  1. cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
  2. project(cyclegan-jit)
  3. find_package(Torch REQUIRED)
  4. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
  5. add_executable(cyclegan-jit cyclegan_jit.cpp)
  6. target_link_libraries(cyclegan-jit pthread jpeg X11)
  7. target_link_libraries(cyclegan-jit "${TORCH_LIBRARIES}")
  8. set_property(TARGET cyclegan-jit PROPERTY CXX_STANDARD 14)
  9. add_executable(cyclegan-cpp-api cyclegan_cpp_api.cpp)
  10. target_link_libraries(cyclegan-cpp-api pthread jpeg X11)
  11. target_link_libraries(cyclegan-cpp-api "${TORCH_LIBRARIES}")
  12. set_property(TARGET cyclegan-cpp-api PROPERTY CXX_STANDARD 14)
  13. # The following code block is suggested to be used on Windows.
  14. # According to https://github.com/pytorch/pytorch/issues/25457,
  15. # the DLLs need to be copied to avoid memory errors.
  16. if (MSVC)
  17. file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
  18. add_custom_command(TARGET cyclegan-jit
  19. POST_BUILD
  20. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  21. ${TORCH_DLLS}
  22. $<TARGET_FILE_DIR:example-app>)
  23. endif (MSVC)