diff --git a/CMakeLists.txt b/CMakeLists.txt index ae492166..a1f68b79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,15 +381,15 @@ if (MATX_EN_FILEIO OR MATX_EN_VISUALIZATION OR MATX_EN_PYBIND11 OR MATX_BUILD_EX find_package(Python3 REQUIRED COMPONENTS Interpreter Development) find_package(pybind11 REQUIRED) + # Export pybind11 dependency for downstream users after make install + rapids_export_package(INSTALL pybind11 matx-exports GLOBAL_TARGETS pybind11::embed pybind11::pybind11) + rapids_export_package(BUILD pybind11 matx-exports GLOBAL_TARGETS pybind11::embed pybind11::pybind11) + # Check for python libs include(cmake/CheckPythonLibs.cmake) check_python_libs("numpy") check_optional_python_libs("cupy") - # Required by pybind - # https://pybind11.readthedocs.io/en/stable/faq.html#someclass-declared-with-greater- - # visibility-than-the-type-of-its-field-someclass-member-wattributes - target_compile_options(matx INTERFACE -fvisibility=hidden) target_link_libraries(matx INTERFACE pybind11::embed) # Visualization requires Python libraries diff --git a/cmake/GetPyBind11.cmake b/cmake/GetPyBind11.cmake index f37a82e4..9d4ae996 100644 --- a/cmake/GetPyBind11.cmake +++ b/cmake/GetPyBind11.cmake @@ -30,6 +30,11 @@ # // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ///////////////////////////////////////////////////////////////////////////////// function(find_and_configure_pybind11) + # Enable pybind11 installation when fetched via CPM + # This ensures pybind11 headers and cmake config are installed with matx + set(PYBIND11_INSTALL ON CACHE BOOL "Install pybind11 headers and cmake config") + set(PYBIND11_FINDPYTHON ON CACHE BOOL "Use FindPython for pybind11") + CPMFindPackage(NAME pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG a5b9e50)