Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Deploy Adjustments #11362

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
enable_testing()
endif()

set(QT_ENABLE_VERBOSE_DEPLOYMENT ON CACHE BOOL "Verbose Deployment")

if(ANDROID)
cmake_print_variables(QT_ANDROID_APPLICATION_ARGUMENTS QT_HOST_PATH)

set(QT_ENABLE_VERBOSE_DEPLOYMENT ON CACHE BOOL "Verbose Deployment")
# QT_USE_TARGET_ANDROID_BUILD_DIR
list(APPEND QT_ANDROID_MULTI_ABI_FORWARD_VARS QGC_STABLE_BUILD)
list(APPEND QT_ANDROID_MULTI_ABI_FORWARD_VARS QT_HOST_PATH)
Expand Down Expand Up @@ -134,6 +135,7 @@ find_package(Qt6
Sql
Svg
Test
TextToSpeech
Widgets
Xml
OPTIONAL_COMPONENTS
Expand Down Expand Up @@ -220,26 +222,32 @@ if(Qt6LinguistTools_FOUND)
qt_add_translations(${PROJECT_NAME} TS_FILES ${TS_SOURCES}) # TODO: Update to new qt_add_translations form in Qt6.7
endif()

target_precompile_headers(${PROJECT_NAME} PRIVATE src/pch.h)
target_precompile_headers(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/pch.h)

set_target_properties(${PROJECT_NAME} PROPERTIES QT_RESOURCE_PREFIX "/qgc")

include(Git)

if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
set_target_properties(${PROJECT_NAME}
PROPERTIES
WIN32_EXECUTABLE TRUE
QT_TARGET_RC_ICONS "${CMAKE_SOURCE_DIR}/deploy/windows/WindowsQGC.ico"
)
add_compile_definitions(_USE_MATH_DEFINES)
elseif(MACOS)
set_target_properties(${PROJECT_NAME}
PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/deploy/mac/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2018 QGroundControl. All rights reserved."
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/deploy/mac/MacOSXBundleInfo.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2020 QGroundControl. All rights reserved."
MACOSX_BUNDLE_GUI_IDENTIFIER "io.mavlink.qgroundcontrol"
MACOSX_BUNDLE_ICON_FILE "${CMAKE_SOURCE_DIR}/resources/icons/macx.icns"
# MACOSX_BUNDLE_INFO_STRING
# MACOSX_BUNDLE_LONG_VERSION_STRING
# MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE_ICON_FILE "macx.icns"
MACOSX_BUNDLE_INFO_STRING "Open Source Ground Control App"
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)
elseif(IOS)
enable_language(OBJC)
Expand All @@ -253,22 +261,33 @@ elseif(ANDROID)
include(${android_openssl_SOURCE_DIR}/android_openssl.cmake)
add_android_openssl_libraries(${PROJECT_NAME})

set(ANDROID_PLATFORM_ARCHITECTURE_CODE)
if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
set(ANDROID_PLATFORM_ARCHITECTURE_CODE "032")
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
set(ANDROID_PLATFORM_ARCHITECTURE_CODE "064")
elseif(${ANDROID_ABI} STREQUAL "x86")
set(ANDROID_PLATFORM_ARCHITECTURE_CODE "132")
elseif(${ANDROID_ABI} STREQUAL "x86_64")
set(ANDROID_PLATFORM_ARCHITECTURE_CODE "164")
endif()
set(ANDROID_VERSION_CODE "${ANDROID_PLATFORM_ARCHITECTURE_CODE}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}")

set_target_properties(${PROJECT_NAME}
PROPERTIES
# QT_ANDROID_ABIS ${ANDROID_ABI}
QT_ANDROID_MIN_SDK_VERSION 26
QT_ANDROID_TARGET_SDK_VERSION 34
QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android
QT_ANDROID_VERSION_NAME "${CMAKE_PROJECT_VERSION}"
# QT_ANDROID_VERSION_CODE "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
QT_ANDROID_VERSION_NAME ${CMAKE_PROJECT_VERSION}
QT_ANDROID_VERSION_CODE ${ANDROID_VERSION_CODE}
QT_QML_ROOT_PATH ${CMAKE_SOURCE_DIR}
)
# get_target_property(QGC_ANDROID_DEPLOY_FILE ${PROJECT_NAME} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
elseif(LINUX)

endif()

include(Git)
add_compile_definitions(
QGC_APPLICATION_NAME="QGroundControl"
QGC_ORG_NAME="QGroundControl.org"
Expand Down
67 changes: 35 additions & 32 deletions cmake/BuildSdl2.cmake
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
include(FetchContent)
set(SDL2_DISABLE_SDL2MAIN TRUE CACHE INTERNAL "")
set(SDL_SHARED FALSE CACHE INTERNAL "")
set(SDL_STATIC TRUE CACHE INTERNAL "")
set(SDL_TEST FALSE CACHE INTERNAL "")
function(build_sdl2)
include(FetchContent)
set(SDL2_DISABLE_SDL2MAIN TRUE CACHE INTERNAL "")
set(SDL_SHARED FALSE CACHE INTERNAL "")
set(SDL_STATIC TRUE CACHE INTERNAL "")
set(SDL_TEST FALSE CACHE INTERNAL "")

set(SDL_ATOMIC TRUE CACHE INTERNAL "")
set(SDL_AUDIO FALSE CACHE INTERNAL "")
set(SDL_CPUINFO TRUE CACHE INTERNAL "")
set(SDL_EVENTS TRUE CACHE INTERNAL "")
set(SDL_FILE FALSE CACHE INTERNAL "")
set(SDL_FILESYSTEM FALSE CACHE INTERNAL "")
set(SDL_HAPTIC FALSE CACHE INTERNAL "")
set(SDL_HIDAPI TRUE CACHE INTERNAL "")
set(SDL_JOYSTICK TRUE CACHE INTERNAL "")
set(SDL_LOADSO TRUE CACHE INTERNAL "")
set(SDL_LOCALE TRUE CACHE INTERNAL "")
set(SDL_MISC FALSE CACHE INTERNAL "")
set(SDL_POWER FALSE CACHE INTERNAL "")
set(SDL_RENDER FALSE CACHE INTERNAL "")
set(SDL_SENSOR FALSE CACHE INTERNAL "")
set(SDL_THREADS TRUE CACHE INTERNAL "")
set(SDL_TIMERS FALSE CACHE INTERNAL "")
set(SDL_VIDEO FALSE CACHE INTERNAL "")
set(SDL_ATOMIC TRUE CACHE INTERNAL "")
set(SDL_AUDIO FALSE CACHE INTERNAL "")
set(SDL_CPUINFO TRUE CACHE INTERNAL "")
set(SDL_EVENTS TRUE CACHE INTERNAL "")
set(SDL_FILE FALSE CACHE INTERNAL "")
set(SDL_FILESYSTEM FALSE CACHE INTERNAL "")
set(SDL_HAPTIC FALSE CACHE INTERNAL "")
set(SDL_HIDAPI TRUE CACHE INTERNAL "")
set(SDL_JOYSTICK TRUE CACHE INTERNAL "")
set(SDL_LOADSO TRUE CACHE INTERNAL "")
set(SDL_LOCALE TRUE CACHE INTERNAL "")
set(SDL_MISC FALSE CACHE INTERNAL "")
set(SDL_POWER FALSE CACHE INTERNAL "")
set(SDL_RENDER FALSE CACHE INTERNAL "")
set(SDL_SENSOR FALSE CACHE INTERNAL "")
set(SDL_THREADS TRUE CACHE INTERNAL "")
set(SDL_TIMERS FALSE CACHE INTERNAL "")
set(SDL_VIDEO FALSE CACHE INTERNAL "")

FetchContent_Declare(
SDL
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.30.2
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(SDL)
set(SDL2_FOUND TRUE)
FetchContent_Declare(
SDL
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.30.2
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(SDL)

set(SDL2_FOUND TRUE PARENT_SCOPE)
endfunction()
73 changes: 46 additions & 27 deletions cmake/Git.cmake
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
find_package(Git)

if(NOT GIT_FOUND OR NOT EXISTS "${PROJECT_SOURCE_DIR}/.git")
return()
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE GIT_SUBMODULE_RESULT
OUTPUT_VARIABLE GIT_SUBMODULE_OUTPUT
ERROR_VARIABLE GIT_SUBMODULE_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_SUBMODULE_RESULT EQUAL 0)
cmake_print_variables(GIT_SUBMODULE_RESULT GIT_SUBMODULE_OUTPUT GIT_SUBMODULE_ERROR)
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMODULE_RESULT}, please checkout submodules")
endif()
endif()
endif()

# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(NOT GIT_SUBMODULE)
return()
endif()
include(CMakePrintHelpers)

message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE GIT_SUBMODULE_RESULT)
if(NOT GIT_SUBMODULE_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMODULE_RESULT}, please checkout submodules")
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE APP_VERSION_STR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
cmake_print_variables(APP_VERSION_STR)

# Fetch the necessary git variables
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE APP_VERSION_STR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
cmake_print_variables(GIT_BRANCH)

execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE REL_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# execute_process(
# COMMAND ${GIT_EXECUTABLE} describe --abbrev=0
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE REL_VERSION
# OUTPUT_STRIP_TRAILING_WHITESPACE
# )
# cmake_print_variables(REL_VERSION)

execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%aI ${REL_VERSION}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE REL_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# execute_process(
# COMMAND ${GIT_EXECUTABLE} log -1 --format=%aI ${REL_VERSION}
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE REL_DATE
# OUTPUT_STRIP_TRAILING_WHITESPACE
# )
# cmake_print_variables(REL_DATE)
2 changes: 1 addition & 1 deletion src/AnalyzeView/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core Charts Location Widgets)

qt_add_library(AnalyzeView STATIC
ExifParser.cc
Expand Down
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
find_package(Qt6
REQUIRED
COMPONENTS
Core
Core5Compat
QuickControls2
QuickWidgets
Widgets
)

qt_add_library(qgc STATIC
CmdLineOptParser.cc
CmdLineOptParser.h
Expand Down
2 changes: 2 additions & 0 deletions src/Joystick/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if(ANDROID)
)
else()
include(BuildSdl2)
build_sdl2()
if(SDL2_FOUND)
message(STATUS "Building JoystickSDL")
target_sources(Joystick
PRIVATE
JoystickSDL.cc
Expand Down
3 changes: 2 additions & 1 deletion src/MissionManager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core Xml)

qt_add_library(MissionManager STATIC
BlankPlanCreator.cc
Expand Down Expand Up @@ -102,6 +102,7 @@ target_link_libraries(MissionManager
PUBLIC
Qt6::Xml
qgc
UTMSP
)

target_include_directories(MissionManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
11 changes: 6 additions & 5 deletions src/QmlControls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Core Qml)
find_package(Qt6 REQUIRED COMPONENTS Core Qml Concurrent Location Widgets)

qt_add_library(QmlControls STATIC
AppMessages.cc
Expand Down Expand Up @@ -142,13 +142,14 @@ add_custom_target(QmlControlsQml
)

target_link_libraries(QmlControls
PUBLIC
qgc
FactSystem
PUBLIC
PRIVATE
Qt6::Concurrent
Qt6::Location
Qt6::Widgets
PUBLIC
qgc
FactSystem
UTMSP
)

target_include_directories(QmlControls PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
7 changes: 5 additions & 2 deletions src/Settings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core Qml Multimedia)

qt_add_library(Settings STATIC
ADSBVehicleManagerSettings.cc
Expand Down Expand Up @@ -46,9 +46,12 @@ qt_add_library(Settings STATIC
)

target_link_libraries(Settings
PRIVATE
Qt6::Multimedia
PUBLIC
qgc
Qt6::Multimedia
Qt6::Core
Qt6::Qml
)

target_include_directories(Settings PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Loading