@@ -745,6 +745,10 @@ file(WRITE ${DUMMY_EMPTY_FILE} ${DUMMY_FILE_CONTENT})
745
745
# Wrapper library for people who link against torch and expect both CPU and CUDA support
746
746
# Contains "torch_cpu" and "torch_cuda"
747
747
add_library (torch ${DUMMY_EMPTY_FILE} )
748
+ if (BUILD_SPLIT_CUDA )
749
+ # When we split torch_cuda, we want a dummy torch_cuda library that contains both parts
750
+ add_library (torch_cuda ${DUMMY_EMPTY_FILE} )
751
+ endif ()
748
752
if (HAVE_SOVERSION )
749
753
set_target_properties (torch PROPERTIES
750
754
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION} )
@@ -1237,34 +1241,39 @@ endif()
1237
1241
1238
1242
caffe2_interface_library (torch_cpu torch_cpu_library )
1239
1243
1240
- if (BUILD_SPLIT_CUDA )
1241
- caffe2_interface_library (torch_cuda_cu torch_cuda_cu_library )
1242
- caffe2_interface_library (torch_cuda_cpp torch_cuda_cpp_library )
1243
- elseif (USE_CUDA )
1244
+ if (USE_CUDA )
1244
1245
caffe2_interface_library (torch_cuda torch_cuda_library )
1246
+ if (BUILD_SPLIT_CUDA )
1247
+ caffe2_interface_library (torch_cuda_cu torch_cuda_cu_library )
1248
+ caffe2_interface_library (torch_cuda_cpp torch_cuda_cpp_library )
1249
+ endif ()
1245
1250
elseif (USE_ROCM )
1246
1251
caffe2_interface_library (torch_hip torch_hip_library )
1247
1252
endif ()
1248
1253
1249
1254
caffe2_interface_library (torch torch_library )
1250
1255
1251
1256
install (TARGETS torch_cpu torch_cpu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1252
- if (BUILD_SPLIT_CUDA )
1253
- install (TARGETS torch_cuda_cu torch_cuda_cu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1254
- install (TARGETS torch_cuda_cpp torch_cuda_cpp_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1255
- elseif (USE_CUDA )
1257
+
1258
+ if (USE_CUDA )
1256
1259
install (TARGETS torch_cuda torch_cuda_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1260
+ if (BUILD_SPLIT_CUDA )
1261
+ install (TARGETS torch_cuda_cu torch_cuda_cu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1262
+ install (TARGETS torch_cuda_cpp torch_cuda_cpp_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1263
+ endif ()
1257
1264
elseif (USE_ROCM )
1258
1265
install (TARGETS torch_hip torch_hip_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1259
1266
endif ()
1260
1267
install (TARGETS torch torch_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR} " )
1261
1268
1262
1269
target_link_libraries (torch PUBLIC torch_cpu_library )
1263
- if (BUILD_SPLIT_CUDA )
1264
- target_link_libraries (torch PUBLIC torch_cuda_cu_library )
1265
- target_link_libraries (torch PUBLIC torch_cuda_cpp_library )
1266
- elseif (USE_CUDA )
1270
+
1271
+ if (USE_CUDA )
1267
1272
target_link_libraries (torch PUBLIC torch_cuda_library )
1273
+ if (BUILD_SPLIT_CUDA )
1274
+ target_link_libraries (torch_cuda PUBLIC torch_cuda_cu_library )
1275
+ target_link_libraries (torch_cuda PUBLIC torch_cuda_cpp_library )
1276
+ endif ()
1268
1277
elseif (USE_ROCM )
1269
1278
target_link_libraries (torch PUBLIC torch_hip_library )
1270
1279
endif ()
0 commit comments