From 3b0f38f24a3c3d7ccadf8c0b0011dfc58c2f9d46 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 26 Oct 2015 06:05:27 -0700 Subject: [PATCH] Fix building without BT support I guess no one had tried this in a while. Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 24 +++++++++++++++--------- configuredivecomputer.cpp | 2 ++ libdivecomputer.c | 2 ++ qt-ui/configuredivecomputerdialog.cpp | 6 +++++- qt-ui/configuredivecomputerdialog.h | 6 +++++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e7c630a1..5e9321eee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,13 +203,18 @@ if(ANDROID) set(ANDROID_PKG AndroidExtras) set(ANDROID_LIB Qt5::AndroidExtras) endif() -find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network ${WEBKIT_PKG} ${PRINTING_PKG} Svg Test LinguistTools ${QT_QUICK_PKG} ${ANDROID_PKG} Bluetooth) -set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${WEBKIT_LIB} ${PRINTING_LIB} Qt5::Svg ${QT_QUICK_LIB} ${ANDROID_LIB} Qt5::Bluetooth) +if(BTSUPPORT) + set(BLUETOOTH_PKG Bluetooth) + set(BLUETOOTH_LIB Qt5::Bluetooth) +endif() +find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network ${WEBKIT_PKG} ${PRINTING_PKG} Svg Test LinguistTools ${QT_QUICK_PKG} ${ANDROID_PKG} ${BLUETOOTH_PKG}) +set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${WEBKIT_LIB} ${PRINTING_LIB} Qt5::Svg ${QT_QUICK_LIB} ${ANDROID_LIB} ${BLUETOOTH_LIB}) set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test) -if ("${Qt5Core_VERSION_STRING}" STRLESS "5.4.0") +if (BTSUPPORT AND "${Qt5Core_VERSION_STRING}" STRLESS "5.4.0") set(BTSUPPORT OFF) message(STATUS "Turning off Bluetooth support as Qt version ${Qt5Core_VERSION_STRING} is insufficiant for that") + string(REPLACE "Qt5::Bluetooth" "" QT_LIBRARIES ${QT_LIBRARIES}) endif() # Generate the ssrf-config.h every 'make' @@ -311,6 +316,12 @@ endif() # include translations add_subdirectory(translations) +if(BTSUPPORT) + add_definitions(-DBT_SUPPORT) + set(BT_SRC_FILES qt-ui/btdeviceselectiondialog.cpp) + set(BT_CORE_SRC_FILES qtserialbluetooth.cpp) +endif() + # compile the core library, in C. set(SUBSURFACE_CORE_LIB_SRCS cochran.c @@ -361,7 +372,7 @@ set(SUBSURFACE_CORE_LIB_SRCS windowtitleupdate.cpp divelogexportlogic.cpp qt-init.cpp - qtserialbluetooth.cpp + ${BT_CORE_SRC_FILES} ${SERIAL_FTDI} ${PLATFORM_SRC} ) @@ -372,11 +383,6 @@ if(FBSUPPORT) set(SOCIALNETWORKS qt-ui/socialnetworks.cpp) endif() -if(BTSUPPORT) - add_definitions(-DBT_SUPPORT) - set(BT_SRC_FILES qt-ui/btdeviceselectiondialog.cpp) -endif() - # the data models that will interface # with the views. set(SUBSURFACE_MODELS_LIB_SRCS diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 1262492de..2457ffe82 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -636,7 +636,9 @@ QString ConfigureDiveComputer::dc_open(device_data_t *data) dc_serial_t *serial_device = NULL; if (data->bluetooth_mode) { +#ifdef BT_SUPPORT rc = dc_serial_qt_open(&serial_device, data->context, data->devname); +#endif #ifdef SERIAL_FTDI } else if (!strcmp(data->devname, "ftdi")) { rc = dc_serial_ftdi_open(&serial_device, data->context); diff --git a/libdivecomputer.c b/libdivecomputer.c index b5f90cb35..ca8378379 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -971,7 +971,9 @@ const char *do_libdivecomputer_import(device_data_t *data) dc_serial_t *serial_device = NULL; if (data->bluetooth_mode) { +#ifdef BT_SUPPORT rc = dc_serial_qt_open(&serial_device, data->context, data->devname); +#endif #ifdef SERIAL_FTDI } else if (!strcmp(data->devname, "ftdi")) { rc = dc_serial_ftdi_open(&serial_device, data->context); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 7afb3f4bd..ddb9450de 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -115,8 +115,12 @@ void GasTypeComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemMod ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), config(0), +#ifdef BT_SUPPORT deviceDetails(0), btDeviceSelectionDialog(0) +#else + deviceDetails(0) +#endif { ui.setupUi(this); @@ -134,7 +138,7 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(dc_open())); connect(ui.disconnectButton, SIGNAL(clicked()), this, SLOT(dc_close())); -#if BT_SUPPORT +#ifdef BT_SUPPORT connect(ui.bluetoothMode, SIGNAL(clicked(bool)), this, SLOT(selectRemoteBluetoothDevice())); #else ui.bluetoothMode->setVisible(false); diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 7092e9708..be76644a9 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -8,7 +8,9 @@ #include "configuredivecomputer.h" #include #include +#ifdef BT_SUPPORT #include "btdeviceselectiondialog.h" +#endif class GasSpinBoxItemDelegate : public QStyledItemDelegate { Q_OBJECT @@ -85,7 +87,7 @@ slots: void dc_open(); void dc_close(); -#if BT_SUPPORT +#ifdef BT_SUPPORT void bluetoothSelectionDialogIsFinished(int result); void selectRemoteBluetoothDevice(); #endif @@ -119,7 +121,9 @@ private: QString selected_product; bool fw_upgrade_possible; +#ifdef BT_SUPPORT BtDeviceSelectionDialog *btDeviceSelectionDialog; +#endif }; class OstcFirmwareCheck : QObject {