From 957ad6934d5a7f1d0172bf5b200897839cc3a813 Mon Sep 17 00:00:00 2001 From: David Protzman Date: Thu, 23 Jun 2022 22:17:31 -0400 Subject: [PATCH] Added CMake config option for MATLAB install directory --- gnuradio/gr-droneid/CMakeLists.txt | 2 ++ gnuradio/gr-droneid/lib/CMakeLists.txt | 27 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gnuradio/gr-droneid/CMakeLists.txt b/gnuradio/gr-droneid/CMakeLists.txt index 72e338d..204acff 100644 --- a/gnuradio/gr-droneid/CMakeLists.txt +++ b/gnuradio/gr-droneid/CMakeLists.txt @@ -25,6 +25,8 @@ cmake_minimum_required(VERSION 3.8) project(gr-droneid CXX C) enable_testing() +set(MATLAB_PATH "" CACHE STRING "Path to MATLAB installation") + # Install to PyBOMBS target prefix if defined if(DEFINED ENV{PYBOMBS_PREFIX}) set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX}) diff --git a/gnuradio/gr-droneid/lib/CMakeLists.txt b/gnuradio/gr-droneid/lib/CMakeLists.txt index 3b65835..78f226c 100644 --- a/gnuradio/gr-droneid/lib/CMakeLists.txt +++ b/gnuradio/gr-droneid/lib/CMakeLists.txt @@ -81,10 +81,31 @@ include(GrTest) #include_directories() # List all files that contain Boost.UTF unit tests here list(APPEND test_droneid_sources - qa_normalized_xcorr.cc - qa_normalized_xcorr_estimate.cc - qa_variance.cc + qa_normalized_xcorr_estimate.cc ) + +if (MATLAB_PATH) + message(STATUS "Using MATLAB path '${MATLAB_PATH}'") + + if (NOT IS_DIRECTORY ${MATLAB_PATH}) + message(FATAL_ERROR "MATLAB path '${MATLAB_PATH}' does not exist or is not a directory. Please fix or remove") + endif() + + # Add paths to MATLAB libraries and headers + target_link_directories(gnuradio-droneid PUBLIC ${MATLAB_PATH}/extern/bin/glnxa64) + target_include_directories(gnuradio-droneid PUBLIC PUBLIC ${MATLAB_PATH}/extern/include) + + # Add MATLAB library dependencies + target_link_libraries(gnuradio-droneid MatlabEngine MatlabDataArray) + + list(APPEND test_droneid_sources + qa_variance.cc + qa_normalized_xcorr.cc + ) +else() + message(WARNING "No MATLAB path specified, so some tests will be skipped") +endif() + # Anything we need to link to for the unit tests go here list(APPEND GR_TEST_TARGET_DEPS gnuradio-droneid)