Search for CMake config files for pybind11. (#11423)

Summary:
If pybind is build with cmake and installed, we should use config file instead of the Findpybind11 shipped with caffe2.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11423

Differential Revision: D9735557

Pulled By: ezyang

fbshipit-source-id: 28a39e579fa045060aa1a716e5fd7dbcf7b89569
This commit is contained in:
Tongliang Liao 2018-09-08 22:28:49 -07:00 committed by Facebook Github Bot
parent 02114e877f
commit 538ea67437

View File

@ -412,7 +412,14 @@ if(BUILD_PYTHON)
endif()
# ---[ pybind11
find_package(pybind11)
find_package(pybind11 CONFIG)
if((DEFINED pybind11_DIR) AND pybind11_DIR)
get_target_property(pybind11_INCLUDE_DIRS pybind11::pybind11 INTERFACE_INCLUDE_DIRECTORIES)
else()
message("pybind11 config not found. Fallback to legacy find.")
find_package(pybind11)
endif()
if(pybind11_FOUND)
include_directories(SYSTEM ${pybind11_INCLUDE_DIRS})
else()