diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..e1345f284b5 --- /dev/null +++ b/.clang-format @@ -0,0 +1,17 @@ +--- +BasedOnStyle: Google +AccessModifierOffset: -4 +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: Inline +BinPackArguments: false +BinPackParameters: false +ColumnLimit: 120 +IncludeBlocks: Preserve +IndentWidth: 4 +Language: Cpp +PackConstructorInitializers: Never +PenaltyBreakAssignment: 80 +SortIncludes: true +SpacesBeforeTrailingComments: 1 +Standard: c++17 diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000000..b9925b48bb8 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,39 @@ +--- +Checks: > + clang-diagnostic-*, + clang-analyzer-*, + bugprone-*, + cppcoreguidelines-*, + google-*, + llvm-*, + misc-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -bugprone-easily-swappable-parameters, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-static-cast-downcast, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-special-member-functions, + -google-readability-todo, + -llvm-header-guard, + -llvm-include-order, + -misc-include-cleaner, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-use-internal-linkage, + -modernize-avoid-c-arrays, + -modernize-use-trailing-return-type, + -readability-convert-member-functions-to-static, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-redundant-access-specifiers, + -readability-uppercase-literal-suffix +WarningsAsErrors: '*' +HeaderFilterRegex: '^((?!vendor).)*$' +... diff --git a/.cmake-format b/.cmake-format new file mode 100644 index 00000000000..ca863a20680 --- /dev/null +++ b/.cmake-format @@ -0,0 +1,3 @@ +format: + tab_size: 4 + line_width: 100 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..509c02a0114 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace=true diff --git a/.github/actions/qt-android/action.yml b/.github/actions/qt-android/action.yml index e2e9990f449..ba0ae16ed9b 100644 --- a/.github/actions/qt-android/action.yml +++ b/.github/actions/qt-android/action.yml @@ -63,7 +63,6 @@ runs: uses: jurplel/install-qt-action@v4 with: version: ${{ inputs.version }} - aqtversion: ==3.1.* host: ${{ inputs.host }} target: desktop arch: ${{ inputs.arch }} @@ -76,12 +75,10 @@ runs: uses: jurplel/install-qt-action@v4 with: version: ${{ inputs.version }} - aqtversion: ==3.1.* host: ${{ inputs.host }} target: android arch: android_armv7 dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} @@ -90,12 +87,10 @@ runs: uses: jurplel/install-qt-action@v4 with: version: ${{ inputs.version }} - aqtversion: ==3.1.* host: ${{ inputs.host }} target: android arch: android_arm64_v8a dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} @@ -104,12 +99,10 @@ runs: uses: jurplel/install-qt-action@v4 with: version: ${{ inputs.version }} - aqtversion: ==3.1.* host: ${{ inputs.host }} target: android arch: android_x86 dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} @@ -118,11 +111,9 @@ runs: uses: jurplel/install-qt-action@v4 with: version: ${{ inputs.version }} - aqtversion: ==3.1.* host: ${{ inputs.host }} target: android arch: android_x86_64 dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90d35da8c80..4122b57d746 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,4 @@ version: 2 - updates: - package-ecosystem: github-actions directory: / diff --git a/.github/workflows/android-linux.yml b/.github/workflows/android-linux.yml index 88a1f23d086..33737d74ca3 100644 --- a/.github/workflows/android-linux.yml +++ b/.github/workflows/android-linux.yml @@ -12,9 +12,9 @@ on: - '.github/workflows/android-linux.yml' - 'deploy/android/**' - 'src/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} diff --git a/.github/workflows/android-macos.yml b/.github/workflows/android-macos.yml index 03f8cef329f..722d1e89099 100644 --- a/.github/workflows/android-macos.yml +++ b/.github/workflows/android-macos.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -44,7 +43,7 @@ jobs: - name: Install Dependencies run: | brew update - brew install cmake ninja ccache + brew install ccache continue-on-error: true - name: Install Qt for Android diff --git a/.github/workflows/android-windows.yml b/.github/workflows/android-windows.yml index 1a9f580fc2b..b1c9ff91518 100644 --- a/.github/workflows/android-windows.yml +++ b/.github/workflows/android-windows.yml @@ -12,9 +12,9 @@ on: - '.github/workflows/android-windows.yml' - 'deploy/android/**' - 'src/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -32,6 +32,7 @@ jobs: env: ARTIFACT: QGroundControl.apk + PACKAGE: QGroundControl QT_VERSION: 6.8.1 GST_VERSION: 1.22.12 QT_ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/deploy/android/android_release.keystore @@ -50,7 +51,9 @@ jobs: - uses: seanmiddleditch/gha-setup-ninja@v5 - uses: lukka/get-cmake@latest - - uses: mozilla-actions/sccache-action@v0.0.7 + + - name: Update ccache + run: choco install ccache - name: Install Qt for Android uses: ./.github/actions/qt-android @@ -85,5 +88,5 @@ jobs: - name: Save APK uses: actions/upload-artifact@v4 with: - name: ${{ env.ARTIFACT }} + name: ${{ env.PACKAGE }} path: ${{ runner.temp }}/shadow_build_dir/android-build/*.apk diff --git a/.github/workflows/custom.yml b/.github/workflows/custom.yml index 8ab5cb1ad88..fe7858fbc1c 100644 --- a/.github/workflows/custom.yml +++ b/.github/workflows/custom.yml @@ -9,12 +9,13 @@ on: - 'v*' pull_request: paths: + - '.github/workflows/custom.yml' + - 'deploy/windows/**' - 'src/**' - 'custom-example/**' - - 'deploy/windows/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -55,23 +56,12 @@ jobs: - uses: seanmiddleditch/gha-setup-ninja@v5 - uses: lukka/get-cmake@latest - # - name: Install Vulkan - # working-directory: ${{ runner.temp }} - # shell: pwsh - # run: | - # Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" -OutFile vulkan-sdk.exe - # .\vulkan-sdk.exe --root C:\VulkanSDK\latest --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.glm com.lunarg.vulkan.volk com.lunarg.vulkan.vma com.lunarg.vulkan.debug - # echo "VULKAN_SDK=C:\VulkanSDK\latest" >> $env:GITHUB_ENV - - name: Install GStreamer uses: blinemedical/setup-gstreamer@v1 with: version: ${{ env.GST_VERSION }} - # - name: Install Gstreamer - # run: choco install --no-progress gstreamer gstreamer-devel --version=${{ env.GST_VERSION }} - - - name: Set Up sccache + - name: Set Up SCCache uses: mozilla-actions/sccache-action@v0.0.7 - name: Set Up Cache @@ -82,7 +72,6 @@ jobs: variant: sccache save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} verbose: 1 - evict-old-files: 'job' - name: Install Qt for Windows (x64) if: matrix.Arch == 'x64' diff --git a/.github/workflows/docker-linux.yml b/.github/workflows/docker-linux.yml index e4db0affca8..2c465e621a5 100644 --- a/.github/workflows/docker-linux.yml +++ b/.github/workflows/docker-linux.yml @@ -12,6 +12,7 @@ on: - 'src/**' - 'deploy/docker/**' - 'deploy/linux/**' + - 'CMakeLists.txt' concurrency: # cancel jobs on PRs only diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index b22d761e53d..a7a17a27c72 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -27,17 +26,6 @@ jobs: GST_VERSION: 1.22.12 steps: - - name: Recover disk space - run: | - df -h - ls /Applications - brew uninstall google-chrome - sudo rm -rf /Users/runner/Library/Android - sudo rm -rf /Applications/Xcode_14* - sudo rm -rf /Applications/Xcode_15* - ls /Applications - df -h - - name: Checkout repo uses: actions/checkout@v4 with: @@ -51,14 +39,12 @@ jobs: xcode-version: latest-stable - uses: seanmiddleditch/gha-setup-ninja@v5 + - uses: lukka/get-cmake@latest - name: Install Dependencies run: | brew update - brew install cmake ninja ccache - - - uses: seanmiddleditch/gha-setup-ninja@v5 - - uses: lukka/get-cmake@latest + brew install ccache - name: Set Up Cache uses: hendrikmuhs/ccache-action@main @@ -74,7 +60,6 @@ jobs: uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} - aqtversion: ==3.1.* host: mac target: desktop arch: clang_64 @@ -86,12 +71,10 @@ jobs: uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} - aqtversion: ==3.1.* host: mac target: ios arch: ios dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 513c2dc92af..7ec0a7782bb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,9 +12,9 @@ on: - '.github/workflows/linux.yml' - 'deploy/linux/**' - 'src/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -49,7 +49,9 @@ jobs: run: | chmod a+x ./tools/setup/install-dependencies-debian.sh sudo ./tools/setup/install-dependencies-debian.sh - python3 -m pip install --user ninja cmake + + - uses: lukka/get-cmake@latest + - uses: seanmiddleditch/gha-setup-ninja@v5 - name: Install Vulkan run: | @@ -86,7 +88,6 @@ jobs: uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} - aqtversion: ==3.1.* host: linux target: desktop arch: linux_gcc_64 @@ -97,9 +98,6 @@ jobs: # - name: Build GStreamer # uses: ./.github/actions/gstreamer - - uses: lukka/get-cmake@latest - - uses: seanmiddleditch/gha-setup-ninja@v5 - - run: mkdir ${{ runner.temp }}/shadow_build_dir - name: Configure diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 11d9c42823a..06bb9de1d93 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,9 +12,9 @@ on: - '.github/workflows/macos.yml' - 'deploy/macos/**' - 'src/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -70,6 +70,7 @@ jobs: - name: Set Up Cache uses: hendrikmuhs/ccache-action@main with: + create-symlink: true key: ${{ runner.os }}-${{ matrix.BuildType }} max-size: 1G save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} @@ -80,7 +81,6 @@ jobs: uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} - aqtversion: ==3.1.* host: mac target: desktop arch: clang_64 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 92aa2e056d2..0a78d823b10 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,9 +12,9 @@ on: - '.github/workflows/windows.yml' - 'deploy/windows/**' - 'src/**' + - 'CMakeLists.txt' concurrency: - # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -62,9 +62,6 @@ jobs: with: version: ${{ env.GST_VERSION }} - # - name: Install Gstreamer - # run: choco install --no-progress gstreamer gstreamer-devel --version=${{ env.GST_VERSION }} - - name: Set Up sccache uses: mozilla-actions/sccache-action@v0.0.7 @@ -75,7 +72,6 @@ jobs: max-size: 1G variant: sccache save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - evict-old-files: 'job' - name: Install Qt for Windows (x64) uses: jurplel/install-qt-action@v4 @@ -95,12 +91,11 @@ jobs: uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} - aqtversion: ==3.1.* + aqtversion: ==3.1.19 host: windows target: desktop arch: win64_msvc2022_arm64_cross_compiled dir: ${{ runner.temp }} - extra: --autodesktop modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} diff --git a/.gitignore b/.gitignore index 887cfef683c..0f03ff6df8d 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,6 @@ Qt*-linux*.tar.* # vitepress - user guide node_modules/ docs/.vitepress/cache/ -docs/.vitepress/dist/ \ No newline at end of file +docs/.vitepress/dist/ + +CMakeUserPresets.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..7ab049cd01d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + args: [--allow-multiple-documents, --unsafe] diff --git a/CMakeLists.txt b/CMakeLists.txt index 58527d43a1e..23002324f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,9 +65,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) # set(CMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG ON) -set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release") -if(NOT CMAKE_BUILD_TYPE) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release") endif() if(LINUX) @@ -82,6 +82,9 @@ if(UNIX) message(STATUS "Using CCache") set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + if(APPLE) + set(CMAKE_OBJC_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + endif() endif() elseif(WIN32) find_program(SCCACHE_PROGRAM sccache) @@ -119,10 +122,24 @@ if(POLICY CMP0168) set(CMAKE_POLICY_DEFAULT_CMP0168 NEW) endif() +# https://cmake.org/cmake/help/latest/policy/CMP0075.html#policy:CMP0075 +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) + set(CMAKE_POLICY_DEFAULT_CMP0075 NEW) +endif() + +if(QGC_USE_IWYU) + include(IWYU) +endif() + ####################################################### # Qt6 Configuration ####################################################### +if(CMAKE_CROSSCOMPILING AND NOT IS_DIRECTORY ${QT_HOST_PATH}) + message(FATAL_ERROR "You need to set QT_HOST_PATH to cross compile Qt.") +endif() + set(QT_SILENCE_MISSING_DEPENDENCY_TARGET_WARNING ON) set(QT_MINIMUM_VERSION 6.8.1) @@ -317,6 +334,16 @@ qt_add_executable(${CMAKE_PROJECT_NAME} ${QGC_RESOURCES} ) +if(NOT ANDROID AND NOT IOS) + target_sources(${CMAKE_PROJECT_NAME} + PRIVATE + src/RunGuard.cc + src/RunGuard.h + ) +endif() + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) + if(Qt6LinguistTools_FOUND) file(GLOB TS_SOURCES ${CMAKE_SOURCE_DIR}/translations/qgc_*.ts) set_source_files_properties(${TS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/i18n") @@ -410,11 +437,11 @@ elseif(IOS) # set(QT_NO_FFMPEG_XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON) # qt_add_ios_ffmpeg_libraries(CMAKE_PROJECT_NAME) elseif(ANDROID) - FetchContent_Declare(android_openssl - DOWNLOAD_EXTRACT_TIMESTAMP true + include(CPM) + CPMAddPackage( + NAME android_openssl URL https://github.com/KDAB/android_openssl/archive/refs/heads/master.zip ) - FetchContent_MakeAvailable(android_openssl) include(${android_openssl_SOURCE_DIR}/android_openssl.cmake) add_android_openssl_libraries(${CMAKE_PROJECT_NAME}) @@ -439,12 +466,10 @@ elseif(ANDROID) QT_ANDROID_PACKAGE_SOURCE_DIR "${QGC_ANDROID_PACKAGE_SOURCE_DIR}" QT_ANDROID_VERSION_NAME ${CMAKE_PROJECT_VERSION} QT_ANDROID_VERSION_CODE ${ANDROID_VERSION_CODE} - QT_QML_ROOT_PATH ${CMAKE_SOURCE_DIR}/src + QT_QML_ROOT_PATH ${CMAKE_SOURCE_DIR} # QT_ANDROID_SDK_BUILD_TOOLS_REVISION # QT_ANDROID_SYSTEM_LIBS_PREFIX ) - get_target_property(QGC_ANDROID_DEPLOY_FILE ${CMAKE_PROJECT_NAME} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE) - cmake_print_variables(QGC_ANDROID_DEPLOY_FILE) elseif(LINUX) endif() @@ -458,9 +483,11 @@ add_compile_definitions( ) add_subdirectory(src) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core + Qt6::Core5Compat Qt6::Quick Qt6::Widgets QGC @@ -472,12 +499,22 @@ if(QGC_BUILD_TESTING) target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE qgctest) endif() -target_precompile_headers(${CMAKE_PROJECT_NAME} - PRIVATE - - - -) +if(ANDROID) + target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/android/src/AndroidInit.cc) + + target_link_libraries(${CMAKE_PROJECT_NAME} + PRIVATE + Qt6::Core + Joystick + Utilities + ) + + target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/android/src) + + if(NOT QGC_NO_SERIAL_LINK) + target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Comms) + endif() +endif() qt_import_plugins(${CMAKE_PROJECT_NAME} INCLUDE Qt6::QSvgPlugin @@ -514,7 +551,10 @@ qt_generate_deploy_qml_app_script( ) install(SCRIPT ${deploy_script}) -if(LINUX) +if(ANDROID) + # get_target_property(QGC_ANDROID_DEPLOY_FILE ${CMAKE_PROJECT_NAME} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE) + # cmake_print_variables(QGC_ANDROID_DEPLOY_FILE) +elseif(LINUX) configure_file( ${CMAKE_SOURCE_DIR}/deploy/linux/org.mavlink.qgroundcontrol.desktop.in ${CMAKE_BINARY_DIR}/org.mavlink.qgroundcontrol.desktop @@ -551,12 +591,4 @@ elseif(MACOS) install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/CreateMacDMG.cmake") endif() -## Enforce Handling of All Enum Cases - -if(WIN32) - add_compile_options(/w44265 /we44265) -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wswitch -Werror=switch") -endif() - include(printSummary) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000000..c5593e94083 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,16 @@ +{ + "version": 4, + "cmakeMinimumRequired": { + "major": 3, + "minor": 22, + "patch": 1 + }, + "include": [ + "cmake/presets/common.json", + "cmake/presets/Android.json", + "cmake/presets/iOS.json", + "cmake/presets/Linux.json", + "cmake/presets/macOS.json", + "cmake/presets/Windows.json" + ] +} diff --git a/android/build.gradle b/android/build.gradle index d62f86b1a00..679b034ed7f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.7.3' + classpath 'com.android.tools.build:gradle:8.8.0' } } @@ -35,6 +35,7 @@ android { * - qtAndroidDir - holds the path to qt android files * needed to build any Qt application * on Android. + * - qtGradlePluginType - whether to build an app or a library * * are defined in gradle.properties file. This file is * updated by QtCreator and androiddeployqt tools. @@ -65,6 +66,7 @@ android { tasks.withType(JavaCompile) { options.incremental = true + // options.compilerArgs += ['-Xlint:deprecation'] } buildFeatures { @@ -91,10 +93,6 @@ android { targetSdkVersion qtTargetSdkVersion ndk.abiFilters = qtTargetAbiList.split(",") - // namespace "org.mavlink.qgroundcontrol" - // versionName "5.0" - // versionCode timestampInt - // println "applicationId: ${applicationId}" println "minSdkVersion: ${minSdkVersion}" println "targetSdkVersion: ${targetSdkVersion}" diff --git a/android/gradle.properties b/android/gradle.properties index ce8f6b23dfd..81656f0b448 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -12,8 +12,8 @@ org.gradle.parallel=true # Gradle caching allows reusing the build artifacts from a previous # build with the same inputs. However, over time, the cache size will # grow. Uncomment the following line to enable it. -org.gradle.caching=true -org.gradle.configuration-cache=true +# org.gradle.caching=true +# org.gradle.configuration-cache=true # Allow AndroidX usage android.useAndroidX=true diff --git a/android/src/AndroidInit.cpp b/android/src/AndroidInit.cc similarity index 98% rename from android/src/AndroidInit.cpp rename to android/src/AndroidInit.cc index d59ea92a114..2196e4a070a 100644 --- a/android/src/AndroidInit.cpp +++ b/android/src/AndroidInit.cc @@ -3,7 +3,7 @@ #include "AndroidSerial.h" #endif #include "JoystickAndroid.h" -#include +#include "QGCLoggingCategory.h" #include #include diff --git a/android/src/AndroidInterface.h b/android/src/AndroidInterface.h index 39e12e0f13a..8e915325705 100644 --- a/android/src/AndroidInterface.h +++ b/android/src/AndroidInterface.h @@ -26,5 +26,5 @@ namespace AndroidInterface QString getSDCardPath(); jclass getActivityClass(); - constexpr const char* kJniQGCActivityClassName = "org/mavlink/qgroundcontrol/QGCActivity"; + constexpr const char *kJniQGCActivityClassName = "org/mavlink/qgroundcontrol/QGCActivity"; }; diff --git a/cmake/CreateCPackArchive.cmake b/cmake/CreateCPackArchive.cmake index a78883dd997..073d1cf1ee0 100644 --- a/cmake/CreateCPackArchive.cmake +++ b/cmake/CreateCPackArchive.cmake @@ -1,6 +1,7 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "ZIP") +list(APPEND CPACK_GENERATOR "ZIP") +set(CPACK_BINARY_ZIP ON) set(CPACK_ARCHIVE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) set(CPACK_ARCHIVE_FILE_EXTENSION TXZ) diff --git a/cmake/CreateCPackBundle.cmake b/cmake/CreateCPackBundle.cmake index 5c2c7a01e2f..3c1caa27f73 100644 --- a/cmake/CreateCPackBundle.cmake +++ b/cmake/CreateCPackBundle.cmake @@ -1,6 +1,7 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "BUNDLE") +list(APPEND CPACK_GENERATOR "BUNDLE") +set(CPACK_BINARY_BUNDLE ON) set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/macos") diff --git a/cmake/CreateCPackDMG.cmake b/cmake/CreateCPackDMG.cmake index 23271d82b2a..62078153351 100644 --- a/cmake/CreateCPackDMG.cmake +++ b/cmake/CreateCPackDMG.cmake @@ -1,6 +1,7 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "DragNDrop") +list(APPEND CPACK_GENERATOR "DragNDrop") +set(CPACK_BINARY_DRAGNDROP ON) set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/macos") diff --git a/cmake/CreateCPackDeb.cmake b/cmake/CreateCPackDeb.cmake index d6d2b21437c..be816520101 100644 --- a/cmake/CreateCPackDeb.cmake +++ b/cmake/CreateCPackDeb.cmake @@ -1,6 +1,7 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "DEB") +list(APPEND CPACK_GENERATOR "DEB") +set(CPACK_BINARY_DEB ON) set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/linux") diff --git a/cmake/CreateCPackIFW.cmake b/cmake/CreateCPackIFW.cmake index e47ef60b450..c0ef1086b71 100644 --- a/cmake/CreateCPackIFW.cmake +++ b/cmake/CreateCPackIFW.cmake @@ -6,7 +6,8 @@ set(QTIFWDIR "${Qt6_ROOT_DIR}/../../Tools/QtInstallerFramework/*") include(CPackIFW) -set(CPACK_GENERATOR "IFW") +list(APPEND CPACK_GENERATOR "IFW") +set(CPACK_BINARY_IFW ON) # Debug set(CPACK_IFW_VERBOSE ON) diff --git a/cmake/CreateCPackNSIS.cmake b/cmake/CreateCPackNSIS.cmake index c4009f25b42..2e2844ccfaf 100644 --- a/cmake/CreateCPackNSIS.cmake +++ b/cmake/CreateCPackNSIS.cmake @@ -1,19 +1,30 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "NSIS") +list(APPEND CPACK_GENERATOR "NSIS") +set(CPACK_BINARY_NSIS ON) set(QGC_INSTALLER_SOURCE "${CMAKE_BINARY_DIR}/deploy/windows") -set(CPACK_NSIS_INSTALL_ROOT "C:\\\\Program Files") +set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") set(CPACK_NSIS_MUI_ICON "${QGC_INSTALLER_SOURCE}/WindowsQGC.ico") set(CPACK_NSIS_MUI_UNIICON "${QGC_INSTALLER_SOURCE}/WindowsQGC.ico") # set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") # set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "") # set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP "") # set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "") -# set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "") -# set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "") -# set(CPACK_NSIS_COMPRESSOR "") +set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + CreateDirectory \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\" + CreateShortCut \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME}.lnk\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" \"\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" 0 + CreateShortCut \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME} (GPU Compatibility Mode).lnk\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" \"-desktop\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" 0 + CreateShortCut \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME} (GPU Safe Mode).lnk\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" \"-swrast\" \"\$INSTDIR\\bin\\${EXENAME}.exe\" 0 +") +set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + Delete \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME}.lnk\" + Delete \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME} (GPU Compatibility Mode).lnk\" + Delete \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\\${CMAKE_PROJECT_NAME} (GPU Safe Mode).lnk\" + RMDir /r /REBOOTOK \"\$SMPROGRAMS\\${CMAKE_PROJECT_NAME}\" +") +set(CPACK_NSIS_COMPRESSOR "/SOLID /FINAL lzma") set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) set(CPACK_NSIS_MODIFY_PATH ON) set(CPACK_NSIS_DISPLAY_NAME "${CMAKE_PROJECT_NAME}") @@ -28,7 +39,7 @@ set(CPACK_NSIS_URL_INFO_ABOUT ${CPACK_PACKAGE_HOMEPAGE_URL}) # set(CPACK_NSIS_EXECUTABLES_DIRECTORY "") # set(CPACK_NSIS_MUI_FINISHPAGE_RUN "") # set(CPACK_NSIS_MENU_LINKS "") -# set(CPACK_NSIS_UNINSTALL_NAME "") +set(CPACK_NSIS_UNINSTALL_NAME "${CMAKE_PROJECT_NAME}-Uninstall") # set(CPACK_NSIS_WELCOME_TITLE "") # set(CPACK_NSIS_WELCOME_TITLE_3LINES "") # set(CPACK_NSIS_FINISH_TITLE "") diff --git a/cmake/CreateCPackProductBuild.cmake b/cmake/CreateCPackProductBuild.cmake new file mode 100644 index 00000000000..2b25244c1db --- /dev/null +++ b/cmake/CreateCPackProductBuild.cmake @@ -0,0 +1,34 @@ +include(CreateCPackCommon) + +list(APPEND CPACK_GENERATOR "PRODUCTBUILD") +set(CPACK_BINARY_PRODUCTBUILD ON) + +set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/macos") + +# set(CPACK_COMMAND_PRODUCTBUILD) +# set(CPACK_PRODUCTBUILD_IDENTIFIER) +# set(CPACK_PRODUCTBUILD_IDENTITY_NAME) +# set(CPACK_PRODUCTBUILD_KEYCHAIN_PATH) +# set(CPACK_COMMAND_PKGBUILD) +# set(CPACK_PKGBUILD_IDENTITY_NAME) +# set(CPACK_PKGBUILD_KEYCHAIN_PATH) +# set(CPACK_PREFLIGHT__SCRIPT) +# set(CPACK_POSTFLIGHT__SCRIPT) +# set(CPACK_PRODUCTBUILD_RESOURCES_DIR) +# set(CPACK_PRODUCTBUILD_DOMAINS) +# set(CPACK_PRODUCTBUILD_DOMAINS_ANYWHERE) +# set(CPACK_PRODUCTBUILD_DOMAINS_USER) +# set(CPACK_PRODUCTBUILD_DOMAINS_ROOT) + +# set(CPACK_PRODUCTBUILD_BACKGROUND) +# set(CPACK_PRODUCTBUILD_BACKGROUND_ALIGNMENT) +# set(CPACK_PRODUCTBUILD_BACKGROUND_SCALING) +# set(CPACK_PRODUCTBUILD_BACKGROUND_MIME_TYPE) +# set(CPACK_PRODUCTBUILD_BACKGROUND_UTI) +# set(CPACK_PRODUCTBUILD_BACKGROUND_DARKAQUA) +# set(CPACK_PRODUCTBUILD_BACKGROUND_DARKAQUA_ALIGNMENT) +# set(CPACK_PRODUCTBUILD_BACKGROUND_DARKAQUA_SCALING) +# set(CPACK_PRODUCTBUILD_BACKGROUND_DARKAQUA_MIME_TYPE) +# set(CPACK_PRODUCTBUILD_BACKGROUND_DARKAQUA_UTI) + +include(CPack) diff --git a/cmake/CreateCPackRPM.cmake b/cmake/CreateCPackRPM.cmake index d0a811f68da..fa865c05022 100644 --- a/cmake/CreateCPackRPM.cmake +++ b/cmake/CreateCPackRPM.cmake @@ -1,6 +1,7 @@ include(CreateCPackCommon) -set(CPACK_GENERATOR "RPM") +list(APPEND CPACK_GENERATOR "RPM") +set(CPACK_BINARY_RPM ON) set(QGC_INSTALLER_SOURCE "${CMAKE_SOURCE_DIR}/deploy/linux") diff --git a/cmake/CreateWinInstaller.cmake b/cmake/CreateWinInstaller.cmake index a2f50b243d3..ec5f09cb471 100644 --- a/cmake/CreateWinInstaller.cmake +++ b/cmake/CreateWinInstaller.cmake @@ -2,7 +2,6 @@ message(STATUS "Creating Win Installer") include(CMakePrintHelpers) -# cmake_path(CONVERT "${CMAKE_BINARY_DIR}/../deploy/windows" TO_CMAKE_PATH_LIST QGC_INSTALLER_SOURCE) file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/deploy/windows" QGC_INSTALLER_SOURCE) file(TO_NATIVE_PATH "${QGC_INSTALLER_SOURCE}/WindowsQGC.ico" QGC_INSTALLER_ICON) file(TO_NATIVE_PATH "${QGC_INSTALLER_SOURCE}/installheader.bmp" QGC_INSTALLER_HEADER_BITMAP) @@ -41,5 +40,4 @@ execute_process( ERROR_VARIABLE NSIS_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ) - cmake_print_variables(NSIS_RESULT NSIS_OUTPUT NSIS_ERROR) diff --git a/cmake/IWYU.cmake b/cmake/IWYU.cmake new file mode 100644 index 00000000000..0f7fdff6dfd --- /dev/null +++ b/cmake/IWYU.cmake @@ -0,0 +1,7 @@ +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + find_program(INCLUDE_WHAT_YOU_USE_PROGRAM include-what-you-use) + if(INCLUDE_WHAT_YOU_USE_PROGRAM) + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE_PROGRAM}) + set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE_PROGRAM}) + endif() +endif() diff --git a/cmake/find-modules/Findqmdnsengine.cmake b/cmake/find-modules/Findqmdnsengine.cmake new file mode 100644 index 00000000000..dac675336a2 --- /dev/null +++ b/cmake/find-modules/Findqmdnsengine.cmake @@ -0,0 +1,28 @@ +# QMDNSENGINE_FOUND +# QMDNS_INCLUDE_DIR +# QMDNS_LIBRARIES + +find_path(QMDNS_INCLUDE_DIR + NAMES qmdnsengine/mdns.h + PATH_SUFFIXES include +) + +find_library(QMDNS_LIBRARIES + NAMES libqmdnsengine.a + PATHS /usr/local /usr + PATH_SUFFIXES lib64 lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(qmdnsengine + FOUND_VAR QMDNSENGINE_FOUND + REQUIRED_VARS QMDNS_INCLUDE_DIR QMDNS_LIBRARIES +) + +if(QMDNSENGINE_FOUND) + add_library(qmdnsengine STATIC IMPORTED GLOBAL) + set_target_properties(qmdnsengine PROPERTIES + IMPORTED_LOCATION ${QMDNS_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${QMDNS_INCLUDE_DIR} + ) +endif() diff --git a/cmake/presets/Android.json b/cmake/presets/Android.json new file mode 100644 index 00000000000..0ed0f2f7ca4 --- /dev/null +++ b/cmake/presets/Android.json @@ -0,0 +1,66 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "Android", + "displayName": "Android configuration using Qt6", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt6-Android", + "toolchainFile": "$penv{QT_ROOT_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "ANDROID_ABI": "$penv{ANDROID_ABI}" + } + }, + { + "name": "Android-ccache", + "displayName": "Android configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "Android"] + } + ], + "buildPresets": [ + { + "name": "Android", + "displayName": "Android build using Qt6", + "configurePreset": "Android" + }, + { + "name": "Android-ccache", + "displayName": "Android build using Qt6 and ccache", + "configurePreset": "Android-ccache" + } + ], + "packagePresets": [ + { + "name": "Android", + "displayName": "Android package using Qt6", + "configurePreset": "Android" + }, + { + "name": "Android-ccache", + "displayName": "Android package using Qt6 and ccache", + "configurePreset": "Android-ccache" + } + ], + "workflowPresets": [ + { + "name": "Android-ccache", + "displayName": "Android workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "Android-ccache" + }, + { + "type": "build", + "name": "Android-ccache" + }, + { + "type": "package", + "name": "Android-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/Linux.json b/cmake/presets/Linux.json new file mode 100644 index 00000000000..1e6e469877f --- /dev/null +++ b/cmake/presets/Linux.json @@ -0,0 +1,124 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "Linux", + "displayName": "Linux configuration using Qt6", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt6-Linux", + "toolchainFile": "$penv{QT_ROOT_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "QT_VERSION_MAJOR": "6" + } + }, + { + "name": "Linux-ccache", + "displayName": "Linux configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "Linux"] + } + ], + "buildPresets": [ + { + "name": "Linux", + "displayName": "Linux build using Qt6", + "configurePreset": "Linux" + }, + { + "name": "Linux-ccache", + "displayName": "Linux build using Qt6 and ccache", + "configurePreset": "Linux-ccache" + } + ], + "testPresets": [ + { + "name": "Linux", + "displayName": "Linux tests using Qt6", + "configurePreset": "Linux", + "inherits": ["default"] + }, + { + "name": "Linux-ccache", + "displayName": "Linux tests using Qt6 and ccache", + "configurePreset": "Linux-ccache", + "inherits": ["default"] + } + ], + "packagePresets": [ + { + "name": "Linux", + "displayName": "Linux package using Qt6", + "configurePreset": "Linux" + }, + { + "name": "Linux-ccache", + "displayName": "Linux package using Qt6 and ccache", + "configurePreset": "Linux-ccache" + } + ], + "workflowPresets": [ + { + "name": "Linux", + "displayName": "Linux workflow using Qt6", + "steps": [ + { + "type": "configure", + "name": "Linux" + }, + { + "type": "build", + "name": "Linux" + }, + { + "type": "test", + "name": "Linux" + }, + { + "type": "package", + "name": "Linux" + } + ] + }, + { + "name": "Linux-ccache", + "displayName": "Linux workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "Linux-ccache" + }, + { + "type": "build", + "name": "Linux-ccache" + }, + { + "type": "test", + "name": "Linux-ccache" + }, + { + "type": "package", + "name": "Linux-ccache" + } + ] + }, + { + "name": "Linux-CI", + "displayName": "Linux workflow using Qt6 and ccache for CI", + "steps": [ + { + "type": "configure", + "name": "Linux-ccache" + }, + { + "type": "build", + "name": "Linux-ccache" + }, + { + "type": "package", + "name": "Linux-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/Windows.json b/cmake/presets/Windows.json new file mode 100644 index 00000000000..15c9780d700 --- /dev/null +++ b/cmake/presets/Windows.json @@ -0,0 +1,131 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "Windows", + "displayName": "Windows configuration using Qt6", + "generator": "Ninja Multi-Config", + "binaryDir": "${sourceParentDir}/build/qt6-Windows", + "toolchainFile": "$penv{QT_ROOT_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Release;Debug" + } + }, + { + "name": "Windows-ccache", + "displayName": "Windows configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "Windows"] + } + ], + "buildPresets": [ + { + "name": "Windows", + "displayName": "Windows release build using Qt6", + "configurePreset": "Windows", + "configuration": "Release" + }, + { + "name": "Windows-debug", + "displayName": "Windows debug build using Qt6", + "configurePreset": "Windows", + "configuration": "Debug" + }, + { + "name": "Windows-ccache", + "displayName": "Windows release build using Qt6 and ccache", + "configurePreset": "Windows-ccache", + "configuration": "Release" + }, + { + "name": "Windows-debug-ccache", + "displayName": "Windows debug build using Qt6 and ccache", + "configurePreset": "Windows-ccache", + "configuration": "Debug" + } + ], + "testPresets": [ + { + "name": "Windows", + "displayName": "Windows tests using Qt6", + "configurePreset": "Windows", + "configuration": "Release", + "inherits": ["default"] + }, + { + "name": "Windows-ccache", + "displayName": "Windows tests using Qt6 and ccache", + "configurePreset": "Windows-ccache", + "configuration": "Release", + "inherits": ["default"] + } + ], + "packagePresets": [ + { + "name": "Windows", + "displayName": "Windows package using Qt6", + "configurePreset": "Windows", + "configurations": ["Release", "Debug"] + }, + { + "name": "Windows-ccache", + "displayName": "Windows package using Qt6 and ccache", + "configurePreset": "Windows-ccache", + "configurations": ["Release", "Debug"] + } + ], + "workflowPresets": [ + { + "name": "Windows", + "displayName": "Windows workflow using Qt6", + "steps": [ + { + "type": "configure", + "name": "Windows" + }, + { + "type": "build", + "name": "Windows" + }, + { + "type": "build", + "name": "Windows-debug" + }, + { + "type": "test", + "name": "Windows" + }, + { + "type": "package", + "name": "Windows" + } + ] + }, + { + "name": "Windows-ccache", + "displayName": "Windows workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "Windows-ccache" + }, + { + "type": "build", + "name": "Windows-ccache" + }, + { + "type": "build", + "name": "Windows-debug-ccache" + }, + { + "type": "test", + "name": "Windows-ccache" + }, + { + "type": "package", + "name": "Windows-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/common.json b/cmake/presets/common.json new file mode 100644 index 00000000000..ead509e3401 --- /dev/null +++ b/cmake/presets/common.json @@ -0,0 +1,35 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "dev", + "hidden": true, + "warnings": { + "dev": true, + "deprecated": true, + "uninitialized": false, + "unusedCli": true, + "systemVars": true + }, + "errors": { + "dev": true, + "deprecated": true + } + }, + { + "name": "ccache", + "hidden": true, + "cacheVariables": { + "CMAKE_C_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache" + } + } + ], + "testPresets": [ + { + "name": "default", + "hidden": true, + "output": { "outputOnFailure": true } + } + ] +} diff --git a/cmake/presets/iOS.json b/cmake/presets/iOS.json new file mode 100644 index 00000000000..079a5804202 --- /dev/null +++ b/cmake/presets/iOS.json @@ -0,0 +1,109 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "iOS", + "displayName": "iOS configuration using Qt6", + "generator": "Ninja Multi-Config", + "binaryDir": "${sourceParentDir}/build/qt6-iOS", + "toolchainFile": "$penv{QT_ROOT_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Release;Debug", + "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", + "CMAKE_OSX_DEPLOYMENT_TARGET": "14.0" + } + }, + { + "name": "iOS-ccache", + "displayName": "iOS configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "iOS"] + } + ], + "buildPresets": [ + { + "name": "iOS", + "displayName": "iOS release build using Qt6", + "configurePreset": "iOS", + "configuration": "Release" + }, + { + "name": "iOS-debug", + "displayName": "iOS debug build using Qt6", + "configurePreset": "iOS", + "configuration": "Debug" + }, + { + "name": "iOS-ccache", + "displayName": "iOS release build using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configuration": "Release" + }, + { + "name": "iOS-debug-ccache", + "displayName": "iOS debug build using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configuration": "Debug" + } + ], + "packagePresets": [ + { + "name": "iOS", + "displayName": "iOS package using Qt6", + "configurePreset": "iOS", + "configurations": ["Release", "Debug"] + }, + { + "name": "iOS-ccache", + "displayName": "iOS package using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configurations": ["Release", "Debug"] + } + ], + "workflowPresets": [ + { + "name": "iOS", + "displayName": "iOS workflow using Qt6", + "steps": [ + { + "type": "configure", + "name": "iOS" + }, + { + "type": "build", + "name": "iOS-debug" + }, + { + "type": "build", + "name": "iOS" + }, + { + "type": "package", + "name": "iOS" + } + ] + }, + { + "name": "iOS-ccache", + "displayName": "iOS workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "iOS-ccache" + }, + { + "type": "build", + "name": "iOS-debug-ccache" + }, + { + "type": "build", + "name": "iOS-ccache" + }, + { + "type": "package", + "name": "iOS-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/macOS.json b/cmake/presets/macOS.json new file mode 100644 index 00000000000..bc4c84e4121 --- /dev/null +++ b/cmake/presets/macOS.json @@ -0,0 +1,154 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "macOS", + "displayName": "macOS configuration using Qt6", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt6-macOS", + "toolchainFile": "$penv{QT_ROOT_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64", + "CMAKE_OSX_DEPLOYMENT_TARGET": "11.0" + } + }, + { + "name": "macOS-ccache", + "displayName": "macOS configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "macOS"] + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS configuration using Qt6, ccache and clang-tidy", + "inherits": ["macOS-ccache"], + "cacheVariables": { + "CMAKE_OSX_ARCHITECTURES": "arm64", + "MLN_QT_WITH_CLANG_TIDY": "ON" + } + } + ], + "buildPresets": [ + { + "name": "macOS", + "displayName": "macOS build using Qt6", + "configurePreset": "macOS" + }, + { + "name": "macOS-ccache", + "displayName": "macOS build using Qt6 and ccache", + "configurePreset": "macOS-ccache" + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS build using Qt6, ccache and clang-tidy", + "configurePreset": "macOS-clang-tidy" + } + ], + "testPresets": [ + { + "name": "macOS", + "displayName": "macOS tests using Qt6", + "configurePreset": "macOS", + "inherits": ["default"] + }, + { + "name": "macOS-ccache", + "displayName": "macOS tests using Qt6 and ccache", + "configurePreset": "macOS-ccache", + "inherits": ["default"] + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS tests using Qt6, ccache and clang-tidy", + "configurePreset": "macOS-clang-tidy", + "inherits": ["default"] + } + ], + "packagePresets": [ + { + "name": "macOS", + "displayName": "macOS package using Qt6", + "configurePreset": "macOS" + }, + { + "name": "macOS-ccache", + "displayName": "macOS package using Qt6 and ccache", + "configurePreset": "macOS-ccache" + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS package using Qt6, ccache and clang-tidy", + "configurePreset": "macOS-clang-tidy" + } + ], + "workflowPresets": [ + { + "name": "macOS", + "displayName": "macOS workflow using Qt6", + "steps": [ + { + "type": "configure", + "name": "macOS" + }, + { + "type": "build", + "name": "macOS" + }, + { + "type": "test", + "name": "macOS" + }, + { + "type": "package", + "name": "macOS" + } + ] + }, + { + "name": "macOS-ccache", + "displayName": "macOS workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "macOS-ccache" + }, + { + "type": "build", + "name": "macOS-ccache" + }, + { + "type": "test", + "name": "macOS-ccache" + }, + { + "type": "package", + "name": "macOS-ccache" + } + ] + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS workflow using Qt6, ccache and clang-tidy", + "steps": [ + { + "type": "configure", + "name": "macOS-clang-tidy" + }, + { + "type": "build", + "name": "macOS-clang-tidy" + }, + { + "type": "test", + "name": "macOS-clang-tidy" + }, + { + "type": "package", + "name": "macOS-clang-tidy" + } + ] + } + ] +} diff --git a/cmake/printSummary.cmake b/cmake/printSummary.cmake index 278ea46b766..3dda683517a 100644 --- a/cmake/printSummary.cmake +++ b/cmake/printSummary.cmake @@ -8,32 +8,46 @@ macro( OptionOutput _outputstring ) message( STATUS "${_outputstring}${_var}" ) endmacro( OptionOutput _outputstring ) -function(printList items) - foreach (item ${items}) - message("\t ${item}") - endforeach() -endfunction() - -get_property(COMPILER_OPTIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_OPTIONS) - include(CMakePrintHelpers) -# include(CMakePrintSystemInformation) -# include(ProcessorCount) +# cmake_print_properties +# cmake_host_system_information -message( STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}" ) message( STATUS "------------------------------------------------------------------" ) -message( STATUS "CMake Generator: ${CMAKE_GENERATOR}" ) +message( STATUS "" ) +include(CMakePrintSystemInformation) +message( STATUS "" ) +message( STATUS "------------------------------------------------------------------" ) +message( STATUS "" ) +message( STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}" ) +message( STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}" ) +message( STATUS "CMAKE_GENERATOR_INSTANCE: ${CMAKE_GENERATOR_INSTANCE}" ) +message( STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}" ) +message( STATUS "CMAKE_GENERATOR_TOOLSET: ${CMAKE_GENERATOR_TOOLSET}" ) message( STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" ) -message( STATUS "Compiler info: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) ; version: ${CMAKE_CXX_COMPILER_VERSION}" ) +message( STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) ; version: ${CMAKE_CXX_COMPILER_VERSION}" ) message( STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}" ) +message( STATUS "CMAKE_CXX_COMPILER_LAUNCHER: ${CMAKE_CXX_COMPILER_LAUNCHER}" ) +message( STATUS "CMAKE_C_COMPILER_LAUNCHER: ${CMAKE_C_COMPILER_LAUNCHER}" ) +if(APPLE) +message( STATUS "CMAKE_OBJC_COMPILER_LAUNCHER:${CMAKE_OBJC_COMPILER_LAUNCHER}" ) +endif() +message( STATUS "CMAKE_VERSION: ${CMAKE_VERSION}" ) +message( STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}" ) +message( STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}" ) +message( STATUS "CMAKE_HOST_SYSTEM_VERSION: ${CMAKE_HOST_SYSTEM_VERSION}" ) +message( STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}" ) +message( STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}" ) +message( STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}" ) +message( STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}" ) +message( STATUS "" ) message( STATUS " --- Compiler flags --- ") message( STATUS "General: ${CMAKE_CXX_FLAGS}" ) -printList("${COMPILER_OPTIONS}") message( STATUS "Extra: ${EXTRA_COMPILE_FLAGS}" ) message( STATUS "Debug: ${CMAKE_CXX_FLAGS_DEBUG}" ) message( STATUS "Release: ${CMAKE_CXX_FLAGS_RELEASE}" ) message( STATUS "RelWithDebInfo: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" ) message( STATUS "MinSizeRel: ${CMAKE_CXX_FLAGS_MINSIZEREL}" ) +message( STATUS "" ) message( STATUS " --- Linker flags --- ") message( STATUS "General: ${CMAKE_EXE_LINKER_FLAGS}" ) message( STATUS "Debug: ${CMAKE_EXE_LINKER_FLAGS_DEBUG}" ) @@ -41,56 +55,42 @@ message( STATUS "Release: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}" message( STATUS "RelWithDebInfo: ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}" ) message( STATUS "MinSizeRel: ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}" ) message( STATUS "" ) - -message( STATUS "CMake Version: ${CMAKE_VERSION}" ) -message( STATUS "CMake Prefix: ${CMAKE_PREFIX_PATH}" ) -message( STATUS "CMake Host System Name: ${CMAKE_HOST_SYSTEM_NAME}" ) -message( STATUS "CMake Host System Version: ${CMAKE_HOST_SYSTEM_VERSION}" ) -message( STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}" ) -message( STATUS "CMake System Version: ${CMAKE_SYSTEM_VERSION}" ) -message( STATUS "CMake Source Dir: ${CMAKE_SOURCE_DIR}" ) -message( STATUS "CMake Toolchain File: ${CMAKE_TOOLCHAIN_FILE}" ) - +message( STATUS "------------------------------------------------------------------" ) +message( STATUS "" ) message( STATUS "App Name: ${QGC_APP_NAME}" ) message( STATUS "App Copyright: ${QGC_APP_COPYRIGHT}" ) message( STATUS "App Description: ${QGC_APP_DESCRIPTION}" ) message( STATUS "Org Name: ${QGC_ORG_NAME}" ) message( STATUS "App Domain: ${QGC_ORG_DOMAIN}" ) message( STATUS "App Version: ${QGC_APP_VERSION_STR}" ) - if(MACOS) message( STATUS "MacOS Bundle ID: ${QGC_BUNDLE_ID}" ) message( STATUS "MacOS Icon Path: ${QGC_MACOS_ICON_PATH}" ) endif() - if(ANDROID) message( STATUS "Android NDK Host System ${ANDROID_NDK_HOST_SYSTEM_NAME}" ) message( STATUS "Android SDK Root ${ANDROID_SDK_ROOT}" ) endif() - OptionOutput( "Stable Build: " QGC_STABLE_BUILD ) OptionOutput( "Building Tests: " QGC_BUILD_TESTING AND BUILD_TESTING ) OptionOutput( "Debug QML: " QGC_DEBUG_QML ) OptionOutput( "Build Dependencies: " QGC_BUILD_DEPENDENCIES ) - OptionOutput( "Disable APM Dialect: " QGC_DISABLE_APM_MAVLINK ) OptionOutput( "Disable APM Plugin: " QGC_DISABLE_APM_PLUGIN ) OptionOutput( "Disable APM Plugin Factory: " QGC_DISABLE_APM_PLUGIN_FACTORY ) - OptionOutput( "Disable PX4 Plugin: " QGC_DISABLE_PX4_PLUGIN ) OptionOutput( "Disable PX4 Plugin Factory: " QGC_DISABLE_PX4_PLUGIN_FACTORY ) - OptionOutput( "Enable Bluetooth Links: " QGC_ENABLE_BLUETOOTH ) OptionOutput( "Enable ZeroConf: " QGC_ZEROCONF_ENABLED ) OptionOutput( "Disable AIRLink: " QGC_AIRLINK_DISABLED ) OptionOutput( "Disable Serial Links: " QGC_NO_SERIAL_LINK ) - OptionOutput( "Enable UTM Adapter: " QGC_UTM_ADAPTER ) OptionOutput( "Enable Viewer3D: " QGC_VIEWER3D ) - OptionOutput( "Enable UVC Devices: " QGC_ENABLE_UVC ) OptionOutput( "Enable GStreamer: " QGC_ENABLE_GST_VIDEOSTREAMING ) OptionOutput( "Enable QtMultimedia: " QGC_ENABLE_QT_VIDEOSTREAMING ) - message( STATUS "MAVLink Git Repo: ${QGC_MAVLINK_GIT_REPO}" ) message( STATUS "MAVLink Git Tag: ${QGC_MAVLINK_GIT_TAG}" ) +message( STATUS "" ) +message( STATUS "------------------------------------------------------------------" ) +message( STATUS "" ) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..d25776f5338 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,7 @@ +coverage: + round: down + precision: 1 + status: + project: + default: + threshold: 1% diff --git a/src/AnalyzeView/CMakeLists.txt b/src/AnalyzeView/CMakeLists.txt index 54a2d34152a..a4a8f7541d4 100644 --- a/src/AnalyzeView/CMakeLists.txt +++ b/src/AnalyzeView/CMakeLists.txt @@ -48,11 +48,6 @@ target_link_libraries(AnalyzeView target_include_directories(AnalyzeView PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_precompile_headers(AnalyzeView - PRIVATE - -) - # qt_add_qml_module(AnalyzeView # URI QGroundControl.AnalyzeView # VERSION 1.0 @@ -99,7 +94,7 @@ message(STATUS "Building ULogParser") include(CPM) CPMAddPackage( NAME ulog_cpp - GIT_REPOSITORY https://github.com/PX4/ulog_cpp.git + GITHUB_REPOSITORY PX4/ulog_cpp GIT_TAG main GIT_SHALLOW TRUE ) @@ -125,16 +120,15 @@ set(TARGET_EXPAT_VERSION 2.6.4) # elseif(MACOS) # set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${TARGET_EXIV2_VERSION}/exiv2-${TARGET_EXIV2_VERSION}-Darwin.tar.gz") # endif() - +# # if(EXIV2_URL) -# FetchContent_Declare(exiv2 -# DOWNLOAD_EXTRACT_TIMESTAMP true -# URL ${EXIV2_URL} +# include(CPM) +# CPMAddPackage( +# NAME exiv2 +# URL ${EXIV2_URL} # ) -# FetchContent_MakeAvailable(exiv2) - -# # exiv2_SOURCE_DIR -# # target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib) +# exiv2_SOURCE_DIR +# target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib) # return() # endif() # endif() @@ -150,58 +144,66 @@ endif() if(NOT QGC_BUILD_DEPENDENCIES) find_package(EXPAT ${MINIMUM_EXPAT_VERSION}) endif() + if(NOT TARGET EXPAT::EXPAT) message(STATUS "Building Expat") - FetchContent_Declare(expat - GIT_REPOSITORY https://github.com/libexpat/libexpat.git - GIT_TAG R_2_6_4 + + include(CPM) + CPMAddPackage( + NAME expat + VERSION ${TARGET_EXPAT_VERSION} + GITHUB_REPOSITORY libexpat/libexpat + GIT_TAG "R_2_6_4" GIT_SHALLOW TRUE SOURCE_SUBDIR expat + OPTIONS + "EXPAT_BUILD_DOCS OFF" + "EXPAT_BUILD_EXAMPLES OFF" + "EXPAT_BUILD_FUZZERS OFF" + "EXPAT_BUILD_PKGCONFIG OFF" + "EXPAT_BUILD_TESTS OFF" + "EXPAT_BUILD_TOOLS OFF" + "EXPAT_ENABLE_INSTALL OFF" + "EXPAT_SHARED_LIBS OFF" ) - set(EXPAT_BUILD_DOCS OFF CACHE INTERNAL "" FORCE) - set(EXPAT_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE) - set(EXPAT_BUILD_FUZZERS OFF CACHE INTERNAL "" FORCE) - set(EXPAT_BUILD_PKGCONFIG OFF CACHE INTERNAL "" FORCE) - set(EXPAT_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) - set(EXPAT_BUILD_TOOLS OFF CACHE INTERNAL "" FORCE) - set(EXPAT_ENABLE_INSTALL OFF CACHE INTERNAL "" FORCE) - set(EXPAT_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) - FetchContent_MakeAvailable(expat) endif() message(STATUS "Building Exiv2") -FetchContent_Declare(exiv2 - GIT_REPOSITORY https://github.com/Exiv2/exiv2.git - GIT_TAG "v${TARGET_EXIV2_VERSION}" - GIT_SHALLOW TRUE -) + if(TARGET EXPAT::EXPAT) - set(EXIV2_ENABLE_XMP ON CACHE INTERNAL "" FORCE) + set(_EXIV2_ENABLE_XMP ON) else() - set(EXIV2_ENABLE_XMP OFF CACHE INTERNAL "" FORCE) + set(_EXIV2_ENABLE_XMP OFF) endif() -set(EXIV2_ENABLE_EXTERNAL_XMP OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_PNG OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_NLS OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_LENSDATA OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_DYNAMIC_RUNTIME OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_WEBREADY OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_CURL OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_BMFF OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_BROTLI OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_VIDEO OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_INIH OFF CACHE INTERNAL "" FORCE) -set(EXIV2_ENABLE_FILESYSTEM_ACCESS ON CACHE INTERNAL "" FORCE) -set(EXIV2_BUILD_SAMPLES OFF CACHE INTERNAL "" FORCE) -set(EXIV2_BUILD_EXIV2_COMMAND OFF CACHE INTERNAL "" FORCE) -set(EXIV2_BUILD_UNIT_TESTS OFF CACHE INTERNAL "" FORCE) -set(EXIV2_BUILD_FUZZ_TESTS OFF CACHE INTERNAL "" FORCE) -set(EXIV2_BUILD_DOC OFF CACHE INTERNAL "" FORCE) -set(BUILD_WITH_CCACHE ON CACHE INTERNAL "" FORCE) -FetchContent_MakeAvailable(exiv2) + +include(CPM) +CPMAddPackage( + NAME exiv2 + VERSION ${TARGET_EXIV2_VERSION} + GITHUB_REPOSITORY Exiv2/exiv2 + OPTIONS + "EXIV2_ENABLE_XMP ${_EXIV2_ENABLE_XMP}" + "EXIV2_ENABLE_EXTERNAL_XMP OFF" + "EXIV2_ENABLE_PNG OFF" + "EXIV2_ENABLE_NLS OFF" + "EXIV2_ENABLE_LENSDATA OFF" + "EXIV2_ENABLE_DYNAMIC_RUNTIME OFF" + "EXIV2_ENABLE_WEBREADY OFF" + "EXIV2_ENABLE_CURL OFF" + "EXIV2_ENABLE_BMFF OFF" + "EXIV2_ENABLE_BROTLI OFF" + "EXIV2_ENABLE_VIDEO OFF" + "EXIV2_ENABLE_INIH OFF" + "EXIV2_ENABLE_FILESYSTEM_ACCESS OFF" + "EXIV2_BUILD_SAMPLES OFF" + "EXIV2_BUILD_EXIV2_COMMAND OFF" + "EXIV2_BUILD_UNIT_TESTS OFF" + "EXIV2_BUILD_FUZZ_TESTS OFF" + "EXIV2_BUILD_DOC OFF" + "BUILD_WITH_CCACHE ON" +) if(TARGET Exiv2::exiv2lib) target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib) target_include_directories(AnalyzeView PRIVATE ${CMAKE_BINARY_DIR}) - return() endif() diff --git a/src/Audio/CMakeLists.txt b/src/Audio/CMakeLists.txt index 58a83f24ff1..14b40e396f2 100644 --- a/src/Audio/CMakeLists.txt +++ b/src/Audio/CMakeLists.txt @@ -16,19 +16,14 @@ target_link_libraries(Audio target_include_directories(Audio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -if(LINUX) - find_package(SpeechDispatcher) - if(TARGET SpeechDispatcher::SpeechDispatcher) - target_link_libraries(Audio PRIVATE SpeechDispatcher::SpeechDispatcher) - endif() +# if(LINUX) +# find_package(SpeechDispatcher) +# if(TARGET SpeechDispatcher::SpeechDispatcher) +# target_link_libraries(Audio PRIVATE SpeechDispatcher::SpeechDispatcher) +# endif() - find_package(Flite) - if(TARGET Flite::Flite) - target_link_libraries(Audio PRIVATE Flite::Flite) - endif() -endif() - -target_precompile_headers(Audio - PRIVATE - -) +# find_package(Flite) +# if(TARGET Flite::Flite) +# target_link_libraries(Audio PRIVATE Flite::Flite) +# endif() +# endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84bb55c70bf..7e9dc16ab28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,4 @@ -find_package(Qt6 - REQUIRED - COMPONENTS - Core - Core5Compat - QuickControls2 - QuickWidgets - Widgets -) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Qml QuickControls2 Widgets) qt_add_library(QGC STATIC CmdLineOptParser.cc @@ -53,10 +45,12 @@ add_subdirectory(Viewer3D) ####################################################### target_link_libraries(QGC PRIVATE + Qt6::CorePrivate + Qt6::Gui + Qt6::Network + Qt6::Qml Qt6::Quick Qt6::QuickControls2 - Qt6::QuickWidgets - Qt6::Core5Compat API AnalyzeView Audio @@ -89,45 +83,31 @@ target_link_libraries(QGC VideoManager PUBLIC Qt6::Core - Qt6::CorePrivate Qt6::Widgets ) target_include_directories(QGC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_precompile_headers(QGC + PUBLIC + + +) + if(ANDROID) target_sources(QGC PRIVATE ${CMAKE_SOURCE_DIR}/android/src/AndroidInterface.cc ${CMAKE_SOURCE_DIR}/android/src/AndroidInterface.h - PUBLIC - ${CMAKE_SOURCE_DIR}/android/src/AndroidInit.cpp ) target_link_libraries(QGC PRIVATE Qt6::CorePrivate + Utilities PUBLIC Qt6::Core - Comms - Joystick ) target_include_directories(QGC PUBLIC ${CMAKE_SOURCE_DIR}/android/src) - target_precompile_headers(QGC - PRIVATE - - ) -else() - target_sources(QGC - PRIVATE - RunGuard.cc - RunGuard.h - ) endif() - -target_precompile_headers(QGC - PRIVATE - ${CMAKE_SOURCE_DIR}/src/pch.h - -) diff --git a/src/Comms/CMakeLists.txt b/src/Comms/CMakeLists.txt index 9085acc6ed5..15899059130 100644 --- a/src/Comms/CMakeLists.txt +++ b/src/Comms/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries(Comms target_include_directories(Comms PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -############# Serial +#===========================================================================# if(QGC_NO_SERIAL_LINK) target_compile_definitions(Comms PUBLIC NO_SERIAL_LINK) @@ -55,11 +55,13 @@ else() UdpIODevice.cc UdpIODevice.h ) + target_link_libraries(Comms PRIVATE GPS PositionManager ) + if(ANDROID) add_subdirectory(${CMAKE_SOURCE_DIR}/android/libs/qtandroidserialport qtandroidserialport.build) target_sources(qtandroidserialport @@ -72,14 +74,10 @@ else() else() find_package(Qt6 REQUIRED COMPONENTS SerialPort) target_link_libraries(Comms PUBLIC Qt6::SerialPort) - target_precompile_headers(Comms - PRIVATE - - ) endif() endif() -############# Bluetooth +#===========================================================================# if(QGC_ENABLE_BLUETOOTH) find_package(Qt6 REQUIRED COMPONENTS Bluetooth) @@ -90,28 +88,29 @@ if(QGC_ENABLE_BLUETOOTH) BluetoothLink.h ) target_compile_definitions(Comms PUBLIC QGC_ENABLE_BLUETOOTH) - target_precompile_headers(Comms - PRIVATE - - ) endif() -############# ZEROConf +#===========================================================================# if(QGC_ZEROCONF_ENABLED) message(STATUS "Building QMDNSEngine") - FetchContent_Declare(qmdnsengine - GIT_REPOSITORY https://github.com/nitroshare/qmdnsengine.git + + include(CPM) + CPMAddPackage( + NAME qmdnsengine + GITHUB_REPOSITORY nitroshare/qmdnsengine GIT_TAG master GIT_SHALLOW TRUE + OPTIONS + "BUILD_DOC OFF" + "BUILD_EXAMPLES OFF" + "BUILD_TESTS OFF" ) - set(BUILD_DOC OFF CACHE INTERNAL "") - set(BUILD_EXAMPLES OFF CACHE INTERNAL "") - set(BUILD_TESTS OFF CACHE INTERNAL "") - FetchContent_MakeAvailable(qmdnsengine) - target_link_libraries(Comms PUBLIC qmdnsengine) - target_compile_definitions(Comms PUBLIC QGC_ZEROCONF_ENABLED) + if(TARGET qmdnsengine) + target_link_libraries(Comms PUBLIC qmdnsengine) + target_compile_definitions(Comms PUBLIC QGC_ZEROCONF_ENABLED) + endif() endif() # target_compile_definitions(Comms PUBLIC QABSTRACTSOCKET_DEBUG) diff --git a/src/FirmwarePlugin/APM/CMakeLists.txt b/src/FirmwarePlugin/APM/CMakeLists.txt index a31ffda3b52..0cf357778ac 100644 --- a/src/FirmwarePlugin/APM/CMakeLists.txt +++ b/src/FirmwarePlugin/APM/CMakeLists.txt @@ -46,7 +46,7 @@ target_include_directories(APMFirmwarePlugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) include(CPM) CPMAddPackage( NAME ArduPilotParams - GIT_REPOSITORY https://github.com/ArduPilot/ParameterRepository.git + GITHUB_REPOSITORY ArduPilot/ParameterRepository GIT_TAG main GIT_SHALLOW TRUE ) diff --git a/src/GPS/CMakeLists.txt b/src/GPS/CMakeLists.txt index dbd9c8c8bc7..6ae110ea302 100644 --- a/src/GPS/CMakeLists.txt +++ b/src/GPS/CMakeLists.txt @@ -45,7 +45,7 @@ message(STATUS "Building GPS Drivers") include(CPM) CPMAddPackage( NAME px4-gpsdrivers - GIT_REPOSITORY https://github.com/PX4/PX4-GPSDrivers.git + GITHUB_REPOSITORY PX4/PX4-GPSDrivers GIT_TAG main GIT_SHALLOW TRUE SOURCE_SUBDIR src diff --git a/src/Geo/CMakeLists.txt b/src/Geo/CMakeLists.txt index a3d8ba8a0e3..f8d41140ea5 100644 --- a/src/Geo/CMakeLists.txt +++ b/src/Geo/CMakeLists.txt @@ -37,29 +37,32 @@ if(NOT QGC_BUILD_DEPENDENCIES) endif() message(STATUS "Building GeographicLib") -FetchContent_Declare(GeographicLib - GIT_REPOSITORY https://github.com/geographiclib/geographiclib.git + +include(CPM) +CPMAddPackage( + NAME geographiclib + VERSION ${TARGET_GEOGRAPHICLIB_VERSION} + GITHUB_REPOSITORY geographiclib/geographiclib GIT_TAG "r${TARGET_GEOGRAPHICLIB_VERSION}" GIT_SHALLOW TRUE + OPTIONS + "BUILD_BOTH_LIBS OFF" + "BUILD_DOCUMENTATION OFF" + "BUILD_MANPAGES OFF" + "PACKAGE_DEBUG_LIBS OFF" + "APPLE_MULTIPLE_ARCHITECTURES OFF" + "INCDIR OFF" + "BINDIR OFF" + "SBINDIR OFF" + "LIBDIR ${CMAKE_INSTALL_LIBDIR}" + "DLLDIR ${CMAKE_INSTALL_BINDIR}" + "MANDIR OFF" + "CMAKEDIR OFF" + "PKGDIR OFF" + "DOCDIR OFF" + "EXAMPLEDIR OFF" ) -set(BUILD_BOTH_LIBS OFF CACHE INTERNAL "" FORCE) -set(BUILD_DOCUMENTATION OFF CACHE INTERNAL "" FORCE) -set(BUILD_MANPAGES OFF CACHE INTERNAL "" FORCE) -set(PACKAGE_DEBUG_LIBS OFF CACHE INTERNAL "" FORCE) -set(APPLE_MULTIPLE_ARCHITECTURES OFF CACHE INTERNAL "" FORCE) -set(INCDIR "" CACHE INTERNAL "" FORCE) -set(BINDIR "" CACHE INTERNAL "" FORCE) -set(SBINDIR "" CACHE INTERNAL "" FORCE) -set(LIBDIR "${CMAKE_INSTALL_LIBDIR}" CACHE STRING "" FORCE) -set(DLLDIR "${CMAKE_INSTALL_BINDIR}" CACHE INTERNAL "" FORCE) -set(MANDIR "" CACHE INTERNAL "" FORCE) -set(CMAKEDIR "" CACHE INTERNAL "" FORCE) -set(PKGDIR "" CACHE INTERNAL "" FORCE) -set(DOCDIR "" CACHE INTERNAL "" FORCE) -set(EXAMPLEDIR "" CACHE INTERNAL "" FORCE) -FetchContent_MakeAvailable(GeographicLib) if(TARGET GeographicLib::GeographicLib) target_link_libraries(Geo PRIVATE GeographicLib::GeographicLib) - return() endif() diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index d95b3b365de..781ff25ec7f 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -53,7 +53,7 @@ target_compile_definitions(Joystick PRIVATE QGC_SDL_JOYSTICK SDL_MAIN_HANDLED) include(CPM) CPMAddPackage( NAME sdl_gamecontrollerdb - GIT_REPOSITORY https://github.com/mdqinc/SDL_GameControllerDB.git + GITHUB_REPOSITORY mdqinc/SDL_GameControllerDB GIT_TAG master GIT_SHALLOW TRUE ) @@ -78,51 +78,56 @@ if(NOT QGC_BUILD_DEPENDENCIES) endif() endif() -message(STATUS "Building SDL") -FetchContent_Declare(SDL - GIT_REPOSITORY https://github.com/libsdl-org/SDL.git - GIT_TAG "release-${TARGET_SDL2_VERSION}" - GIT_SHALLOW TRUE -) -set(SDL2_DISABLE_INSTALL ON CACHE INTERNAL "" FORCE) -set(SDL2_DISABLE_UNINSTALL ON CACHE INTERNAL "" FORCE) -set(SDL2_DISABLE_SDL2MAIN ON CACHE INTERNAL "" FORCE) -set(SDL_SHARED OFF CACHE INTERNAL "" FORCE) -set(SDL_STATIC ON CACHE INTERNAL "" FORCE) -set(SDL_TEST OFF CACHE INTERNAL "" FORCE) - -set(SDL_ATOMIC ON CACHE INTERNAL "" FORCE) -set(SDL_AUDIO OFF CACHE INTERNAL "" FORCE) -set(SDL_CPUINFO ON CACHE INTERNAL "" FORCE) -set(SDL_EVENTS ON CACHE INTERNAL "" FORCE) -set(SDL_FILE OFF CACHE INTERNAL "" FORCE) -set(SDL_FILESYSTEM OFF CACHE INTERNAL "" FORCE) -set(SDL_HAPTIC ON CACHE INTERNAL "" FORCE) -set(SDL_HIDAPI ON CACHE INTERNAL "" FORCE) -set(SDL_JOYSTICK ON CACHE INTERNAL "" FORCE) -set(SDL_LOADSO ON CACHE INTERNAL "" FORCE) -set(SDL_LOCALE OFF CACHE INTERNAL "" FORCE) -set(SDL_MISC OFF CACHE INTERNAL "" FORCE) -set(SDL_POWER ON CACHE INTERNAL "" FORCE) -set(SDL_RENDER OFF CACHE INTERNAL "" FORCE) -set(SDL_SENSOR OFF CACHE INTERNAL "" FORCE) -set(SDL_THREADS ON CACHE INTERNAL "" FORCE) -set(SDL_TIMERS OFF CACHE INTERNAL "" FORCE) -set(SDL_VIDEO OFF CACHE INTERNAL "" FORCE) - -set(SDL_3DNOW OFF CACHE INTERNAL "" FORCE) -set(SDL_DBUS OFF CACHE INTERNAL "" FORCE) -set(SDL_IBUS OFF CACHE INTERNAL "" FORCE) -set(SDL_MMX OFF CACHE INTERNAL "" FORCE) -set(SDL_VIRTUAL_JOYSTICK ON CACHE INTERNAL "" FORCE) +message(STATUS "Building SDL2") if(WIN32) - set(SDL_DIRECTX OFF CACHE INTERNAL "" FORCE) - set(SDL_XINPUT ON CACHE INTERNAL "" FORCE) + set(SDL2_EXTRA_OPTIONS + "SDL_DIRECTX OFF" + "SDL_XINPUT ON" + ) endif() -FetchContent_MakeAvailable(SDL) + +include(CPM) +CPMAddPackage( + NAME sdl2 + VERSION ${TARGET_SDL2_VERSION} + GITHUB_REPOSITORY libsdl-org/SDL + GIT_TAG "release-${TARGET_SDL2_VERSION}" + GIT_SHALLOW TRUE + OPTIONS + "SDL2_DISABLE_INSTALL ON" + "SDL2_DISABLE_INSTALL ON" + "SDL2_DISABLE_UNINSTALL ON" + "SDL2_DISABLE_SDL2MAIN ON" + "SDL_SHARED OFF" + "SDL_STATIC ON" + "SDL_TEST OFF" + "SDL_ATOMIC ON" + "SDL_AUDIO OFF" + "SDL_CPUINFO ON" + "SDL_EVENTS ON" + "SDL_FILE OFF" + "SDL_FILESYSTEM OFF" + "SDL_HAPTIC ON" + "SDL_HIDAPI ON" + "SDL_JOYSTICK ON" + "SDL_LOADSO ON" + "SDL_LOCALE OFF" + "SDL_MISC OFF" + "SDL_POWER ON" + "SDL_RENDER OFF" + "SDL_SENSOR OFF" + "SDL_THREADS ON" + "SDL_TIMERS OFF" + "SDL_VIDEO OFF" + "SDL_3DNOW OFF" + "SDL_DBUS OFF" + "SDL_IBUS OFF" + "SDL_MMX OFF" + "SDL_VIRTUAL_JOYSTICK ON" + "${SDL2_EXTRA_OPTIONS}" +) if(TARGET SDL2::SDL2-static) target_link_libraries(Joystick PRIVATE SDL2::SDL2-static) - return() endif() diff --git a/src/MAVLink/CMakeLists.txt b/src/MAVLink/CMakeLists.txt index d7e1507b447..9d0899fcb26 100644 --- a/src/MAVLink/CMakeLists.txt +++ b/src/MAVLink/CMakeLists.txt @@ -31,19 +31,21 @@ target_link_libraries(MAVLink target_include_directories(MAVLink PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -############# MAVLink +#===========================================================================# message(STATUS "Building MAVLink") # TODO: -# FetchContent_Declare(mavlink -# GIT_REPOSITORY https://github.com/mavlink/mavlink.git +# include(CPM) +# CPMAddPackage( +# NAME mavlink +# GITHUB_REPOSITORY mavlink/mavlink # GIT_TAG master # GIT_SHALLOW TRUE +# OPTIONS +# "MAVLINK_DIALECT all" +# "MAVLINK_VERSION 2.0" # ) -# set(MAVLINK_DIALECT all) -# set(MAVLINK_VERSION 2.0) -# FetchContent_MakeAvailable(mavlink) include(CPM) CPMAddPackage( diff --git a/src/MAVLink/LibEvents/CMakeLists.txt b/src/MAVLink/LibEvents/CMakeLists.txt index 63802c135fd..c68ce3c3ba5 100644 --- a/src/MAVLink/LibEvents/CMakeLists.txt +++ b/src/MAVLink/LibEvents/CMakeLists.txt @@ -30,7 +30,7 @@ message(STATUS "Building libevents") include(CPM) CPMAddPackage( NAME libevents - GIT_REPOSITORY https://github.com/mavlink/libevents.git + GITHUB_REPOSITORY mavlink/libevents GIT_TAG main GIT_SHALLOW TRUE SOURCE_SUBDIR libs/cpp diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 7787912caa2..b97753cfbf0 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -18,7 +18,10 @@ #include "QGCApplication.h" +#include #include +#include +#include #include #include #include @@ -29,6 +32,8 @@ #include #include +#include + #include "AppMessages.h" #include "AudioOutput.h" #include "AutoPilotPlugin.h" @@ -218,7 +223,7 @@ void QGCApplication::setLanguage() _locale = QLocale(possibleLocale); } //-- We have specific fonts for Korean - if(_locale == QLocale::Korean) { + if (_locale == QLocale::Korean) { qCDebug(LocalizationLog) << "Loading Korean fonts" << _locale.name(); if(QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Regular") < 0) { qCWarning(LocalizationLog) << "Could not load /fonts/NanumGothic-Regular font"; @@ -233,17 +238,17 @@ void QGCApplication::setLanguage() removeTranslator(&_qgcTranslatorQtLibs); if (_locale.name() != "en_US") { QLocale::setDefault(_locale); - if(_qgcTranslatorQtLibs.load("qt_" + _locale.name(), QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { + if (_qgcTranslatorQtLibs.load("qt_" + _locale.name(), QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { installTranslator(&_qgcTranslatorQtLibs); } else { qCWarning(LocalizationLog) << "Qt lib localization for" << _locale.name() << "is not present"; } - if(_qgcTranslatorSourceCode.load(_locale, QLatin1String("qgc_source_"), "", ":/i18n")) { + if (_qgcTranslatorSourceCode.load(_locale, QLatin1String("qgc_source_"), "", ":/i18n")) { installTranslator(&_qgcTranslatorSourceCode); } else { qCWarning(LocalizationLog) << "Error loading source localization for" << _locale.name(); } - if(JsonHelper::translator()->load(_locale, QLatin1String("qgc_json_"), "", ":/i18n")) { + if (JsonHelper::translator()->load(_locale, QLatin1String("qgc_json_"), "", ":/i18n")) { installTranslator(JsonHelper::translator()); } else { qCWarning(LocalizationLog) << "Error loading json localization for" << _locale.name(); diff --git a/src/QGCApplication.h b/src/QGCApplication.h index aa5488d26e1..4c0742e327e 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -9,52 +9,38 @@ #pragma once -#include -#include #include #include #include -#include -#include -#include +#include #include -// These private headers are require to implement the signal compress support below -#include -#include +#include -// Work around circular header includes class QQmlApplicationEngine; class QQuickWindow; class QGCImageProvider; class QGCApplication; +class QEvent; +class QPostEventList; +class QMetaMethod; +class QMetaObject; #if defined(qApp) #undef qApp #endif -#define qApp (static_cast(QApplication::instance())) +#define qApp (static_cast(QApplication::instance())) #if defined(qGuiApp) #undef qGuiApp #endif -#define qGuiApp (static_cast(QGuiApplication::instance())) +#define qGuiApp (static_cast(QGuiApplication::instance())) #define qgcApp() qApp -/** - * @brief The main application and management class. - * - * This class is started by the main method and provides - * the central management unit of the groundstation application. - * - * Needs QApplication base to support QtCharts module. This way - * we avoid application crashing on 5.12 when using the module. - * - * Note: `lastWindowClosed` will be sent by MessageBox popups and other - * dialogs, that are spawned in QML, when they are closed -**/ - -// TODO: Use QtGraphs to convert to QGuiApplication +/// The main application and management class. +/// Needs QApplication base to support QtCharts module. +/// TODO: Use QtGraphs to convert to QGuiApplication class QGCApplication : public QApplication { Q_OBJECT @@ -65,16 +51,16 @@ class QGCApplication : public QApplication QGCApplication(int &argc, char *argv[], bool unitTesting); ~QGCApplication(); - /// @brief Sets the persistent flag to delete all settings the next time QGroundControl is started. + /// Sets the persistent flag to delete all settings the next time QGroundControl is started. void deleteAllSettingsNextBoot(); - /// @brief Clears the persistent flag to delete all settings the next time QGroundControl is started. + /// Clears the persistent flag to delete all settings the next time QGroundControl is started. void clearDeleteAllSettingsNextBoot(); - /// @brief Returns true if unit tests are being run + /// Returns true if unit tests are being run bool runningUnitTests() const { return _runningUnitTests; } - /// @brief Returns true if Qt debug output should be logged to a file + /// Returns true if Qt debug output should be logged to a file bool logOutput() const { return _logOutput; } /// Used to report a missing Parameter. Warning will be displayed to user. Method may be called @@ -102,11 +88,11 @@ class QGCApplication : public QApplication static QString cachedAirframeMetaDataFile(); public: - /// @brief Perform initialize which is common to both normal application running and unit tests. + /// Perform initialize which is common to both normal application running and unit tests. void init(); void shutdown(); - // Although public, these methods are internal and should only be called by UnitTest code + /// Although public, these methods are internal and should only be called by UnitTest code QQmlApplicationEngine *qmlAppEngine() const { return _qmlAppEngine; } signals: @@ -140,15 +126,14 @@ private slots: void _showDelayedAppMessages(); private: - /// @brief Initialize the application for normal application boot. Or in other words we are not going to run unit tests. + bool compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) final; + + /// Initialize the application for normal application boot. Or in other words we are not going to run unit tests. void _initForNormalAppBoot(); QObject *_rootQmlObject(); void _checkForNewVersion(); - // Overrides from QApplication - bool compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) final; - bool _runningUnitTests = false; ///< true: running unit tests, false: normal app static constexpr int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display @@ -171,12 +156,10 @@ private slots: QList> _delayedAppMessages; - class CompressedSignalList { - Q_DISABLE_COPY(CompressedSignalList) - + class CompressedSignalList + { public: CompressedSignalList() {} - void add(const QMetaMethod &method); void remove(const QMetaMethod &method); bool contains(const QMetaObject *metaObject, int signalIndex); @@ -185,7 +168,9 @@ private slots: /// Returns a signal index that is can be compared to QMetaCallEvent.signalId static int _signalIndex(const QMetaMethod &method); - QMap > _signalMap; + QMap> _signalMap; + + Q_DISABLE_COPY(CompressedSignalList) }; CompressedSignalList _compressedSignals; diff --git a/src/QtLocationPlugin/CMakeLists.txt b/src/QtLocationPlugin/CMakeLists.txt index 8a301ccfe24..2b0c55a6a96 100644 --- a/src/QtLocationPlugin/CMakeLists.txt +++ b/src/QtLocationPlugin/CMakeLists.txt @@ -72,12 +72,6 @@ target_include_directories(QGCLocation QMLControl ) -target_precompile_headers(QGCLocation - PRIVATE - - -) - set_source_files_properties(QMLControl/OfflineMapEditor.qml PROPERTIES QT_RESOURCE_ALIAS OfflineMapEditor.qml) # qt_add_qml_module(QGCLocation diff --git a/src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp b/src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp index 5b63ecdef2a..11e5f7997d1 100644 --- a/src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp +++ b/src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp @@ -16,7 +16,9 @@ #include "QGCMapUrlEngine.h" #include "MapProvider.h" #include "QGCMapEngineManager.h" -#include +#include "QGCLoggingCategory.h" + +#include #include #include diff --git a/src/RunGuard.h b/src/RunGuard.h index ffff3cd3dbc..edc11d161ef 100644 --- a/src/RunGuard.h +++ b/src/RunGuard.h @@ -9,15 +9,14 @@ #pragma once - -#include #include +#include #include class RunGuard { public: - RunGuard( const QString& key ); + RunGuard(const QString &key); ~RunGuard(); bool isAnotherRunning(); @@ -32,5 +31,5 @@ class RunGuard QSharedMemory sharedMem; QSystemSemaphore memLock; - Q_DISABLE_COPY( RunGuard ) + Q_DISABLE_COPY(RunGuard) }; diff --git a/src/UTMSP/CMakeLists.txt b/src/UTMSP/CMakeLists.txt index 455099dcc95..ea9dc2e0276 100644 --- a/src/UTMSP/CMakeLists.txt +++ b/src/UTMSP/CMakeLists.txt @@ -6,14 +6,13 @@ qt_add_library(UTMSP STATIC) if(QGC_UTM_ADAPTER) message(STATUS "UTMSP is Initialized") - # if(NOT TARGET nlohmann_json) - # FetchContent_Declare(json - # GIT_REPOSITORY https://github.com/nlohmann/json.git - # GIT_TAG v3.11.3 - # GIT_SHALLOW TRUE - # ) - # FetchContent_MakeAvailable(json) - # endif() + # message(STATUS "Building nlohmann_json") + # include(CPM) + # CPMAddPackage( + # NAME nlohmann_json + # VERSION 3.11.3 + # GITHUB_REPOSITORY nlohmann/json + # ) find_package(Qt6 REQUIRED COMPONENTS Network Positioning Qml) find_package(Threads REQUIRED) diff --git a/src/Utilities/CMakeLists.txt b/src/Utilities/CMakeLists.txt index 8f58c82c5a0..72ecfcfb176 100644 --- a/src/Utilities/CMakeLists.txt +++ b/src/Utilities/CMakeLists.txt @@ -74,19 +74,18 @@ if(NOT QGC_BUILD_DEPENDENCIES) endif() message(STATUS "Building Shapelib") -FetchContent_Declare(shapelib - GIT_REPOSITORY https://github.com/OSGeo/shapelib.git - GIT_TAG "v${TARGET_SHAPELIB_VERSION}" - GIT_SHALLOW TRUE + +include(CPM) +CPMAddPackage( + NAME shapelib + VERSION ${TARGET_SHAPELIB_VERSION} + GITHUB_REPOSITORY OSGeo/shapelib + OPTIONS + "BUILD_SHAPELIB_CONTRIB OFF" + "BUILD_APPS OFF" + "BUILD_TESTING OFF" ) -set(BUILD_SHAPELIB_CONTRIB OFF CACHE INTERNAL "" FORCE) -set(BUILD_APPS OFF CACHE INTERNAL "" FORCE) -set(saved_BUILD_TESTING ${BUILD_TESTING}) -set(BUILD_TESTING OFF CACHE INTERNAL "Disable Testing for Shapelib" FORCE) -FetchContent_MakeAvailable(shapelib) -set(BUILD_TESTING ${saved_BUILD_TESTING} CACHE INTERNAL "Restore BUILD_TESTING from Shapelib" FORCE) if(TARGET shp) target_link_libraries(Utilities PRIVATE shp) - return() endif() diff --git a/src/Utilities/Compression/CMakeLists.txt b/src/Utilities/Compression/CMakeLists.txt index b4f8fac09b0..0e1604fa8a2 100644 --- a/src/Utilities/Compression/CMakeLists.txt +++ b/src/Utilities/Compression/CMakeLists.txt @@ -34,17 +34,19 @@ endif() if(NOT TARGET ZLIB::ZLIB) message(STATUS "Building ZLIB") - FetchContent_Declare(zlib - GIT_REPOSITORY https://github.com/madler/zlib.git - GIT_TAG "v${TARGET_ZLIB_VERSION}" - GIT_SHALLOW TRUE + + include(CPM) + CPMAddPackage( + NAME zlib + VERSION ${TARGET_ZLIB_VERSION} + GITHUB_REPOSITORY madler/zlib + OPTIONS + "ZLIB_BUILD_EXAMPLES OFF" + "SKIP_INSTALL_FILES ON" + "SKIP_INSTALL_LIBRARIES ON" + "SKIP_INSTALL_HEADERS ON" + "SKIP_INSTALL_ALL ON" ) - set(ZLIB_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE) - set(SKIP_INSTALL_FILES ON CACHE INTERNAL "" FORCE) - set(SKIP_INSTALL_LIBRARIES ON CACHE INTERNAL "" FORCE) - set(SKIP_INSTALL_HEADERS ON CACHE INTERNAL "" FORCE) - set(SKIP_INSTALL_ALL ON CACHE INTERNAL "" FORCE) - FetchContent_MakeAvailable(zlib) if(TARGET zlibstatic) target_link_libraries(Compression PRIVATE zlibstatic) @@ -54,12 +56,18 @@ endif() #===========================================================================# message(STATUS "Building XZ") -FetchContent_Declare(xz-embedded - GIT_REPOSITORY https://github.com/tukaani-project/xz-embedded.git - GIT_TAG v2024-12-30 + +include(CPM) +CPMAddPackage( + NAME xz-embedded + GITHUB_REPOSITORY tukaani-project/xz-embedded + GIT_TAG "v2024-12-30" GIT_SHALLOW TRUE + OPTIONS + "BUILD_SHAPELIB_CONTRIB OFF" + "BUILD_APPS OFF" + "BUILD_TESTING OFF" ) -FetchContent_MakeAvailable(xz-embedded) qt_add_library(xz STATIC ${xz-embedded_SOURCE_DIR}/linux/include/linux/xz.h diff --git a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt index 0ca4ed63017..1c10e713979 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt @@ -112,12 +112,12 @@ endif() ################################################################################ if(GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) - FetchContent_Declare(gstreamer_good_plugins - DOWNLOAD_EXTRACT_TIMESTAMP true + include(CPM) + CPMAddPackage( + NAME gstreamer_good_plugins # URL https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GST_PLUGINS_VERSION}/gstreamer-${GST_PLUGINS_VERSION}.zip?path=subprojects/gst-plugins-good/ext/qt6 URL https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-${GST_PLUGINS_VERSION}.tar.xz ) - FetchContent_MakeAvailable(gstreamer_good_plugins) set(QGC_GST_QT6_PLUGIN_PATH "${gstreamer_good_plugins_SOURCE_DIR}/ext/qt6") else() set(QGC_GST_QT6_PLUGIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qt6") diff --git a/src/VideoManager/VideoReceiver/QtMultimedia/CMakeLists.txt b/src/VideoManager/VideoReceiver/QtMultimedia/CMakeLists.txt index 285eeec5ac3..c9f6a9d4299 100644 --- a/src/VideoManager/VideoReceiver/QtMultimedia/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/QtMultimedia/CMakeLists.txt @@ -2,7 +2,6 @@ find_package(Qt6 REQUIRED COMPONENTS Core) qt_add_library(QtMultimediaReceiver STATIC) -cmake_print_variables(QGC_ENABLE_QT_VIDEOSTREAMING) if(NOT QGC_ENABLE_QT_VIDEOSTREAMING) return() endif() @@ -41,8 +40,3 @@ target_sources(QtMultimediaReceiver UVCReceiver.cc UVCReceiver.h ) - -target_precompile_headers(QtMultimediaReceiver - PRIVATE - -) diff --git a/src/main.cc b/src/main.cc index 3a2d3f108f1..02b714930a0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -7,16 +7,19 @@ * ****************************************************************************/ -#include #include -#include -#include #include +#include + +#ifdef Q_OS_MACOS + #include +#endif #include "QGCApplication.h" #include "AppMessages.h" #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + #include #include "RunGuard.h" #endif @@ -29,7 +32,7 @@ #include "CmdLineOptParser.h" #ifdef UNITTEST_BUILD -#include "UnitTestList.h" + #include "UnitTestList.h" #endif #ifdef Q_OS_WIN @@ -53,7 +56,6 @@ int WindowsCrtReportHook(int reportType, char* message, int* returnValue) #endif // QT_DEBUG -// To shut down QGC on Ctrl+C on Linux #ifdef Q_OS_LINUX #ifndef Q_OS_ANDROID @@ -92,7 +94,6 @@ int main(int argc, char *argv[]) RunGuard guard(runguardString); if (!guard.tryToRun()) { - // QApplication is necessary to use QMessageBox QApplication errorApp(argc, argv); QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("A second instance of %1 is already running. Please close the other instance and try again.").arg(QGC_APP_NAME) @@ -116,13 +117,11 @@ int main(int argc, char *argv[]) #endif #ifdef Q_OS_UNIX - //Force writing to the console on UNIX/BSD devices if (!qEnvironmentVariableIsSet("QT_LOGGING_TO_CONSOLE")) { qputenv("QT_LOGGING_TO_CONSOLE", "1"); } #endif - // install the message handler AppMessages::installHandler(); #ifdef Q_OS_MACOS @@ -146,16 +145,12 @@ int main(int argc, char *argv[]) break; } } - -// In Windows, the compiler doesn't see the use of the class created by Q_IMPORT_PLUGIN -#pragma warning( disable : 4930 4101 ) - #endif // We statically link our own QtLocation plugin Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryQGC) - bool runUnitTests = false; // Run unit tests + bool runUnitTests = false; #ifdef QT_DEBUG // We parse a small set of command line options here prior to QGCApplication in order to handle the ones diff --git a/src/pch.h b/src/pch.h deleted file mode 100644 index def854bb62a..00000000000 --- a/src/pch.h +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2024 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#pragma once - -#ifdef __cplusplus -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef QT_DEBUG -#include -#endif -#endif