Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/spectrum_analyzer: Add cmake option to build it or not #352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this option should be in the plugins specific CMakeLists file. Moreover, I would just not compile the library at all if the option is OFF. As it is the default value, I would remove the plugin from the list of plugins and just add it if (WITH_PLUGIN_SPECTRUM_ANALYZER)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that initially but as Michael said we need to build the plugin. As for the option, I prefer all options to be at top level cmake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot say I agree with that but fair enough...

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