Skip to content

Commit

Permalink
Correct NO_SERIAL_LINK Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Apr 30, 2024
1 parent b8cab66 commit 2de2b7d
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 322 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ if(QGC_DEBUG_QML)
add_compile_definitions(QT_QML_DEBUG)
endif()

cmake_dependent_option(QGC_NO_SERIAL_LINK "Build QGroundControl without Serial Support Support." OFF "NOT IOS" ON)

#######################################################
# QGroundControl Resources
#######################################################
Expand Down
107 changes: 56 additions & 51 deletions src/GPS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
find_package(Qt6 REQUIRED COMPONENTS Core)

# include(FetchContent)
# FetchContent_Declare(gps_drivers
# GIT_REPOSITORY https://github.com/PX4/PX4-GPSDrivers.git
# GIT_TAG main
# GIT_SHALLOW TRUE
# )
# FetchContent_GetProperties(gps_drivers)
# if(NOT gps_drivers_POPULATED)
# FetchContent_Populate(gps_drivers)
# add_subdirectory(${gps_drivers_SOURCE_DIR} ${gps_drivers_BINARY_DIR} EXCLUDE_FROM_ALL)
# endif()
qt_add_library(gps STATIC)

qt_add_library(gps STATIC
definitions.h
Drivers/src/ashtech.cpp
Drivers/src/ashtech.h
Drivers/src/gps_helper.cpp
Drivers/src/gps_helper.h
Drivers/src/mtk.cpp
Drivers/src/mtk.h
Drivers/src/rtcm.cpp
Drivers/src/rtcm.h
Drivers/src/sbf.cpp
Drivers/src/sbf.h
Drivers/src/ubx.cpp
Drivers/src/ubx.h
GPSManager.cc
GPSManager.h
GPSPositionMessage.h
GPSProvider.cc
GPSProvider.h
RTCMMavlink.cc
RTCMMavlink.h
satellite_info.h
sensor_gnss_relative.h
sensor_gps.h
)
if(NOT QGC_NO_SERIAL_LINK)
# include(FetchContent)
# FetchContent_Declare(gps_drivers
# GIT_REPOSITORY https://github.com/PX4/PX4-GPSDrivers.git
# GIT_TAG main
# GIT_SHALLOW TRUE
# )
# FetchContent_GetProperties(gps_drivers)
# if(NOT gps_drivers_POPULATED)
# FetchContent_Populate(gps_drivers)
# add_subdirectory(${gps_drivers_SOURCE_DIR} ${gps_drivers_BINARY_DIR} EXCLUDE_FROM_ALL)
# endif()

target_link_libraries(gps
PRIVATE
comm
Settings
Utilities
Vehicle
PUBLIC
Qt6::Core
qgc
)
target_sources(gps
PRIVATE
definitions.h
Drivers/src/ashtech.cpp
Drivers/src/ashtech.h
Drivers/src/gps_helper.cpp
Drivers/src/gps_helper.h
Drivers/src/mtk.cpp
Drivers/src/mtk.h
Drivers/src/rtcm.cpp
Drivers/src/rtcm.h
Drivers/src/sbf.cpp
Drivers/src/sbf.h
Drivers/src/ubx.cpp
Drivers/src/ubx.h
GPSManager.cc
GPSManager.h
GPSPositionMessage.h
GPSProvider.cc
GPSProvider.h
RTCMMavlink.cc
RTCMMavlink.h
satellite_info.h
sensor_gnss_relative.h
sensor_gps.h
)

target_include_directories(gps
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Drivers/src
)
target_link_libraries(gps
PRIVATE
comm
Settings
Utilities
Vehicle
PUBLIC
Qt6::Core
qgc
)

target_include_directories(gps
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Drivers/src
)
endif()
13 changes: 4 additions & 9 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,13 @@
#include "Viewer3DTerrainTexture.h"
#include "LinkConfiguration.h"

#ifndef __mobile__
#include "FirmwareUpgradeController.h"
#endif

#ifndef NO_SERIAL_LINK
#include "FirmwareUpgradeController.h"
#include "SerialLink.h"
#endif

#ifdef Q_OS_LINUX
#ifndef __mobile__
#ifndef Q_OS_ANDROID
#include <unistd.h>
#include <sys/types.h>
#endif
Expand Down Expand Up @@ -185,7 +182,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
_msecsElapsedTime.start();

#ifdef Q_OS_LINUX
#ifndef __mobile__
#ifndef Q_OS_ANDROID
if (!_runningUnitTests) {
if (getuid() == 0) {
_exitWithError(QString(
Expand Down Expand Up @@ -486,10 +483,8 @@ void QGCApplication::_initCommon()
qmlRegisterType<ToolStripAction> ("QGroundControl.Controls", 1, 0, "ToolStripAction");
qmlRegisterType<ToolStripActionList> ("QGroundControl.Controls", 1, 0, "ToolStripActionList");

#ifndef __mobile__
#ifndef NO_SERIAL_LINK
qmlRegisterType<FirmwareUpgradeController> (kQGCControllers, 1, 0, "FirmwareUpgradeController");
#endif
#endif
qmlRegisterType<GeoTagController> (kQGCControllers, 1, 0, "GeoTagController");
qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController");
Expand Down Expand Up @@ -543,7 +538,7 @@ bool QGCApplication::_initForNormalAppBoot()
}

#ifdef Q_OS_LINUX
#ifndef __mobile__
#ifndef Q_OS_ANDROID
#ifndef NO_SERIAL_LINK
if (!_runningUnitTests) {
// Determine if we have the correct permissions to access USB serial devices
Expand Down
6 changes: 3 additions & 3 deletions src/QGCToolbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "FactSystem.h"
#include "FirmwarePluginManager.h"
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
#include "GPSManager.h"
#endif
#include "JoystickManager.h"
Expand Down Expand Up @@ -64,7 +64,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_scanAndLoadPlugins(app);
_factSystem = new FactSystem (app, this);
_firmwarePluginManager = new FirmwarePluginManager (app, this);
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
_gpsManager = new GPSManager (app, this);
#endif
_imageProvider = new QGCImageProvider (app, this);
Expand Down Expand Up @@ -99,7 +99,7 @@ void QGCToolbox::setChildToolboxes(void)
_corePlugin->setToolbox(this);
_factSystem->setToolbox(this);
_firmwarePluginManager->setToolbox(this);
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
_gpsManager->setToolbox(this);
#endif
_imageProvider->setToolbox(this);
Expand Down
4 changes: 2 additions & 2 deletions src/QGCToolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class QGCToolbox : public QObject {
QGCCorePlugin* corePlugin () { return _corePlugin; }
SettingsManager* settingsManager () { return _settingsManager; }
ADSBVehicleManager* adsbVehicleManager () { return _adsbVehicleManager; }
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
GPSManager* gpsManager () { return _gpsManager; }
#endif
#ifndef QGC_AIRLINK_DISABLED
Expand All @@ -79,7 +79,7 @@ class QGCToolbox : public QObject {

FactSystem* _factSystem = nullptr;
FirmwarePluginManager* _firmwarePluginManager = nullptr;
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
GPSManager* _gpsManager = nullptr;
#endif
QGCImageProvider* _imageProvider = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/QmlControls/QGroundControlQmlGlobal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "QGCMapUrlEngine.h"
#include "FirmwarePluginManager.h"
#include "AppSettings.h"
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
#include "GPSManager.h"
#endif
#include "QGCPalette.h"
Expand Down Expand Up @@ -86,7 +86,7 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox)
_corePlugin = toolbox->corePlugin();
_firmwarePluginManager = toolbox->firmwarePluginManager();
_settingsManager = toolbox->settingsManager();
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
_gpsRtkFactGroup = toolbox->gpsManager()->gpsRtkFactGroup();
#endif
_adsbVehicleManager = toolbox->adsbVehicleManager();
Expand Down
6 changes: 6 additions & 0 deletions src/QmlControls/QGroundControlQmlGlobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class QGroundControlQmlGlobal : public QGCTool
Q_PROPERTY(ADSBVehicleManager* adsbVehicleManager READ adsbVehicleManager CONSTANT)
Q_PROPERTY(QGCCorePlugin* corePlugin READ corePlugin CONSTANT)
Q_PROPERTY(MissionCommandTree* missionCommandTree READ missionCommandTree CONSTANT)
#ifndef NO_SERIAL_LINK
Q_PROPERTY(FactGroup* gpsRtk READ gpsRtkFactGroup CONSTANT)
#endif
#ifndef QGC_AIRLINK_DISABLED
Q_PROPERTY(AirLinkManager* airlinkManager READ airlinkManager CONSTANT)
#endif
Expand Down Expand Up @@ -173,7 +175,9 @@ class QGroundControlQmlGlobal : public QGCTool
MAVLinkLogManager* mavlinkLogManager () { return _mavlinkLogManager; }
QGCCorePlugin* corePlugin () { return _corePlugin; }
SettingsManager* settingsManager () { return _settingsManager; }
#ifndef NO_SERIAL_LINK
FactGroup* gpsRtkFactGroup () { return _gpsRtkFactGroup; }
#endif
ADSBVehicleManager* adsbVehicleManager () { return _adsbVehicleManager; }
QmlUnitsConversion* unitsConversion () { return &_unitsConversion; }
static QGeoCoordinate flightMapPosition () { return _coord; }
Expand Down Expand Up @@ -262,7 +266,9 @@ class QGroundControlQmlGlobal : public QGCTool
QGCCorePlugin* _corePlugin = nullptr;
FirmwarePluginManager* _firmwarePluginManager = nullptr;
SettingsManager* _settingsManager = nullptr;
#ifndef NO_SERIAL_LINK
FactGroup* _gpsRtkFactGroup = nullptr;
#endif
AirLinkManager* _airlinkManager = nullptr;
ADSBVehicleManager* _adsbVehicleManager = nullptr;
QGCPalette* _globalPalette = nullptr;
Expand Down
30 changes: 21 additions & 9 deletions src/VehicleSetup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)

qt_add_library(VehicleSetup STATIC
Bootloader.cc
Bootloader.h
FirmwareImage.cc
FirmwareImage.h
FirmwareUpgradeController.cc
FirmwareUpgradeController.h
JoystickConfigController.cc
JoystickConfigController.h
PX4FirmwareUpgradeThread.cc
PX4FirmwareUpgradeThread.h
VehicleComponent.cc
VehicleComponent.h
)

add_custom_target(VehicleSetupQml
SOURCES
FirmwareUpgrade.qml
JoystickConfig.qml
JoystickConfigAdvanced.qml
JoystickConfigButtons.qml
Expand Down Expand Up @@ -50,3 +41,24 @@ target_link_libraries(VehicleSetup
)

target_include_directories(VehicleSetup PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if(NOT QGC_NO_SERIAL_LINK)
target_sources(VehicleSetup
PRIVATE
Bootloader.cc
Bootloader.h
FirmwareImage.cc
FirmwareImage.h
FirmwareUpgradeController.cc
FirmwareUpgradeController.h
PX4FirmwareUpgradeThread.cc
PX4FirmwareUpgradeThread.h
)

target_link_libraries(VehicleSetup PUBLIC comm)

target_sources(VehicleSetupQml
PRIVATE
FirmwareUpgrade.qml
)
endif()
13 changes: 4 additions & 9 deletions src/comm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,15 @@ target_link_libraries(comm
Utilities
)

if(NOT MOBILE)
option(QGC_NO_SERIAL_LINK "Disable Serial Links" OFF)
if(QGC_NO_SERIAL_LINK)
target_compile_definitions(comm PUBLIC NO_SERIAL_LINK)
else()
target_link_libraries(comm
PRIVATE
gps
PositionManager
)
endif()

target_include_directories(comm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

option(QGC_NO_SERIAL_LINK "Disable Serial Links" OFF)
if(QGC_NO_SERIAL_LINK)
target_compile_definitions(comm PUBLIC NO_SERIAL_LINK)
else()
if(ANDROID)
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/qtandroidserialport qtandroidserialport.build)
target_link_libraries(comm PUBLIC qtandroidserialport)
Expand Down
Loading

0 comments on commit 2de2b7d

Please sign in to comment.