Skip to content

Commit

Permalink
CMake: Deployment Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Jan 16, 2025
1 parent 7c64ca3 commit 321cc34
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 95 deletions.
76 changes: 15 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
#######################################################
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion cmake/CustomOptions.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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")
23 changes: 23 additions & 0 deletions custom-example/cmake/CustomOverrides.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ qt_add_library(QGC STATIC
CmdLineOptParser.h
QGCApplication.cc
QGCApplication.h
QGCConfig.h
)

add_subdirectory(ADSB)
Expand Down
2 changes: 1 addition & 1 deletion src/FactSystem/FactMetaData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ FactMetaData* FactMetaData::createFromJsonObject(const QJsonObject& json, QMap<Q
}

QString defaultValueJsonKey = _defaultValueJsonKey;
#ifdef __mobile__
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
if (json.contains(_mobileDefaultValueJsonKey)) {
defaultValueJsonKey = _mobileDefaultValueJsonKey;
}
Expand Down
2 changes: 1 addition & 1 deletion src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "ParameterManager.h"
#include "PositionManager.h"
#include "QGCCameraManager.h"
#include "QGCConfig.h"
#include "QGCCorePlugin.h"
#include "QGCFileDownload.h"
#include "QGCImageProvider.h"
Expand Down Expand Up @@ -187,6 +186,7 @@ QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting)
}
}
}
qDebug() << QGC_SETTINGS_VERSION;
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);

if (fClearCache) {
Expand Down
14 changes: 0 additions & 14 deletions src/QGCConfig.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/QmlControls/AppMessages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Settings/AppSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ DECLARE_SETTINGGROUP(App, "")

SettingsFact* savePathFact = qobject_cast<SettingsFact*>(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
bool userHasModifiedSavePath = !savePathFact->rawValue().toString().isEmpty() || !_nameToMetaDataMap[savePathName]->rawDefaultValue().toString().isEmpty();
#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));
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Utilities/MobileScreenMgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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*/)
{
Expand Down
9 changes: 4 additions & 5 deletions src/Utilities/MobileScreenMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
*
****************************************************************************/


#pragma once

#ifdef __mobile__
#include <QtCore/QtSystemDetection>

#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);
};
Expand Down
1 change: 0 additions & 1 deletion src/Utilities/MobileScreenMgr.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*
****************************************************************************/


#include "MobileScreenMgr.h"

#import <Foundation/Foundation.h>
Expand Down
7 changes: 3 additions & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
#include <QtQuick/QQuickWindow>

#include "QGCApplication.h"
#include "QGC.h"
#include "AppMessages.h"

#ifndef __mobile__
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
#include "RunGuard.h"
#endif

Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 321cc34

Please sign in to comment.