Skip to content

Commit

Permalink
plugins/spectrum_analyzer: Add cmake option to build it or not
Browse files Browse the repository at this point in the history
And by default exclude it from build.

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Aug 11, 2021
1 parent f8e1a4c commit 4fdba24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
4 changes: 4 additions & 0 deletions plugins/spectrum_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 4fdba24

Please sign in to comment.