mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Revert D31193205: [pytorch][PR] CMake: Limit python include directories to only python libraries
Test Plan: revert-hammer
Differential Revision:
D31193205 (971c57f1d0)
Original commit changeset: 5c1b554a59d0
fbshipit-source-id: 5719b7df987ded6e7e212749a438db947656df87
This commit is contained in:
parent
2670cacfc2
commit
9b40eaaaab
|
|
@ -1916,7 +1916,6 @@ if(BUILD_PYTHON)
|
|||
add_library(caffe2_pybind11_state MODULE ${Caffe2_CPU_PYTHON_SRCS})
|
||||
if(USE_NUMPY)
|
||||
target_compile_options(caffe2_pybind11_state PRIVATE "-DUSE_NUMPY")
|
||||
target_link_libraries(caffe2_pybind11_state PRIVATE numpy::numpy)
|
||||
endif()
|
||||
if(NOT MSVC)
|
||||
set_target_properties(caffe2_pybind11_state PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
|
||||
|
|
@ -1928,10 +1927,11 @@ if(BUILD_PYTHON)
|
|||
target_include_directories(caffe2_pybind11_state PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(caffe2_pybind11_state PRIVATE ${Caffe2_CPU_INCLUDE})
|
||||
|
||||
target_link_libraries(caffe2_pybind11_state PRIVATE
|
||||
torch_library python::python pybind::pybind11)
|
||||
target_link_libraries(
|
||||
caffe2_pybind11_state torch_library)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state PRIVATE onnx_proto)
|
||||
target_link_libraries(caffe2_pybind11_state ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(caffe2_pybind11_state onnx_proto)
|
||||
endif(WIN32)
|
||||
|
||||
# Install caffe2_pybind11_state(_gpu|hip) in site-packages/caffe2/python,
|
||||
|
|
@ -1949,7 +1949,6 @@ if(BUILD_PYTHON)
|
|||
add_library(caffe2_pybind11_state_gpu MODULE ${Caffe2_GPU_PYTHON_SRCS})
|
||||
if(USE_NUMPY)
|
||||
target_compile_options(caffe2_pybind11_state_gpu PRIVATE "-DUSE_NUMPY")
|
||||
target_link_libraries(caffe2_pybind11_state_gpu PRIVATE numpy::numpy)
|
||||
endif()
|
||||
if(NOT MSVC)
|
||||
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
|
||||
|
|
@ -1960,10 +1959,10 @@ if(BUILD_PYTHON)
|
|||
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
|
||||
target_include_directories(caffe2_pybind11_state_gpu PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(caffe2_pybind11_state_gpu PRIVATE ${Caffe2_CPU_INCLUDE})
|
||||
target_link_libraries(caffe2_pybind11_state_gpu PRIVATE
|
||||
torch_library python::python pybind::pybind11)
|
||||
target_link_libraries(caffe2_pybind11_state_gpu torch_library)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state_gpu PRIVATE onnx_proto)
|
||||
target_link_libraries(caffe2_pybind11_state_gpu ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(caffe2_pybind11_state_gpu onnx_proto)
|
||||
endif(WIN32)
|
||||
|
||||
# Install with same rpath as non-gpu caffe2_pybind11_state
|
||||
|
|
@ -1981,7 +1980,6 @@ if(BUILD_PYTHON)
|
|||
add_library(caffe2_pybind11_state_hip MODULE ${Caffe2_HIP_PYTHON_SRCS})
|
||||
if(USE_NUMPY)
|
||||
target_compile_options(caffe2_pybind11_state_hip PRIVATE "-DUSE_NUMPY")
|
||||
target_link_libraries(caffe2_pybind11_state_hip PRIVATE numpy::numpy)
|
||||
endif()
|
||||
if(NOT MSVC)
|
||||
target_compile_options(caffe2_pybind11_state_hip PRIVATE ${HIP_CXX_FLAGS} -fvisibility=hidden)
|
||||
|
|
@ -1992,8 +1990,10 @@ if(BUILD_PYTHON)
|
|||
set_target_properties(caffe2_pybind11_state_hip PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
|
||||
target_include_directories(caffe2_pybind11_state_hip PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(caffe2_pybind11_state_hip PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
|
||||
target_link_libraries(caffe2_pybind11_state_hip PRIVATE
|
||||
torch_library python::python pybind::pybind11)
|
||||
target_link_libraries(caffe2_pybind11_state_hip torch_library)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state_hip ${PYTHON_LIBRARIES})
|
||||
endif(WIN32)
|
||||
|
||||
# Install with same rpath as non-hip caffe2_pybind11_state
|
||||
set_target_properties(
|
||||
|
|
|
|||
|
|
@ -1024,18 +1024,11 @@ if(BUILD_PYTHON)
|
|||
endif()
|
||||
|
||||
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
|
||||
add_library(python::python INTERFACE IMPORTED)
|
||||
set_property(TARGET python::python PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
||||
set_property(TARGET python::python PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
|
||||
|
||||
include_directories(SYSTEM ${PYTHON_INCLUDE_DIR})
|
||||
caffe2_update_option(USE_NUMPY OFF)
|
||||
if(NUMPY_FOUND)
|
||||
caffe2_update_option(USE_NUMPY ON)
|
||||
add_library(numpy::numpy INTERFACE IMPORTED)
|
||||
set_property(TARGET numpy::numpy PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${NUMPY_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${NUMPY_INCLUDE_DIR})
|
||||
endif()
|
||||
# Observers are required in the python build
|
||||
caffe2_update_option(USE_OBSERVERS ON)
|
||||
|
|
@ -1062,11 +1055,7 @@ else()
|
|||
FILES_MATCHING PATTERN "*.h")
|
||||
endif()
|
||||
message(STATUS "pybind11 include dirs: " "${pybind11_INCLUDE_DIRS}")
|
||||
add_library(pybind::pybind11 INTERFACE IMPORTED)
|
||||
set_property(TARGET pybind::pybind11 PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${pybind11_INCLUDE_DIRS})
|
||||
set_property(TARGET pybind::pybind11 PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES python::python)
|
||||
include_directories(SYSTEM ${pybind11_INCLUDE_DIRS})
|
||||
|
||||
# ---[ MPI
|
||||
if(USE_MPI)
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ set(TORCH_PYTHON_INCLUDE_DIRECTORIES
|
|||
|
||||
${TORCH_ROOT}/third_party/gloo
|
||||
${TORCH_ROOT}/third_party/onnx
|
||||
${pybind11_INCLUDE_DIRS}
|
||||
|
||||
${TORCH_SRC_DIR}/csrc
|
||||
${TORCH_SRC_DIR}/csrc/api/include
|
||||
|
|
@ -79,8 +80,6 @@ set(TORCH_PYTHON_INCLUDE_DIRECTORIES
|
|||
list(APPEND TORCH_PYTHON_INCLUDE_DIRECTORIES ${LIBSHM_SRCDIR})
|
||||
|
||||
set(TORCH_PYTHON_LINK_LIBRARIES
|
||||
python::python
|
||||
pybind::pybind11
|
||||
shm
|
||||
fmt::fmt-header-only)
|
||||
|
||||
|
|
@ -325,6 +324,12 @@ if(USE_DEPLOY)
|
|||
|
||||
endif()
|
||||
|
||||
|
||||
# Avoid numpy for the DEPLOY build
|
||||
if(USE_NUMPY)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_NUMPY)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 in EmbeddingBag.cpp
|
||||
set_source_files_properties(${TORCH_SRC_DIR}/csrc/utils/throughput_benchmark.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes)
|
||||
|
|
@ -338,12 +343,6 @@ endif()
|
|||
|
||||
|
||||
add_library(torch_python SHARED ${TORCH_PYTHON_SRCS})
|
||||
# Avoid numpy for the DEPLOY build
|
||||
if(USE_NUMPY)
|
||||
target_link_libraries(torch_python PRIVATE numpy::numpy)
|
||||
target_compile_definitions(torch_python PRIVATE USE_NUMPY)
|
||||
endif()
|
||||
|
||||
if(HAVE_SOVERSION)
|
||||
set_target_properties(torch_python PROPERTIES
|
||||
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
|
||||
|
|
@ -378,7 +377,7 @@ endif()
|
|||
|
||||
target_compile_definitions(torch_python PRIVATE "-DTHP_BUILD_MAIN_LIB")
|
||||
|
||||
target_link_libraries(torch_python PRIVATE torch_library ${TORCH_PYTHON_LINK_LIBRARIES})
|
||||
target_link_libraries(torch_python torch_library ${TORCH_PYTHON_LINK_LIBRARIES})
|
||||
|
||||
target_compile_definitions(torch_python PRIVATE ${TORCH_PYTHON_COMPILE_DEFINITIONS})
|
||||
|
||||
|
|
@ -429,7 +428,7 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||
${TORCH_SRC_DIR}/csrc/jit/backends/nnapi/nnapi_backend_preprocess.cpp
|
||||
)
|
||||
# Pybind11 requires explicit linking of the torch_python library
|
||||
target_link_libraries(nnapi_backend PRIVATE torch torch_python pybind::pybind11)
|
||||
target_link_libraries(nnapi_backend torch torch_python)
|
||||
endif()
|
||||
|
||||
if(BUILD_BINARY)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user