From 321cc348a72924b91eb797e9b052249ff50b8e90 Mon Sep 17 00:00:00 2001 From: Holden Date: Wed, 15 Jan 2025 22:37:28 -0500 Subject: [PATCH] CMake: Deployment Updates --- CMakeLists.txt | 76 +++++----------------- cmake/CustomOptions.cmake | 8 ++- custom-example/cmake/CustomOverrides.cmake | 23 +++++++ src/CMakeLists.txt | 1 - src/FactSystem/FactMetaData.cc | 2 +- src/QGCApplication.cc | 2 +- src/QGCConfig.h | 14 ---- src/QmlControls/AppMessages.cc | 2 +- src/Settings/AppSettings.cc | 4 +- src/Utilities/CMakeLists.txt | 2 +- src/Utilities/MobileScreenMgr.cc | 3 +- src/Utilities/MobileScreenMgr.h | 9 ++- src/Utilities/MobileScreenMgr.mm | 1 - src/main.cc | 7 +- 14 files changed, 59 insertions(+), 95 deletions(-) delete mode 100644 src/QGCConfig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d22793042e..5286ec5a33b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,6 @@ if(APPLE AND NOT IOS) set(MACOS TRUE) endif() -if(IOS OR ANDROID) - set(MOBILE TRUE) - add_compile_definitions(__mobile__) -endif() - ####################################################### # CMake Configuration Options ####################################################### @@ -336,7 +331,7 @@ if(Qt6LinguistTools_FOUND) ) endif() -set_target_properties(${PROJECT_NAME} +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES QT_RESOURCE_PREFIX "/qgc" OUTPUT_NAME ${CMAKE_PROJECT_NAME} @@ -376,11 +371,8 @@ if(WIN32) list(APPEND QGC_INSTALLER_SOURCE_WIN_FILES "${QGC_INSTALLER_SOURCE_WIN}/${FILE_NAME}") endforeach() - target_sources(${PROJECT_NAME} - PRIVATE - ${QGC_INSTALLER_SOURCE_WIN_FILES} - ) - set_target_properties(${PROJECT_NAME} + target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${QGC_INSTALLER_SOURCE_WIN_FILES}) + set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE QT_TARGET_RC_ICONS "${CMAKE_BINARY_DIR}/deploy/windows/WindowsQGC.ico" @@ -389,10 +381,7 @@ if(WIN32) elseif(MACOS) set(MACOSX_BUNDLE_ICON_FILE "macx.icns") set(app_icon_macos "${QGC_MACOS_ICON_PATH}/macx.icns") - set_source_files_properties(${app_icon_macos} - PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources" - ) + set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") target_sources(${PROJECT_NAME} PRIVATE ${app_icon_macos}) set_target_properties(${PROJECT_NAME} PROPERTIES @@ -452,32 +441,6 @@ elseif(ANDROID) endif() set(ANDROID_VERSION_CODE "${ANDROID_PLATFORM_ARCHITECTURE_CODE}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}") - if(NOT QGC_CUSTOM_BUILD) - set(QGC_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android) - else() - set(CUSTOM_ANDROID_DIR "${CMAKE_SOURCE_DIR}/custom/android") - if(EXISTS "${CUSTOM_ANDROID_DIR}") - file(GLOB CUSTOM_ANDROID_FILES "${CUSTOM_ANDROID_DIR}/*") - if(CUSTOM_ANDROID_FILES) - message(STATUS "Custom Android package template found. Overlaying custom files...") - set(DEFAULT_ANDROID_DIR "${CMAKE_SOURCE_DIR}/android") - set(FINAL_ANDROID_DIR "${CMAKE_BINARY_DIR}/custom/android") - file(COPY "${DEFAULT_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}") - file(COPY "${CUSTOM_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS - "${DEFAULT_ANDROID_DIR}/" - "${CUSTOM_ANDROID_DIR}/" - ) - set(QGC_ANDROID_PACKAGE_SOURCE_DIR "${FINAL_ANDROID_DIR}" CACHE STRING "Path to a custom Android package template" FORCE) - message(STATUS "Android package template path will be set to: ${QGC_ANDROID_PACKAGE_SOURCE_DIR}") - else() - message(STATUS "Custom Android package template empty. Using default.") - endif() - else() - message(STATUS "No custom Android package template found. Using default.") - endif() - endif() - set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES # QT_ANDROID_ABIS ${ANDROID_ABI} @@ -502,25 +465,24 @@ add_compile_definitions( QGC_ORG_NAME="${QGC_ORG_NAME}" QGC_ORG_DOMAIN="${QGC_ORG_DOMAIN}" QGC_APP_VERSION_STR="${QGC_APP_VERSION_STR}" + QGC_SETTINGS_VERSION=${QGC_SETTINGS_VERSION} ) add_subdirectory(src) -target_link_libraries(${PROJECT_NAME} +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick Qt6::Widgets - Qt6::Svg # Used to import QSvgPlugin QGC QmlControls - Utilities ) if(QGC_BUILD_TESTING) add_subdirectory(test) - target_link_libraries(${PROJECT_NAME} PRIVATE qgctest) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE qgctest) endif() -qt_import_plugins(${PROJECT_NAME} +qt_import_plugins(${CMAKE_PROJECT_NAME} INCLUDE Qt6::QSvgPlugin EXCLUDE_BY_TYPE geoservices INCLUDE_BY_TYPE sqldrivers Qt6::QSQLiteDriverPlugin @@ -533,7 +495,7 @@ qt_import_plugins(${PROJECT_NAME} include(InstallRequiredSystemLibraries) install( - TARGETS ${PROJECT_NAME} + TARGETS ${CMAKE_PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -546,7 +508,7 @@ if(APPLE) endif() qt_generate_deploy_qml_app_script( - TARGET ${PROJECT_NAME} + TARGET ${CMAKE_PROJECT_NAME} OUTPUT_SCRIPT deploy_script DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg} MACOS_BUNDLE_POST_BUILD @@ -565,19 +527,11 @@ if(LINUX) FILES ${CMAKE_BINARY_DIR}/org.mavlink.qgroundcontrol.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) - if(QGC_CUSTOM_BUILD) - install( - FILES ${CMAKE_SOURCE_DIR}/custom/res/icons/custom_qgroundcontrol.png - DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/ - RENAME org.mavlink.qgroundcontrol.png - ) - else() - install( - FILES ${CMAKE_SOURCE_DIR}/resources/icons/qgroundcontrol.png - DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/ - RENAME org.mavlink.qgroundcontrol.png - ) - endif() + install( + FILES ${QGC_APPIMAGE_ICON_PATH} + DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/ + RENAME org.mavlink.qgroundcontrol.png + ) configure_file( ${CMAKE_SOURCE_DIR}/deploy/linux/org.mavlink.qgroundcontrol.metainfo.xml.in ${CMAKE_BINARY_DIR}/metainfo/org.mavlink.qgroundcontrol.metainfo.xml diff --git a/cmake/CustomOptions.cmake b/cmake/CustomOptions.cmake index f4408efbdd9..61f83ddbb07 100644 --- a/cmake/CustomOptions.cmake +++ b/cmake/CustomOptions.cmake @@ -1,7 +1,6 @@ # The following options can be overriden by custom builds using the CustomOverrides.cmake file # General - set(QGC_APP_NAME "QGroundControl" CACHE STRING "App Name") set(QGC_APP_COPYRIGHT "Copyright (c) 2024 QGroundControl. All rights reserved." CACHE STRING "Copyright") set(QGC_APP_DESCRIPTION "Open Source Ground Control App" CACHE STRING "Description") @@ -35,11 +34,15 @@ set(QGC_MAVLINK_GIT_TAG "b71f061a53941637cbcfc5bcf860f96bc82e0892" CACHE STRING set(QGC_QT_ANDROID_MIN_SDK_VERSION "28" CACHE STRING "Android Min SDK Version") set(QGC_QT_ANDROID_TARGET_SDK_VERSION "35" CACHE STRING "Android Target SDK Version") set(QGC_ANDROID_PACKAGE_NAME "org.mavlink.qgroundcontrol" CACHE STRING "Android Package Name") +set(QGC_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/android" CACHE PATH "Android Package Path") # MacOS set(QGC_BUNDLE_ID "org.qgroundcontrol.QGroundControl" CACHE STRING "MacOS Bundle ID") # MACOS set(QGC_MACOS_ICON_PATH "${CMAKE_SOURCE_DIR}/deploy/mac" CACHE PATH "MacOS Icon Path") # MACOS +# Linuix +set(QGC_APPIMAGE_ICON_PATH "${CMAKE_SOURCE_DIR}/resources/icons/qgroundcontrol.png" CACHE PATH "AppImage Icon Path") + # APM option(QGC_DISABLE_APM_MAVLINK "Disable APM Dialect" OFF) option(QGC_DISABLE_APM_PLUGIN "Disable APM Plugin" OFF) @@ -49,3 +52,6 @@ option(QGC_DISABLE_APM_PLUGIN_FACTORY "Disable APM Plugin Factory" OFF) option(QGC_DISABLE_PX4_PLUGIN "Disable PX4 Plugin" OFF) option(QGC_DISABLE_PX4_PLUGIN_FACTORY "Disable PX4 Plugin Factory" OFF) +# If you need to make an incompatible changes to stored settings, bump this version number +# up by 1. This will caused store settings to be cleared on next boot. +set(QGC_SETTINGS_VERSION "9" CACHE STRING "Settings Version") diff --git a/custom-example/cmake/CustomOverrides.cmake b/custom-example/cmake/CustomOverrides.cmake index 344b2307da8..ecbbd529975 100644 --- a/custom-example/cmake/CustomOverrides.cmake +++ b/custom-example/cmake/CustomOverrides.cmake @@ -1,6 +1,7 @@ set(QGC_APP_NAME "Custom-QGroundControl" CACHE STRING "App Name" FORCE) set(QGC_MACOS_ICON_PATH "${CMAKE_SOURCE_DIR}/custom/res" CACHE PATH "MacOS Icon Path" FORCE) +set(QGC_APPIMAGE_ICON_PATH "${CMAKE_SOURCE_DIR}/custom/res/icons/custom_qgroundcontrol.png" CACHE PATH "AppImage Icon Path" FORCE) # Build a single flight stack by disabling APM support set(QGC_DISABLE_APM_MAVLINK ON CACHE BOOL "Disable APM Dialect" FORCE) @@ -9,3 +10,25 @@ set(QGC_DISABLE_APM_PLUGIN_FACTORY ON CACHE BOOL "Disable APM Plugin Factory" FO # We implement our own PX4 plugin factory set(QGC_DISABLE_PX4_PLUGIN_FACTORY ON CACHE BOOL "Disable PX4 Plugin Factory" FORCE) + +set(CUSTOM_ANDROID_DIR "${CMAKE_SOURCE_DIR}/custom/android") +if(EXISTS "${CUSTOM_ANDROID_DIR}") + file(GLOB CUSTOM_ANDROID_FILES "${CUSTOM_ANDROID_DIR}/*") + if(CUSTOM_ANDROID_FILES) + message(STATUS "Custom Android package template found. Overlaying custom files...") + set(DEFAULT_ANDROID_DIR "${CMAKE_SOURCE_DIR}/android") + set(FINAL_ANDROID_DIR "${CMAKE_BINARY_DIR}/custom/android") + file(COPY "${DEFAULT_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}") + file(COPY "${CUSTOM_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}") + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + "${DEFAULT_ANDROID_DIR}/" + "${CUSTOM_ANDROID_DIR}/" + ) + set(QGC_ANDROID_PACKAGE_SOURCE_DIR "${FINAL_ANDROID_DIR}" CACHE STRING "Path to a custom Android package template" FORCE) + message(STATUS "Android package template path will be set to: ${QGC_ANDROID_PACKAGE_SOURCE_DIR}") + else() + message(STATUS "Custom Android package template empty. Using default.") + endif() +else() + message(STATUS "No custom Android package template found. Using default.") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1837faa20b5..84bb55c70bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,6 @@ qt_add_library(QGC STATIC CmdLineOptParser.h QGCApplication.cc QGCApplication.h - QGCConfig.h ) add_subdirectory(ADSB) diff --git a/src/FactSystem/FactMetaData.cc b/src/FactSystem/FactMetaData.cc index 139de03a892..5820904e231 100644 --- a/src/FactSystem/FactMetaData.cc +++ b/src/FactSystem/FactMetaData.cc @@ -1268,7 +1268,7 @@ FactMetaData* FactMetaData::createFromJsonObject(const QJsonObject& json, QMap - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#pragma once - -// If you need to make an incompatible changes to stored settings, bump this version number -// up by 1. This will caused store settings to be cleared on next boot. -#define QGC_SETTINGS_VERSION 9 diff --git a/src/QmlControls/AppMessages.cc b/src/QmlControls/AppMessages.cc index 753473731d6..7d202be0e91 100644 --- a/src/QmlControls/AppMessages.cc +++ b/src/QmlControls/AppMessages.cc @@ -56,7 +56,7 @@ AppLogModel *AppMessages::getModel() AppLogModel::AppLogModel() : QStringListModel() { -#ifdef __mobile__ +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) Qt::ConnectionType contype = Qt::QueuedConnection; #else Qt::ConnectionType contype = Qt::AutoConnection; diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index 9c4dd43b490..daae122795a 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -93,7 +93,7 @@ DECLARE_SETTINGGROUP(App, "") SettingsFact* savePathFact = qobject_cast(savePath()); QString appName = QCoreApplication::applicationName(); -#ifdef __mobile__ +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) // Mobile builds always use the runtime generated location for savePath. bool userHasModifiedSavePath = false; #else @@ -101,7 +101,7 @@ DECLARE_SETTINGGROUP(App, "") #endif if (!userHasModifiedSavePath) { -#ifdef __mobile__ +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) #ifdef Q_OS_IOS // This will expose the directories directly to the File iOs app QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); diff --git a/src/Utilities/CMakeLists.txt b/src/Utilities/CMakeLists.txt index 679e721c924..8f58c82c5a0 100644 --- a/src/Utilities/CMakeLists.txt +++ b/src/Utilities/CMakeLists.txt @@ -29,7 +29,7 @@ qt_add_library(Utilities STATIC StateMachine.h ) -if(MOBILE) +if(ANDROID OR IOS) target_sources(Utilities PRIVATE MobileScreenMgr.h) if(ANDROID) target_sources(Utilities PRIVATE MobileScreenMgr.cc) diff --git a/src/Utilities/MobileScreenMgr.cc b/src/Utilities/MobileScreenMgr.cc index 66dd5013d00..963f27abff0 100644 --- a/src/Utilities/MobileScreenMgr.cc +++ b/src/Utilities/MobileScreenMgr.cc @@ -7,10 +7,9 @@ * ****************************************************************************/ - #include "MobileScreenMgr.h" -//static const char* kJniClassName = "org/mavlink/qgroundcontrol/QGCActivity"; +// static const char* kJniClassName = "org/mavlink/qgroundcontrol/QGCActivity"; void MobileScreenMgr::setKeepScreenOn(bool /*keepScreenOn*/) { diff --git a/src/Utilities/MobileScreenMgr.h b/src/Utilities/MobileScreenMgr.h index d24aa3f7f3d..d98fa53da64 100644 --- a/src/Utilities/MobileScreenMgr.h +++ b/src/Utilities/MobileScreenMgr.h @@ -7,14 +7,13 @@ * ****************************************************************************/ - #pragma once -#ifdef __mobile__ +#include + +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) -class MobileScreenMgr { - -public: +namespace MobileScreenMgr { /// Turns on/off screen sleep on mobile devices static void setKeepScreenOn(bool keepScreenOn); }; diff --git a/src/Utilities/MobileScreenMgr.mm b/src/Utilities/MobileScreenMgr.mm index cdca63521c3..e2271c67e47 100644 --- a/src/Utilities/MobileScreenMgr.mm +++ b/src/Utilities/MobileScreenMgr.mm @@ -7,7 +7,6 @@ * ****************************************************************************/ - #include "MobileScreenMgr.h" #import diff --git a/src/main.cc b/src/main.cc index e4acd9710c6..e96f83022a4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -14,10 +14,9 @@ #include #include "QGCApplication.h" -#include "QGC.h" #include "AppMessages.h" -#ifndef __mobile__ +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) #include "RunGuard.h" #endif @@ -82,12 +81,12 @@ void sigHandler(int s) int main(int argc, char *argv[]) { -#ifndef __mobile__ +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) // We make the runguard key different for custom and non custom // builds, so they can be executed together in the same device. // Stable and Daily have same QGC_APP_NAME so they would // not be able to run at the same time - const QString runguardString = QString("%1 RunGuardKey").arg(QGC_APP_NAME); + const QString runguardString = QStringLiteral("%1 RunGuardKey").arg(QGC_APP_NAME); RunGuard guard(runguardString); if (!guard.tryToRun()) {