mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
cmake: Update UHDPython.cmake
- Use find_package(pybind11) to find a system-wide Pybind11. This will take preference over the vendored version of Pybind11, unless requested otherwise. - Fix a typo.
This commit is contained in:
parent
0998a4855e
commit
2233b8d05e
@ -40,6 +40,7 @@ set(NUMPY_MIN_VERSION "1.11")
|
||||
set(RUAMEL.YAML_MIN_VERSION "0.15")
|
||||
set(PY_MAKO_MIN_VERSION "0.4.2")
|
||||
set(PY_REQUESTS_MIN_VERSION "2.0")
|
||||
set(PYBIND11_MIN_VERSION "2.4")
|
||||
|
||||
########################################################################
|
||||
# Check Compiler Version
|
||||
|
||||
@ -17,6 +17,14 @@ endif()
|
||||
if(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE)
|
||||
set(INCLUDED_UHD_PYTHON_CMAKE TRUE)
|
||||
|
||||
########################################################################
|
||||
# Setup Python Part 0: Pybind11
|
||||
#
|
||||
# We do this first so it doesn't interfere with the other steps. In
|
||||
# particular, searching for pybind11 will mess with PYTHON_VERSION.
|
||||
########################################################################
|
||||
find_package(pybind11 ${PYBIND11_MIN_VERSION} QUIET)
|
||||
|
||||
########################################################################
|
||||
# Setup Python Part 1: Find the interpreters
|
||||
########################################################################
|
||||
@ -211,7 +219,7 @@ exit(0)
|
||||
)
|
||||
if(python_result EQUAL 0)
|
||||
if(${version_output} VERSION_GREATER_EQUAL ${min_module_version})
|
||||
message(STATUS "Python checking for ${desc} - ${version_output} satisifes minimum required version ${min_module_version}")
|
||||
message(STATUS "Python checking for ${desc} - ${version_output} satisfies minimum required version ${min_module_version}")
|
||||
set(${have_var} TRUE)
|
||||
else()
|
||||
message(STATUS "Python checking for ${desc} - ${version_output} does not satisfy minimum required version ${min_module_version}")
|
||||
|
||||
@ -22,7 +22,8 @@ Build-Depends: cmake,
|
||||
python3-numpy,
|
||||
python3-requests,
|
||||
python3-ruamel.yaml,
|
||||
python3-setuptools
|
||||
python3-setuptools,
|
||||
pybind11-dev
|
||||
Build-Depends-Indep: doxygen,
|
||||
doxygen-latex,
|
||||
graphviz [!powerpcspe]
|
||||
|
||||
@ -4,10 +4,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# This file included, use CMake directory variables
|
||||
########################################################################
|
||||
|
||||
PYTHON_CHECK_MODULE(
|
||||
"virtual environment"
|
||||
"sys"
|
||||
@ -15,15 +11,18 @@ PYTHON_CHECK_MODULE(
|
||||
HAVE_PYTHON_VIRTUALENV
|
||||
)
|
||||
|
||||
if(pybind11_FOUND)
|
||||
message(STATUS "Using Pybind11 from: ${pybind11_INCLUDE_DIR}")
|
||||
else()
|
||||
set(pybind11_INCLUDE_DIR
|
||||
"${UHD_SOURCE_DIR}/lib/deps/pybind11/include"
|
||||
CACHE STRING
|
||||
"Location of PyBind11 includes"
|
||||
)
|
||||
message(STATUS "Using in-tree Pybind11.")
|
||||
endif()
|
||||
|
||||
# Get include dirs
|
||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
set(PYBIND11_INCLUDE_DIR
|
||||
"${UHD_SOURCE_DIR}/lib/deps/pybind11/include"
|
||||
CACHE
|
||||
STRING
|
||||
"Location of PyBind11 includes"
|
||||
)
|
||||
include_directories(${PYBIND11_INCLUDE_DIR})
|
||||
execute_process(
|
||||
COMMAND "${PYTHON_EXECUTABLE}" -c
|
||||
"try:\n import numpy\n import os\n inc_path = numpy.get_include()\n if os.path.exists(os.path.join(inc_path, 'numpy', 'arrayobject.h')):\n print(inc_path, end='')\nexcept:\n pass"
|
||||
@ -36,6 +35,7 @@ add_library(pyuhd SHARED
|
||||
${UHD_SOURCE_DIR}/lib/device_python.cpp
|
||||
${UHD_SOURCE_DIR}/lib/usrp/multi_usrp_python.cpp
|
||||
)
|
||||
|
||||
# python expects extension modules with a particular suffix
|
||||
if(WIN32)
|
||||
set_target_properties(pyuhd PROPERTIES PREFIX "lib" SUFFIX ".pyd")
|
||||
@ -56,9 +56,10 @@ else()
|
||||
)
|
||||
endif(WIN32)
|
||||
target_include_directories(pyuhd PUBLIC
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${PYTHON_NUMPY_INCLUDE_DIR}
|
||||
${UHD_SOURCE_DIR}/lib
|
||||
${PYBIND11_INCLUDE_DIR}
|
||||
${pybind11_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user