aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/CMakeLists.txt
diff options
context:
space:
mode:
authorSamuel O'Brien <sam.obrien@ni.com>2020-07-24 08:35:35 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-10-28 15:25:48 -0500
commit00c306d5c441e60e7dfd2516e05e4e433977ecee (patch)
tree998752676d4ff9dbd06ad194056a214e7fdc763c /host/lib/CMakeLists.txt
parentbd278a4b936f3e30f51d7cb9ff489f3ff7215379 (diff)
downloaduhd-00c306d5c441e60e7dfd2516e05e4e433977ecee.tar.gz
uhd-00c306d5c441e60e7dfd2516e05e4e433977ecee.tar.bz2
uhd-00c306d5c441e60e7dfd2516e05e4e433977ecee.zip
sim: Integrate simulator into UHD
This commit adds a device::register_device which allows uhd to start up a simulator when uhd is called with the arguments type=sim. Creating the device object creates a subprocess using pybind and an embedded interpreter, and destroying the object cleans up those subprocesses. Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
Diffstat (limited to 'host/lib/CMakeLists.txt')
-rw-r--r--host/lib/CMakeLists.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 3335cfec9..37f73f108 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -69,6 +69,7 @@ LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF
LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("X300" ENABLE_X300 ON "ENABLE_LIBUHD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("MPMD" ENABLE_MPMD ON "ENABLE_LIBUHD" OFF OFF)
+LIBUHD_REGISTER_COMPONENT("SIM" ENABLE_SIM ON "ENABLE_LIBUHD;ENABLE_MPMD;ENABLE_PYTHON_API" OFF OFF)
LIBUHD_REGISTER_COMPONENT("N300" ENABLE_N300 ON "ENABLE_LIBUHD;ENABLE_MPMD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("N320" ENABLE_N320 ON "ENABLE_LIBUHD;ENABLE_MPMD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("E320" ENABLE_E320 ON "ENABLE_LIBUHD;ENABLE_MPMD" OFF OFF)
@@ -187,6 +188,26 @@ if(DEFINED LIBUHD_OUTPUT_NAME)
set_target_properties(uhd PROPERTIES OUTPUT_NAME ${LIBUHD_OUTPUT_NAME})
endif(DEFINED LIBUHD_OUTPUT_NAME)
+if(ENABLE_SIM)
+ # Get python include dirs
+ include_directories(${PYTHON_INCLUDE_DIRS})
+ set(PYBIND11_INCLUDE_DIR
+ "${CMAKE_SOURCE_DIR}/lib/deps/pybind11/include"
+ CACHE
+ STRING
+ "Location of PyBind11 includes"
+ )
+ include_directories(${PYBIND11_INCLUDE_DIR})
+
+ # For PYUHD we don't link against the python libraries, but when calling
+ # python instead of being called by it, we have to.
+ target_link_libraries(uhd ${PYTHON_LIBRARIES})
+
+ if(APPLE)
+ target_link_options(pyuhd PRIVATE "LINKER:-undefined,dynamic_lookup")
+ endif(APPLE)
+endif(ENABLE_SIM)
+
if(NOT UHDHOST_PKG) #Syntax makes it unusable by UHD_INSTALL
install(TARGETS uhd
LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .so file