Remove AT_LINK_STYLE entirely. (#29729)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29729

It already errored when you built with CUDA/HIP support as no longer supported;
now I expunge it entirely.  Along the way, I delete useless INTERFACE
libraries (which aren't used anywhere else in the cmake.)

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D18571167

Pulled By: ezyang

fbshipit-source-id: f88c73a16fad3b61eaa7745a2d15514c68704bec
This commit is contained in:
Edward Yang
2019-11-18 07:03:16 -08:00
committed by Facebook Github Bot
parent 639133d6d1
commit 1381301d46
2 changed files with 5 additions and 73 deletions

View File

@ -122,9 +122,6 @@ filter_list(core_generated_h core_generated_cpp "\\.h$")
list(APPEND ATen_CPU_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/..)
# so the build can find the generated header files
list(APPEND ATen_CPU_INCLUDE ${CMAKE_CURRENT_BINARY_DIR})
IF(NOT AT_LINK_STYLE)
SET(AT_LINK_STYLE SHARED)
ENDIF()
IF (USE_TBB)
message("ATen is compiled with TBB (${TBB_ROOT_DIR})")
@ -355,39 +352,12 @@ list(APPEND ATen_HIP_INCLUDE ${ATen_CPU_INCLUDE})
# built when USE_CUDA=1 and CUDA is available. (libATen_hip.so works
# the same way as libATen_cuda.so)
set(ATen_CPU_SRCS ${all_cpu_cpp})
if(AT_LINK_STYLE STREQUAL "INTERFACE")
# Source code can't be added to an interface library, so it is
# passed back to be compiled into the containing library
add_library(ATen_cpu INTERFACE)
list(APPEND ATen_CPU_DEPENDENCY_LIBS ATEN_CPU_FILES_GEN_LIB)
else()
add_library(ATen_cpu ${AT_LINK_STYLE} ${ATen_CPU_SRCS})
if (ATen_THIRD_PARTY_INCLUDE)
target_include_directories(ATen_cpu SYSTEM PRIVATE ${ATen_THIRD_PARTY_INCLUDE})
endif()
target_include_directories(ATen_cpu INTERFACE $<INSTALL_INTERFACE:include>)
target_include_directories(ATen_cpu PRIVATE ${ATen_CPU_INCLUDE})
target_link_libraries(ATen_cpu PUBLIC ${ATen_CPU_DEPENDENCY_LIBS})
target_link_libraries(ATen_cpu PRIVATE ATEN_CPU_FILES_GEN_LIB)
caffe2_interface_library(ATen_cpu ATen_cpu_library)
# Set standard properties on the target
torch_set_target_props(ATen_cpu)
# Make sure these don't get built by parent
set(ATen_CPU_SRCS)
endif()
list(APPEND ATen_CPU_DEPENDENCY_LIBS ATEN_CPU_FILES_GEN_LIB)
if(USE_CUDA)
set(ATen_CUDA_SRCS ${all_cuda_cpp})
set(ATen_NVRTC_STUB_SRCS ${cuda_nvrtc_stub_cpp})
if(AT_LINK_STYLE STREQUAL "INTERFACE")
# Source code can't be added to an interface library, so it is
# passed back to be compiled into the containing library
add_library(ATen_cuda INTERFACE)
list(APPEND ATen_CUDA_DEPENDENCY_LIBS ATEN_CUDA_FILES_GEN_LIB)
else()
message(FATAL_ERROR "Non-INTERFACE AT_LINK_STYLE no longer supported")
endif()
list(APPEND ATen_CUDA_DEPENDENCY_LIBS ATEN_CUDA_FILES_GEN_LIB)
endif()
if(USE_ROCM)
@ -395,46 +365,9 @@ if(USE_ROCM)
# caffe2_nvrtc's stubs to driver APIs are useful for HIP.
# See NOTE [ ATen NVRTC Stub and HIP ]
set(ATen_NVRTC_STUB_SRCS ${hip_nvrtc_stub_cpp})
if(AT_LINK_STYLE STREQUAL "INTERFACE")
# Source code can't be added to an interface library, so it is
# passed back to be compiled into the containing library
add_library(ATen_hip INTERFACE)
# NB: Instead of adding it to this list, we add it by hand
# to caffe2_hip, because it needs to be a PRIVATE dependency
# list(APPEND ATen_HIP_DEPENDENCY_LIBS ATEN_CUDA_FILES_GEN_LIB)
else()
message(FATAL_ERROR "Non-INTERFACE AT_LINK_STYLE not (yet) supported for ROCm build")
endif()
endif()
if(NOT AT_LINK_STYLE STREQUAL "INTERFACE")
if(USE_CUDA)
if (NOT $ENV{ATEN_STATIC_CUDA})
cuda_add_cublas_to_target(ATen_cuda)
cuda_add_cufft_to_target(ATen_cuda)
endif()
endif()
if(NOT MSVC)
torch_compile_options(ATen_cpu)
if(USE_CUDA)
torch_compile_options(ATen_cuda)
endif()
if(USE_ROCM)
torch_compile_options(ATen_hip)
endif()
endif()
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.1")
set_property(TARGET ATen_cpu PROPERTY CXX_STANDARD 11)
if(USE_CUDA)
set_property(TARGET ATen_cuda PROPERTY CXX_STANDARD 11)
endif()
if(USE_ROCM)
set_property(TARGET ATen_hip PROPERTY CXX_STANDARD 11)
endif()
endif()
# NB: Instead of adding it to this list, we add it by hand
# to caffe2_hip, because it needs to be a PRIVATE dependency
# list(APPEND ATen_HIP_DEPENDENCY_LIBS ATEN_CUDA_FILES_GEN_LIB)
endif()
SET(ATEN_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${AT_INSTALL_INCLUDE_DIR}")

View File

@ -7,7 +7,6 @@ include(../cmake/Codegen.cmake)
if (INTERN_BUILD_ATEN_OPS)
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(AT_LINK_STYLE INTERFACE)
add_subdirectory(../aten aten)
set(CMAKE_POSITION_INDEPENDENT_CODE ${__caffe2_CMAKE_POSITION_INDEPENDENT_CODE})