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 9b8371c
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 127 deletions.
101 changes: 22 additions & 79 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()

include(Git)

project(QGroundControl
project(${QGC_APP_NAME}
VERSION ${QGC_APP_VERSION}
DESCRIPTION ${QGC_APP_DESCRIPTION}
HOMEPAGE_URL "https://qgroundcontrol.com/"
Expand All @@ -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 @@ -220,10 +215,6 @@ if(LINUX)
find_package(Qt6 ${QT_MINIMUM_VERSION} COMPONENTS WaylandClient)
endif()

if(NOT Qt6LinguistTools_DIR)
set(Qt6LinguistTools_DIR ${QT_HOST_PATH}/lib/cmake/Qt6LinguistTools)
endif()

qt_standard_project_setup(
REQUIRES ${QT_MINIMUM_VERSION}
SUPPORTS_UP_TO ${QT_MINIMUM_VERSION}
Expand Down Expand Up @@ -290,6 +281,8 @@ endif()
# QGroundControl Resources
#######################################################

# Note: Adding Resources to Library instead requires using Q_INIT_RESOURCE(qgcresources)

if(NOT QGC_CUSTOM_BUILD)
# Custom builds can override the resources
list(APPEND QGC_RESOURCES
Expand Down Expand Up @@ -319,7 +312,7 @@ endif()
# QGroundControl Target
#######################################################

qt_add_executable(${PROJECT_NAME}
qt_add_executable(${CMAKE_PROJECT_NAME}
src/main.cc
${QGC_RESOURCES}
)
Expand All @@ -336,7 +329,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 All @@ -348,18 +341,9 @@ if(WIN32)
"${CMAKE_SOURCE_DIR}/deploy/windows/driver.msi"
"${CMAKE_SOURCE_DIR}/deploy/windows/nullsoft_installer.nsi"
"${CMAKE_SOURCE_DIR}/deploy/windows/QGroundControl.rc"
"${QGC_WINDOWS_INSTALL_HEADER_PATH}"
"${QGC_WINDOWS_ICON_PATH}"
)
# windows installer files different for core and custom
if(EXISTS ${CMAKE_SOURCE_DIR}/custom/deploy/windows/installheader.bmp)
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/custom/deploy/windows/installheader.bmp)
else()
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/deploy/windows/installheader.bmp)
endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/custom/deploy/windows/WindowsQGC.ico)
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/custom/deploy/windows/WindowsQGC.ico)
else()
list(APPEND DEPLOY_WIN_FILES ${CMAKE_SOURCE_DIR}/deploy/windows/WindowsQGC.ico)
endif()

# Destination directory where files will be copied
set(QGC_INSTALLER_SOURCE_WIN "${CMAKE_BINARY_DIR}/deploy/windows")
Expand All @@ -376,23 +360,17 @@ 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"
QT_TARGET_RC_ICONS "${QGC_WINDOWS_ICON_PATH}"
)
add_compile_definitions(_USE_MATH_DEFINES)
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 +430,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 +454,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 +484,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 +497,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 +516,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
12 changes: 11 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,19 @@ 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

# Linux
set(QGC_APPIMAGE_ICON_PATH "${CMAKE_SOURCE_DIR}/resources/icons/qgroundcontrol.png" CACHE FILEPATH "AppImage Icon Path")

# Windows
set(QGC_WINDOWS_INSTALL_HEADER_PATH "${CMAKE_SOURCE_DIR}/deploy/windows/installheader.bmp" CACHE FILEPATH "Windows Install Header Path")
set(QGC_WINDOWS_ICON_PATH "${CMAKE_SOURCE_DIR}/deploy/windows/WindowsQGC.ico" CACHE FILEPATH "Windows 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 +56,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")
File renamed without changes.
25 changes: 25 additions & 0 deletions custom-example/cmake/CustomOverrides.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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 FILEPATH "AppImage Icon Path" FORCE)
set(QGC_WINDOWS_INSTALL_HEADER_PATH "${CMAKE_SOURCE_DIR}/custom/deploy/windows/installheader.bmp" CACHE FILEPATH "Windows Install Header Path" FORCE)
set(QGC_WINDOWS_ICON_PATH "${CMAKE_SOURCE_DIR}/custom/deploy/windows/WindowsQGC.ico" CACHE FILEPATH "Windows 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 +12,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()
6 changes: 3 additions & 3 deletions src/AnalyzeView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ endif()

#===========================================================================#

set(MINIMUM_EXIV2_VERSION 0.28.0)
set(MINIMUM_EXIV2_VERSION 0.28)
set(TARGET_EXIV2_VERSION 0.28.3)

set(MINIMUM_EXPAT_VERSION 2.2.6)
Expand Down Expand Up @@ -137,8 +137,8 @@ set(TARGET_EXPAT_VERSION 2.6.4)
# endif()

if(NOT QGC_BUILD_DEPENDENCIES)
find_package(exiv2 ${MINIMUM_EXIV2_VERSION})
if(TARGET Exiv2::exiv2lib)
find_package(exiv2)
if(TARGET Exiv2::exiv2lib AND exiv2_VERSION VERSION_GREATER_EQUAL ${MINIMUM_EXIV2_VERSION})
target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
return()
endif()
Expand Down
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
7 changes: 4 additions & 3 deletions src/FirmwarePlugin/APM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
find_package(Qt6 REQUIRED COMPONENTS Core Network)

set(APM_RESOURCES)
qt_add_resources(APM_RESOURCES APMResources.qrc)
# set(APM_RESOURCES)
# qt_add_resources(APM_RESOURCES APMResources.qrc)

qt_add_library(APMFirmwarePlugin STATIC
APMFirmwarePlugin.cc
APMFirmwarePlugin.h
Expand All @@ -17,7 +18,7 @@ qt_add_library(APMFirmwarePlugin STATIC
ArduRoverFirmwarePlugin.h
ArduSubFirmwarePlugin.cc
ArduSubFirmwarePlugin.h
${APM_RESOURCES}
# ${APM_RESOURCES}
)

target_link_libraries(APMFirmwarePlugin
Expand Down
7 changes: 4 additions & 3 deletions src/FirmwarePlugin/PX4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
find_package(Qt6 REQUIRED COMPONENTS Core)

set(PX4_RESOURCES)
qt_add_resources(PX4_RESOURCES PX4Resources.qrc)
# set(PX4_RESOURCES)
# qt_add_resources(PX4_RESOURCES PX4Resources.qrc)

qt_add_library(PX4FirmwarePlugin STATIC
px4_custom_mode.h
PX4FirmwarePlugin.cc
Expand All @@ -10,7 +11,7 @@ qt_add_library(PX4FirmwarePlugin STATIC
# PX4FirmwarePluginFactory.h
PX4ParameterMetaData.cc
PX4ParameterMetaData.h
${PX4_RESOURCES}
# ${PX4_RESOURCES}
)

target_link_libraries(PX4FirmwarePlugin
Expand Down
2 changes: 1 addition & 1 deletion src/Joystick/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ qt_add_resources(Joystick "gamecontrollerdb.txt"

#===========================================================================#

set(MINIMUM_SDL2_VERSION 2.24.0)
set(MINIMUM_SDL2_VERSION 2.0.20)
set(TARGET_SDL2_VERSION 2.30.11)

if(NOT QGC_BUILD_DEPENDENCIES)
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
Loading

0 comments on commit 9b8371c

Please sign in to comment.