--- a/c10/CMakeLists.txt +++ b/c10/CMakeLists.txt @@ -161,7 +161,10 @@ # Note: for now, we will put all export path into one single Caffe2Targets group # to deal with the cmake deployment need. Inside the Caffe2Targets set, the # individual libraries like libc10.so and libcaffe2.so are still self-contained. - install(TARGETS c10 EXPORT Caffe2Targets DESTINATION lib) + install(TARGETS c10 EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} --- a/c10/cuda/CMakeLists.txt +++ b/c10/cuda/CMakeLists.txt @@ -86,7 +86,10 @@ # Note: for now, we will put all export path into one single Caffe2Targets group # to deal with the cmake deployment need. Inside the Caffe2Targets set, the # individual libraries like libc10.so and libcaffe2.so are still self-contained. -install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION lib) +install(TARGETS c10_cuda EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() --- a/c10/hip/CMakeLists.txt +++ b/c10/hip/CMakeLists.txt @@ -56,7 +56,10 @@ $ $ $) - install(TARGETS c10_hip EXPORT Caffe2Targets DESTINATION lib) + install(TARGETS c10_hip EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") set(C10_HIP_LIB c10_hip) endif() --- a/c10/xpu/CMakeLists.txt +++ b/c10/xpu/CMakeLists.txt @@ -49,7 +49,10 @@ $ $ ) - install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION lib) + install(TARGETS c10_xpu EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") set(C10_XPU_LIB c10_xpu) add_subdirectory(test) endif() --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -573,7 +573,10 @@ endif() target_link_libraries(caffe2_nvrtc PRIVATE caffe2::nvrtc ${DELAY_LOAD_FLAGS}) - install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS caffe2_nvrtc + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") if(USE_NCCL) list(APPEND Caffe2_GPU_SRCS ${TORCH_SRC_DIR}/csrc/cuda/nccl.cpp) @@ -656,7 +659,10 @@ target_link_libraries(caffe2_nvrtc hip::amdhip64 hiprtc::hiprtc) target_include_directories(caffe2_nvrtc PRIVATE ${CMAKE_BINARY_DIR}) target_compile_definitions(caffe2_nvrtc PRIVATE USE_ROCM __HIP_PLATFORM_AMD__) - install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS caffe2_nvrtc + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() if(NOT NO_API AND NOT BUILD_LITE_INTERPRETER) @@ -1067,7 +1073,10 @@ target_compile_definitions(torch_cuda PUBLIC USE_NVSHMEM) target_compile_definitions(torch_nvshmem PUBLIC USE_NVSHMEM) target_link_libraries(torch_cuda PRIVATE torch_nvshmem) - install(TARGETS torch_nvshmem EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_nvshmem EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") else() message(STATUS "NVSHMEM not found, not building with NVSHMEM support.") endif() @@ -1130,7 +1139,10 @@ CUDA::culibos ${CMAKE_DL_LIBS}) endif() set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../aten/src/ATen/native/cuda/LinearAlgebraStubs.cpp PROPERTIES COMPILE_FLAGS "-DBUILD_LAZY_CUDA_LINALG") - install(TARGETS torch_cuda_linalg DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_cuda_linalg + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() if(USE_PRECOMPILED_HEADERS) @@ -1528,8 +1540,10 @@ target_link_libraries(torch_rocshmem PRIVATE roc::rocshmem) target_link_libraries(torch_hip PRIVATE torch_rocshmem) - install(TARGETS torch_rocshmem EXPORT Caffe2Targets DESTINATION - "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_rocshmem EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") elseif(rocshmem_FOUND) message(STATUS "rocSHMEM found but skipped: PYTORCH_ROCM_ARCH has no entry in " @@ -1676,17 +1690,32 @@ caffe2_interface_library(torch torch_library) -install(TARGETS torch_cpu torch_cpu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") +install(TARGETS torch_cpu torch_cpu_library EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") if(USE_CUDA) - install(TARGETS torch_cuda torch_cuda_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_cuda torch_cuda_library EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") elseif(USE_ROCM) - install(TARGETS torch_hip torch_hip_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_hip torch_hip_library EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") elseif(USE_XPU) - install(TARGETS torch_xpu torch_xpu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_xpu torch_xpu_library EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() -install(TARGETS torch torch_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}") +install(TARGETS torch torch_library EXPORT Caffe2Targets + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") target_link_libraries(torch PUBLIC torch_cpu_library) @@ -1829,7 +1858,10 @@ target_link_libraries(torch_global_deps torch::nvtoolsext) endif() endif() - install(TARGETS torch_global_deps DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS torch_global_deps + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() # ---[ Caffe2 HIP sources. --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -459,7 +459,10 @@ set_target_properties(torch_python PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS}) endif() -install(TARGETS torch_python DESTINATION "${TORCH_INSTALL_LIB_DIR}") +install(TARGETS torch_python + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") # Generate torch/version.py from the appropriate CMake cache variables. if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") --- a/test/cpp/c10d/CMakeLists.txt +++ b/test/cpp/c10d/CMakeLists.txt @@ -79,7 +79,10 @@ LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main __caffe2_nccl INSTALL_TEST ${INSTALL_TEST}) target_compile_definitions(NCCLDevCommManagerTest PRIVATE USE_CUDA USE_NCCL) if(INSTALL_TEST) - install(TARGETS c10d_cuda_test DESTINATION lib) + install(TARGETS c10d_cuda_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() endif() if(USE_UCC AND USE_C10D_UCC) @@ -91,7 +94,10 @@ ProcessGroupUCCTest.cpp LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main __caffe2_ucc INSTALL_TEST ${INSTALL_TEST}) if(INSTALL_TEST) - install(TARGETS c10d_cuda_test DESTINATION lib) + install(TARGETS c10d_cuda_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() endif() elseif(USE_ROCM) @@ -107,7 +113,10 @@ hip/ProcessGroupNCCLErrorsTest.cpp LINK_LIBRARIES torch_cpu c10d_hip_test gtest_main __caffe2_nccl INSTALL_TEST ${INSTALL_TEST}) if(INSTALL_TEST) - install(TARGETS c10d_hip_test DESTINATION lib) + install(TARGETS c10d_hip_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() endif() if(USE_UCC AND USE_C10D_UCC) @@ -115,7 +124,10 @@ hip/ProcessGroupUCCTest.cpp LINK_LIBRARIES torch_cpu c10d_hip_test gtest_main __caffe2_ucc INSTALL_TEST ${INSTALL_TEST}) if(INSTALL_TEST) - install(TARGETS c10d_hip_test DESTINATION lib) + install(TARGETS c10d_hip_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() endif() else() --- a/test/cpp/jit/CMakeLists.txt +++ b/test/cpp/jit/CMakeLists.txt @@ -32,9 +32,18 @@ target_link_libraries(backend_with_compiler torch) if(INSTALL_TEST) - install(TARGETS torchbind_test DESTINATION lib) - install(TARGETS jitbackend_test DESTINATION lib) - install(TARGETS backend_with_compiler DESTINATION lib) + install(TARGETS torchbind_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS jitbackend_test + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") + install(TARGETS backend_with_compiler + RUNTIME DESTINATION "${TORCH_INSTALL_BIN_DIR}" + LIBRARY DESTINATION "${TORCH_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}") endif() # Build the cpp gtest binary containing the cpp-only tests.