aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/CMakeLists.txt29
-rw-r--r--host/cmake/Modules/UHDUnitTest.cmake5
2 files changed, 33 insertions, 1 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt
index a990585c6..0cee8582f 100644
--- a/host/CMakeLists.txt
+++ b/host/CMakeLists.txt
@@ -276,6 +276,35 @@ if(WIN32)
endif(WIN32)
########################################################################
+# Option to use QEMU for running unittests
+#
+# This is useful when cross-compiling UHD for other architectures like arm or
+# aarch64
+#
+# QEMU_EXECUTABLE must be set to the name of the QEMU executable. When using
+# openembedded build environment, this should be set to "qemu-${TUNE_ARCH}"
+# or "${WORKDIR}/recipe-sysroot-native/usr/bin/qemu-${TUNE_ARCH}"
+#
+# QEMU_SYSROOT must be set to the same sysroot of the target architecture that
+# was used when compiling UHD. When using openembedded build environment, this
+# should be set to "${WORKDIR}/recipe-sysroot"
+########################################################################
+option(ENABLE_QEMU_UNITTESTS "Use QEMU for running unittests" OFF)
+mark_as_advanced(ENABLE_QEMU_UNITTESTS)
+if(ENABLE_QEMU_UNITTESTS)
+ message(STATUS "")
+ message(STATUS "Use QEMU for running unittests: ${ENABLE_QEMU_UNITTESTS}")
+ if("${QEMU_EXECUTABLE}" STREQUAL "")
+ message(FATAL_ERROR "The variable QEMU_EXECUTABLE is not set")
+ endif()
+ if("${QEMU_SYSROOT}" STREQUAL "")
+ message(FATAL_ERROR "The variable QEMU_SYSROOT is not set")
+ endif()
+ message(STATUS " QEMU executable: ${QEMU_EXECUTABLE}")
+ message(STATUS " QEMU sysroot: ${QEMU_SYSROOT}")
+endif(ENABLE_QEMU_UNITTESTS)
+
+########################################################################
# Setup Boost
########################################################################
message(STATUS "")
diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake
index f1f52addc..7a6e00178 100644
--- a/host/cmake/Modules/UHDUnitTest.cmake
+++ b/host/cmake/Modules/UHDUnitTest.cmake
@@ -42,7 +42,10 @@ function(UHD_ADD_TEST test_name)
#add_test(${ARGV})
#set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "${environs}")
- if(UNIX)
+ if(ENABLE_QEMU_UNITTESTS)
+ # use QEMU emulator for executing test
+ add_test(${test_name} ${QEMU_EXECUTABLE} -L ${QEMU_SYSROOT} ${test_name})
+ elseif(UNIX)
set(LD_PATH_VAR "LD_LIBRARY_PATH")
if(APPLE)
set(LD_PATH_VAR "DYLD_LIBRARY_PATH")