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 843a56b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 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)
5 changes: 3 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ set(PLUGINS
adrv9002
cf_axi_tdd
)

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (NOT WITH_PLUGIN_SPECTRUM_ANALYZER)
list(REMOVE_ITEM PLUGINS spectrum_analyzer)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list(REMOVE_ITEM PLUGINS spectrum_analyzer scpi)
set(EXTRA_WIN_LIBRARIES winpthread)
endif()
Expand Down
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 843a56b

Please sign in to comment.