From: Joel Holdsworth Date: Tue, 16 Apr 2013 18:45:04 +0000 (+0100) Subject: Added ENABLE_SIGROKDECODE option, disabled for now X-Git-Tag: pulseview-0.1.0~40 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d52d8455db515a779b4451c223ba7aaded70951a;p=pulseview.git Added ENABLE_SIGROKDECODE option, disabled for now --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d46b25e..8566adf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ project(pulseview) #------------------------------------------------------------------------------- option(DISABLE_WERROR "Build without -Werror" FALSE) +option(ENABLE_SIGROKDECODE "Build with libsigrokdecode" FALSE) option(ENABLE_TESTS "Enable unit tests" FALSE) option(STATIC_PKGDEPS_LIBS "Statically link to (pkgconfig) libraries" FALSE) @@ -45,12 +46,17 @@ endif() #= Dependencies #------------------------------------------------------------------------------- -find_package(PkgConfig) -pkg_check_modules(PKGDEPS REQUIRED - libsigrokdecode>=0.1.0 +list(APPEND PKGDEPS libsigrok>=0.2.0 ) +if(ENABLE_SIGROKDECODE) + list(APPEND PKGDEPS libsigrokdecode>=0.1.0) +endif() + +find_package(PkgConfig) +pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) + find_package(Qt4 REQUIRED) # Find the platform's thread library (needed for boost-thread). @@ -158,6 +164,10 @@ include(${QT_USE_FILE}) add_definitions(${QT_DEFINITIONS}) add_definitions(-Wall -Wextra) +if(ENABLE_SIGROKDECODE) + add_definitions(-DENABLE_SIGROKDECODE) +endif() + if(NOT DISABLE_WERROR) add_definitions(-Werror) endif() diff --git a/main.cpp b/main.cpp index 42e4a7c1..b72fc70c 100644 --- a/main.cpp +++ b/main.cpp @@ -18,7 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_SIGROKDECODE #include /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#endif + #include #include @@ -77,7 +80,11 @@ int main(int argc, char *argv[]) { const int loglevel = atoi(optarg); sr_log_loglevel_set(loglevel); + +#ifdef ENABLE_SIGROKDECODE srd_log_loglevel_set(loglevel); +#endif + break; } @@ -105,11 +112,18 @@ int main(int argc, char *argv[]) return 1; } - // Initialise libsigrokdecode - if (srd_init(NULL) == SRD_OK) { + do { + +#ifdef ENABLE_SIGROKDECODE + // Initialise libsigrokdecode + if (srd_init(NULL) != SRD_OK) { + qDebug() << "ERROR: libsigrokdecode init failed."; + break; + } // Load the protocol decoders srd_decoder_load_all(); +#endif // Initialize all libsigrok drivers sr_dev_driver **const drivers = sr_driver_list(); @@ -145,13 +159,14 @@ int main(int argc, char *argv[]) ret = a.exec(); } - // Destroy libsigrokdecode and libsigrok +#ifdef ENABLE_SIGROKDECODE + // Destroy libsigrokdecode srd_exit(); +#endif - } else { - qDebug() << "ERROR: libsigrokdecode init failed."; - } + } while (0); + // Destroy libsigrok if (sr_ctx) sr_exit(sr_ctx); diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index c14a8fea..4065de55 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_SIGROKDECODE #include +#endif #include @@ -41,7 +43,11 @@ About::About(QWidget *parent) : struct sr_dev_driver **drivers; struct sr_input_format **inputs; struct sr_output_format **outputs; + +#ifdef ENABLE_SIGROKDECODE struct srd_decoder *dec; +#endif + QString s; ui->setupUi(this); @@ -87,6 +93,7 @@ About::About(QWidget *parent) : .arg(QString(outputs[i]->description))); } +#ifdef ENABLE_SIGROKDECODE s.append("" + tr("Supported protocol decoders:") + ""); @@ -96,6 +103,7 @@ About::About(QWidget *parent) : .arg(QString(dec->id)) .arg(QString(dec->longname))); } +#endif s.append(""); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 3aeb1227..66bed748 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -18,7 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_SIGROKDECODE #include +#endif #include