mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[CMake] Prefer third_party/pybind11 by default (#58951)
Summary:
To make build behaviour aligned with other third_party/ libraries,
introduce `USE_SYSTEM_PYBIND11 (d55b25a633
)` build option, which set to OFF by
default, which means PyTorch will be build with bundled pybind11 even if
other version is already installed locally.
Fixes https://github.com/pytorch/pytorch/issues/58750
Pull Request resolved: https://github.com/pytorch/pytorch/pull/58951
Reviewed By: driazati
Differential Revision: D28690411
Pulled By: malfet
fbshipit-source-id: e56b5a8f2a23ee1834b2a6d3807f287149decf8c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
45aa54d83c
commit
7179e7ea7b
@ -351,6 +351,7 @@ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo." OFF)
|
||||
option(USE_SYSTEM_SLEEF "Use system-provided sleef." OFF)
|
||||
option(USE_SYSTEM_GLOO "Use system-provided gloo." OFF)
|
||||
option(USE_SYSTEM_FP16 "Use system-provided fp16." OFF)
|
||||
option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." OFF)
|
||||
option(USE_SYSTEM_PTHREADPOOL "Use system-provided pthreadpool." OFF)
|
||||
option(USE_SYSTEM_PSIMD "Use system-provided psimd." OFF)
|
||||
option(USE_SYSTEM_FXDIV "Use system-provided fxdiv." OFF)
|
||||
@ -371,6 +372,7 @@ if(USE_SYSTEM_LIBS)
|
||||
set(USE_SYSTEM_BENCHMARK ON)
|
||||
set(USE_SYSTEM_ONNX ON)
|
||||
set(USE_SYSTEM_XNNPACK ON)
|
||||
set(USE_SYSTEM_PYBIND11 ON)
|
||||
endif()
|
||||
|
||||
# Used when building Caffe2 through setup.py
|
||||
|
@ -999,24 +999,20 @@ if(BUILD_PYTHON)
|
||||
endif()
|
||||
|
||||
# ---[ pybind11
|
||||
if(NOT pybind11_PREFER_third_party)
|
||||
if(USE_SYSTEM_BIND11)
|
||||
find_package(pybind11 CONFIG)
|
||||
if(NOT pybind11_FOUND)
|
||||
find_package(pybind11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(pybind11_FOUND)
|
||||
message(STATUS "System pybind11 found")
|
||||
if(NOT pybind11_FOUND)
|
||||
message(FATAL "Cannot find system pybind11")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Using third_party/pybind11.")
|
||||
set(pybind11_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../third_party/pybind11/include)
|
||||
install(DIRECTORY ${pybind11_INCLUDE_DIRS}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
set(pybind11_PREFER_third_party ON CACHE BOOL
|
||||
"Use the third_party/pybind11 submodule, instead of looking for system
|
||||
installation of pybind11")
|
||||
endif()
|
||||
message(STATUS "pybind11 include dirs: " "${pybind11_INCLUDE_DIRS}")
|
||||
include_directories(SYSTEM ${pybind11_INCLUDE_DIRS})
|
||||
|
Reference in New Issue
Block a user