mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/62445 PyTorch currently uses the old style of compiling CUDA in CMake which is just a bunch of scripts in `FindCUDA.cmake`. Newer versions support CUDA natively as a language just like C++ or C. Test Plan: Imported from OSS Reviewed By: ejguan Differential Revision: D31503350 fbshipit-source-id: 2ee817edc9698531ae1b87eda3ad271ee459fd55
30 lines
778 B
CMake
30 lines
778 B
CMake
if(TARGET caffe2::Threads)
|
|
return()
|
|
endif()
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
# Threads::Threads doesn't work if the target has CUDA code
|
|
if(THREADS_FOUND)
|
|
add_library(caffe2::Threads INTERFACE IMPORTED)
|
|
|
|
if(THREADS_HAVE_PTHREAD_ARG)
|
|
set(compile_options
|
|
$<$<COMPILE_LANGUAGE:C>:-pthread>
|
|
$<$<COMPILE_LANGUAGE:CXX>:-pthread>)
|
|
if(USE_CUDA)
|
|
list(APPEND compile_options
|
|
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler -pthread>)
|
|
endif()
|
|
|
|
set_property(TARGET caffe2::Threads
|
|
PROPERTY INTERFACE_COMPILE_OPTIONS
|
|
${compile_options})
|
|
endif()
|
|
|
|
if(CMAKE_THREAD_LIBS_INIT)
|
|
set_property(TARGET caffe2::Threads
|
|
PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
|
endif()
|
|
endif()
|