diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f152ac94a00..7b783433c598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -134,6 +135,7 @@ find_package(Qt6 Sql Svg Test + TextToSpeech Widgets Xml OPTIONAL_COMPONENTS @@ -220,10 +222,12 @@ 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) add_compile_definitions(_USE_MATH_DEFINES) @@ -234,12 +238,12 @@ elseif(MACOS) 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_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 ${CMAKE_SOURCE_DIR}/resources/icons/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) @@ -253,14 +257,26 @@ 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) @@ -268,7 +284,6 @@ elseif(LINUX) endif() -include(Git) add_compile_definitions( QGC_APPLICATION_NAME="QGroundControl" QGC_ORG_NAME="QGroundControl.org" diff --git a/cmake/BuildSdl2.cmake b/cmake/BuildSdl2.cmake index 929d45c1ac98..2c609b4853c0 100644 --- a/cmake/BuildSdl2.cmake +++ b/cmake/BuildSdl2.cmake @@ -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() \ No newline at end of file diff --git a/cmake/Git.cmake b/cmake/Git.cmake index df899be057c5..81d0019549d1 100644 --- a/cmake/Git.cmake +++ b/cmake/Git.cmake @@ -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) diff --git a/src/AnalyzeView/CMakeLists.txt b/src/AnalyzeView/CMakeLists.txt index 48be200dd36d..d5aefa3eeec5 100644 --- a/src/AnalyzeView/CMakeLists.txt +++ b/src/AnalyzeView/CMakeLists.txt @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6a450b83d02f..79da59d38f53 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,13 @@ +find_package(Qt6 + REQUIRED + COMPONENTS + Core + Core5Compat + QuickControls2 + QuickWidgets + Widgets +) + qt_add_library(qgc STATIC CmdLineOptParser.cc CmdLineOptParser.h diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index b6fd47d30457..b6e5c1940212 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -20,7 +20,9 @@ if(ANDROID) ) else() include(BuildSdl2) + build_sdl2() if(SDL2_FOUND) + message(STATUS "Building JoystickSDL") target_sources(Joystick PRIVATE JoystickSDL.cc diff --git a/src/MissionManager/CMakeLists.txt b/src/MissionManager/CMakeLists.txt index ed2295374620..a48f8c32191b 100644 --- a/src/MissionManager/CMakeLists.txt +++ b/src/MissionManager/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt6 REQUIRED COMPONENTS Core) +find_package(Qt6 REQUIRED COMPONENTS Core Xml) qt_add_library(MissionManager STATIC BlankPlanCreator.cc @@ -102,6 +102,7 @@ target_link_libraries(MissionManager PUBLIC Qt6::Xml qgc + UTMSP ) target_include_directories(MissionManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/QmlControls/CMakeLists.txt b/src/QmlControls/CMakeLists.txt index 911705f4b582..cde039906178 100644 --- a/src/QmlControls/CMakeLists.txt +++ b/src/QmlControls/CMakeLists.txt @@ -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 @@ -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}) diff --git a/src/Settings/CMakeLists.txt b/src/Settings/CMakeLists.txt index 06c10966b63c..f0aeb71429df 100644 --- a/src/Settings/CMakeLists.txt +++ b/src/Settings/CMakeLists.txt @@ -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 @@ -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}) diff --git a/src/UTMSP/CMakeLists.txt b/src/UTMSP/CMakeLists.txt index 00105ae855b6..1b71f691a7c8 100644 --- a/src/UTMSP/CMakeLists.txt +++ b/src/UTMSP/CMakeLists.txt @@ -1,11 +1,16 @@ find_package(Qt6 REQUIRED COMPONENTS Core) -find_package(Threads REQUIRED) qt_add_library(UTMSP STATIC) -option(CONFIG_UTM_ADAPTER "Enable UTM Adapter" OFF) # TODO: Make this QGC_CONFIG_UTM_ADAPTER -if(CONFIG_UTM_ADAPTER) +# set(UTMSP_RESOURCES) + +option(QGC_UTM_ADAPTER "Enable UTM Adapter" OFF) +if(QGC_UTM_ADAPTER) message(STATUS "UTMSP is Initialized") + + find_package(Qt6 REQUIRED COMPONENTS Qml Location Widgets) + find_package(Threads REQUIRED) + target_sources(UTMSP PRIVATE UTMSPAircraft.cpp @@ -30,38 +35,37 @@ if(CONFIG_UTM_ADAPTER) UTMSPVehicle.h ) + target_link_libraries(UTMSP + PRIVATE + nlohmann_json + PUBLIC + Qt6::Core + Qt6::Location + Qt6::Widgets + Threads::Threads + qgc + ) + + target_include_directories(UTMSP + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + services + ) + + target_compile_definitions(UTMSP PUBLIC CONFIG_UTM_ADAPTER) + add_custom_target(UTMSPQml SOURCES UTMSPActivationStatusBar.qml UTMSPAdapterEditor.qml UTMSPMapVisuals.qml ) + + # qt_add_resources(UTMSP_RESOURCES utmsp.qrc) else() message(STATUS "UTMSP: Dummy is Initialized") - set(UTMSP_RESOURCES) - - qt_add_resources(UTMSP_RESOURCES dummy/utmsp_dummy.qrc) - - target_sources(UTMSP - PRIVATE - ${UTMSP_RESOURCES} - ) + # qt_add_resources(UTMSP_RESOURCES dummy/utmsp_dummy.qrc) endif() -target_link_libraries(UTMSP - PRIVATE - nlohmann_json - PUBLIC - Qt6::Core - Qt6::Location - Qt6::Widgets - Threads::Threads - qgc -) - -target_include_directories(UTMSP - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - services -) +# target_sources(UTMSP PUBLIC ${UTMSP_RESOURCES}) diff --git a/src/Vehicle/CMakeLists.txt b/src/Vehicle/CMakeLists.txt index 990753a00774..825867597fbf 100644 --- a/src/Vehicle/CMakeLists.txt +++ b/src/Vehicle/CMakeLists.txt @@ -105,6 +105,7 @@ target_link_libraries(Vehicle qgc libevents Actuators + UTMSP ) target_include_directories(Vehicle PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/Viewer3D/CMakeLists.txt b/src/Viewer3D/CMakeLists.txt index 13751fe9f771..bf63e8c0fa4b 100644 --- a/src/Viewer3D/CMakeLists.txt +++ b/src/Viewer3D/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(Viewer3DQml) -find_package(Qt6 REQUIRED COMPONENTS Core Quick3D) - +find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Network Positioning Quick3D Xml) qt_add_library(Viewer3D STATIC Viewer3DManager.cc @@ -26,13 +25,18 @@ qt_add_library(Viewer3D STATIC Viewer3DTileQuery.cc OsmParserThread.cc OsmParserThread.h - ) target_link_libraries(Viewer3D PUBLIC qgc + Qt6::Core + Qt6::Gui + Qt6::Multimedia + Qt6::Network + Qt6::Positioning Qt6::Quick3D + Qt6::Xml ) target_include_directories(Viewer3D PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/comm/CMakeLists.txt b/src/comm/CMakeLists.txt index e2bb70a55ad9..0ad27ccf2fc3 100644 --- a/src/comm/CMakeLists.txt +++ b/src/comm/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt6 REQUIRED COMPONENTS Bluetooth Core Network Test) +find_package(Qt6 REQUIRED COMPONENTS Bluetooth Core Network Test Widgets) # NO_SERIAL_LINK # TODO: Make this QGC_NO_SERIAL_LINK @@ -56,6 +56,7 @@ if(ANDROID) target_link_libraries(comm PUBLIC qtandroidserialport) else() + find_package(Qt6 REQUIRED COMPONENTS SerialPort) target_link_libraries(comm PUBLIC Qt6::SerialPort) endif() diff --git a/test/qgcunittest/CMakeLists.txt b/test/qgcunittest/CMakeLists.txt index 6c2f285039f1..a768a9c87526 100644 --- a/test/qgcunittest/CMakeLists.txt +++ b/test/qgcunittest/CMakeLists.txt @@ -1,3 +1,4 @@ +find_package(Qt6 REQUIRED COMPONENTS Core Test) qt_add_library(qgcunittest STATIC