From 4fdba24664a7eabb0076b13a09f6fca5a76965f3 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Wed, 11 Aug 2021 12:12:10 +0300 Subject: [PATCH] plugins/spectrum_analyzer: Add cmake option to build it or not And by default exclude it from build. Signed-off-by: Dan Nechita --- CMakeLists.txt | 8 ++++++++ plugins/spectrum_analyzer.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b836db0ab..a5fb71c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,9 @@ project(iio-oscilloscope LANGUAGES C ) +############################### Options ####################################### +option(WITH_PLUGIN_SPECTRUM_ANALYZER "Build the Spectrum Analyzer plugin?" OFF) + if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") string(TIMESTAMP BUILD_YEAR "%Y") endif() @@ -302,4 +305,9 @@ foreach(plib_dest xmls filters waveforms block_diagrams) install(DIRECTORY ${plib_dest} DESTINATION ${PLIB_DEST}) endforeach() +if (WITH_PLUGIN_SPECTRUM_ANALYZER) + add_definitions(-DPLUGIN_SPECTRUM_ANALYZER) +endif() + + add_subdirectory(plugins) diff --git a/plugins/spectrum_analyzer.c b/plugins/spectrum_analyzer.c index 655127da3..a7865c997 100644 --- a/plugins/spectrum_analyzer.c +++ b/plugins/spectrum_analyzer.c @@ -894,11 +894,15 @@ struct osc_plugin plugin; static bool analyzer_identify(const struct osc_plugin *plugin) { +#ifdef PLUGIN_SPECTRUM_ANALYZER /* Use the OSC's IIO context just to detect the devices */ struct iio_context *osc_ctx = get_context_from_osc(); return !!iio_context_find_device(osc_ctx, PHY_DEVICE) && !!iio_context_find_device(osc_ctx, CAP_DEVICE); +#else + return false; +#endif } struct osc_plugin plugin = {