| 123456789101112131415161718192021222324252627282930313233343536 |
- cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
- project(cyclegan-jit)
- find_package(Torch REQUIRED)
- # Explicitly dealing with OpenMP seems to be needed with some C++
- # nightlies in March 2020. Probably a bug.
- find_package(OpenMP)
- if(OPENMP_FOUND)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
- endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
- add_executable(cyclegan-jit cyclegan_jit.cpp)
- target_link_libraries(cyclegan-jit pthread jpeg X11)
- target_link_libraries(cyclegan-jit "${TORCH_LIBRARIES}")
- set_property(TARGET cyclegan-jit PROPERTY CXX_STANDARD 14)
- add_executable(cyclegan-cpp-api cyclegan_cpp_api.cpp)
- target_link_libraries(cyclegan-cpp-api pthread jpeg X11)
- target_link_libraries(cyclegan-cpp-api "${TORCH_LIBRARIES}")
- set_property(TARGET cyclegan-cpp-api PROPERTY CXX_STANDARD 14)
- # The following code block is suggested to be used on Windows.
- # According to https://github.com/pytorch/pytorch/issues/25457,
- # the DLLs need to be copied to avoid memory errors.
- if (MSVC)
- file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
- add_custom_command(TARGET cyclegan-jit
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${TORCH_DLLS}
- $<TARGET_FILE_DIR:example-app>)
- endif (MSVC)
|