Skip to content

Commit

Permalink
Remove unneeded linking in CMake targets (#109192)
Browse files Browse the repository at this point in the history
This PR removes unused library dependencies, help refactoring in the future.

Pull Request resolved: #109192
Approved by: https://github.com/ezyang
  • Loading branch information
cyyever authored and pytorchmergebot committed Sep 15, 2023
1 parent d3a64ff commit 4c208c1
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 57 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_LINK_WHAT_YOU_USE TRUE)

# One variable that determines whether the current cmake process is being run
# with the main Caffe2 library. This is useful for building modules - if
Expand Down
4 changes: 0 additions & 4 deletions aten/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ set(ATEN_INSTALL_LIB_SUBDIR "lib" CACHE PATH "ATen install library subdirectory"
set(ATEN_INSTALL_INCLUDE_SUBDIR "include" CACHE PATH "ATen install include subdirectory")
set(MEM_EFF_ATTENTION_CUDA_SOURCES)

if(USE_CUDA)
list(APPEND ATen_CUDA_INCLUDE ${CUDA_INCLUDE_DIRS})
endif()

set(TH_LINK_STYLE STATIC)
set(TH_CPU_INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/src
Expand Down
2 changes: 0 additions & 2 deletions aten/src/ATen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ if(USE_CUDA AND NOT USE_ROCM)
list(APPEND ATen_CUDA_DEPENDENCY_LIBS
${CUDA_LIBRARIES}
CUDA::cusparse_static
CUDA::curand_static
CUDA::cufft_static_nocallback
)
if(NOT BUILD_LAZY_CUDA_LINALG)
Expand All @@ -466,7 +465,6 @@ if(USE_CUDA AND NOT USE_ROCM)
list(APPEND ATen_CUDA_DEPENDENCY_LIBS
${CUDA_LIBRARIES}
CUDA::cusparse
CUDA::curand
CUDA::cufft
)
if(NOT BUILD_LAZY_CUDA_LINALG)
Expand Down
3 changes: 1 addition & 2 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,7 @@ if(USE_CUDA)
set(DELAY_LOAD_FLAGS "")
endif()

target_link_libraries(caffe2_nvrtc ${CUDA_NVRTC} ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB} ${DELAY_LOAD_FLAGS})
target_include_directories(caffe2_nvrtc PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(caffe2_nvrtc ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB} ${DELAY_LOAD_FLAGS})
install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}")
if(USE_NCCL)
list(APPEND Caffe2_GPU_SRCS
Expand Down
8 changes: 0 additions & 8 deletions test/cpp/aot_inductor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ target_link_libraries(test_aot_inductor PRIVATE
)

if(USE_CUDA)
target_link_libraries(test_aot_inductor PRIVATE
${C10_CUDA_BUILD_SHARED_LIBS}
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES}
)

target_include_directories(test_aot_inductor PRIVATE ${ATen_CUDA_INCLUDE})

target_compile_definitions(test_aot_inductor PRIVATE USE_CUDA)
Expand Down
6 changes: 0 additions & 6 deletions test/cpp/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ if(NOT MSVC)
endif()

if(USE_CUDA)
target_link_libraries(test_api PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_api PRIVATE "USE_CUDA")
endif()

Expand Down
6 changes: 0 additions & 6 deletions test/cpp/dist_autograd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ if(USE_DISTRIBUTED AND NOT WIN32)
target_link_libraries(test_dist_autograd PRIVATE torch gtest)

if(USE_CUDA)
target_link_libraries(test_dist_autograd PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_dist_autograd PRIVATE "USE_CUDA")
endif()

Expand Down
6 changes: 0 additions & 6 deletions test/cpp/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ if(LINUX)
endif()

if(USE_CUDA)
target_link_libraries(test_jit PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_jit PRIVATE USE_CUDA)
# Suppress sign compare checks for NVFUSER JIT tests
if(NOT MSVC)
Expand Down
6 changes: 0 additions & 6 deletions test/cpp/lazy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ target_link_libraries(test_lazy PRIVATE ${LAZY_TEST_DEPENDENCIES})
target_include_directories(test_lazy PRIVATE ${ATen_CPU_INCLUDE})

if(USE_CUDA)
target_link_libraries(test_lazy PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_lazy PRIVATE USE_CUDA)
elseif(USE_ROCM)
target_link_libraries(test_lazy PRIVATE
Expand Down
6 changes: 0 additions & 6 deletions test/cpp/rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ target_include_directories(
target_link_libraries(test_cpp_rpc PRIVATE ${TORCH_RPC_TEST_DEPENDENCY_LIBS})

if(USE_CUDA)
target_link_libraries(test_cpp_rpc PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_cpp_rpc PRIVATE "USE_CUDA")
endif()

Expand Down
11 changes: 0 additions & 11 deletions test/cpp/tensorexpr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,7 @@ if(USE_PTHREADPOOL)
target_link_libraries(test_tensorexpr PRIVATE pthreadpool_interface)
endif()
if(USE_CUDA)
target_link_libraries(test_tensorexpr PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})
target_compile_definitions(test_tensorexpr PRIVATE USE_CUDA)

target_link_libraries(tutorial_tensorexpr PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})
target_compile_definitions(tutorial_tensorexpr PRIVATE USE_CUDA)
elseif(USE_ROCM)
target_link_libraries(test_tensorexpr PRIVATE
Expand Down

0 comments on commit 4c208c1

Please sign in to comment.