Skip to content

Commit

Permalink
CMake: Improve Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Jan 9, 2025
1 parent f7e78bb commit cbbdea4
Show file tree
Hide file tree
Showing 18 changed files with 219 additions and 194 deletions.
1 change: 0 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ jobs:
run: ${{ env.QT_ROOT_DIR }}/bin/qt-cmake -S ${{ github.workspace }} -B . -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.BuildType }}
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
-DQGC_BUILD_TESTING=${{ matrix.BuildType == 'Debug' && 'ON' || 'OFF' }}
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}

- name: Build
Expand Down
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22.1)
cmake_minimum_required(VERSION 3.24)

list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
Expand Down Expand Up @@ -202,7 +202,7 @@ find_package(Qt6
)

if(LINUX)
find_package(Qt6::WaylandClient ${QT_MINIMUM_VERSION})
find_package(Qt6 ${QT_MINIMUM_VERSION} COMPONENTS WaylandClient)
endif()

if(NOT Qt6LinguistTools_DIR)
Expand All @@ -223,8 +223,6 @@ qt_policy(
SET QTP0005 NEW
)

# QT_TARGETS_FOLDER

#######################################################
# QGroundControl Options
#######################################################
Expand Down
1 change: 1 addition & 0 deletions cmake/CustomOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(QGC_ORG_NAME "QGroundControl.org" CACHE STRING "Org Name")
set(QGC_ORG_DOMAIN "org.qgroundcontrol" CACHE STRING "Domain")

option(QGC_STABLE_BUILD "Stable Build" OFF)
option(QGC_DOWNLOAD_DEPENDENCIES "Download Dependencies if Possible" ON)

option(QGC_ENABLE_BLUETOOTH "Enable Bluetooth Links" ON) # Qt6Bluetooth_FOUND
option(QGC_ZEROCONF_ENABLED "Enable ZeroConf Compatibility" OFF)
Expand Down
1 change: 1 addition & 0 deletions cmake/find-modules/FindGStreamer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ elseif(IOS)
set(GSTREAMER_PREFIX_IOS "~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework")
else()
FetchContent_Declare(gstreamer
DOWNLOAD_EXTRACT_TIMESTAMP true
URL "https://gstreamer.freedesktop.org/data/pkg/ios/${QGC_GST_TARGET_VERSION}/gstreamer-1.0-devel-${QGC_GST_TARGET_VERSION}-ios-universal.pkg"
)
FetchContent_MakeAvailable(gstreamer)
Expand Down
File renamed without changes.
205 changes: 113 additions & 92 deletions src/AnalyzeView/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
find_package(Qt6 REQUIRED COMPONENTS Core Charts Gui Qml QmlIntegration)

qt_add_library(AnalyzeView STATIC
ExifParser.cc
ExifParser.h
GeoTagController.cc
GeoTagController.h
GeoTagWorker.cc
Expand All @@ -23,6 +25,8 @@ qt_add_library(AnalyzeView STATIC
MAVLinkSystem.h
PX4LogParser.cc
PX4LogParser.h
ULogParser.cc
ULogParser.h
)

target_link_libraries(AnalyzeView
Expand All @@ -49,98 +53,6 @@ target_precompile_headers(AnalyzeView
<QtCharts/QAbstractSeries>
)

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

include(FetchContent)
FetchContent_Declare(ulogparser
GIT_REPOSITORY https://github.com/PX4/ulog_cpp.git
GIT_TAG main
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(ulogparser)
if(TARGET ulog_cpp::ulog_cpp)
target_link_libraries(AnalyzeView PRIVATE ulog_cpp::ulog_cpp)
target_sources(AnalyzeView PRIVATE ULogParser.cc ULogParser.h)
endif()

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

set(MINIMUM_EXIV2_VERSION 0.28.2)

if(NOT QGC_BUILD_DEPENDENCIES)
find_package(LibExiv2 ${MINIMUM_EXIV2_VERSION})
if(LibExiv2_FOUND AND TARGET LibExiv2::LibExiv2)
target_link_libraries(AnalyzeView PRIVATE LibExiv2::LibExiv2)
else()
find_package(exiv2 ${MINIMUM_EXIV2_VERSION} CONFIG NAMES exiv2)
if(exiv2_FOUND)
target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
endif()
endif()
endif()

if(NOT exiv2_FOUND AND NOT LibExiv2_FOUND)
message(STATUS "Building Exiv2")

include(FetchContent)

# TODO: XMP Compatibility
# FetchContent_Declare(EXPAT
# GIT_REPOSITORY https://github.com/libexpat/libexpat.git
# GIT_TAG R_2_6_3
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# SOURCE_SUBDIR expat
# )
# set(EXPAT_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
# set(EXPAT_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
# set(EXPAT_BUILD_TOOLS OFF CACHE INTERNAL "" FORCE)
# FetchContent_MakeAvailable(EXPAT)

# find_package(Iconv)
# if(ICONV_FOUND)
# target_link_libraries(AnalyzeView PRIVATE Iconv::Iconv)
# endif()

FetchContent_Declare(EXIV2
GIT_REPOSITORY https://github.com/Exiv2/exiv2.git
GIT_TAG v0.28.3
GIT_SHALLOW TRUE
)
set(EXIV2_ENABLE_XMP OFF CACHE INTERNAL "" FORCE)
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)

target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
target_include_directories(AnalyzeView
PRIVATE
${CMAKE_BINARY_DIR}
${exiv2_SOURCE_DIR}/include
${exiv2_SOURCE_DIR}/include/exiv2
)
endif()

target_sources(AnalyzeView PRIVATE ExifParser.cc ExifParser.h)

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

# qt_add_qml_module(AnalyzeView
# URI QGroundControl.AnalyzeView
# VERSION 1.0
Expand Down Expand Up @@ -179,3 +91,112 @@ target_sources(AnalyzeView PRIVATE ExifParser.cc ExifParser.h)
# DEPENDENCIES
# QtCore
# )

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

message(STATUS "Building ULogParser")
FetchContent_Declare(ulogparser
GIT_REPOSITORY https://github.com/PX4/ulog_cpp.git
GIT_TAG main
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(ulogparser)
if(TARGET ulog_cpp::ulog_cpp)
target_link_libraries(AnalyzeView PRIVATE ulog_cpp::ulog_cpp)
endif()

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

set(MINIMUM_EXIV2_VERSION 0.28.0)
set(TARGET_EXIV2_VERSION 0.28.3)

set(MINIMUM_EXPAT_VERSION 2.2.6)
set(TARGET_EXPAT_VERSION 2.6.4)

# if(QGC_DOWNLOAD_DEPENDENCIES)
# set(EXIV2_URL)
# if(MSVC)
# set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${TARGET_EXIV2_VERSION}/exiv2-${TARGET_EXIV2_VERSION}-2019msvc64.zip")
# elseif(LINUX)
# set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${TARGET_EXIV2_VERSION}/exiv2-${TARGET_EXIV2_VERSION}-Linux64.tar.gz")
# 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}
# )
# FetchContent_MakeAvailable(exiv2)

# # exiv2_SOURCE_DIR
# # target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
# return()
# endif()
# endif()

if(NOT QGC_BUILD_DEPENDENCIES)
find_package(exiv2 ${MINIMUM_EXIV2_VERSION})
if(TARGET Exiv2::exiv2lib)
target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
return()
endif()
endif()

find_package(EXPAT ${MINIMUM_EXPAT_VERSION})
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
GIT_SHALLOW TRUE
SOURCE_SUBDIR expat
)
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)
else()
set(EXIV2_ENABLE_XMP OFF CACHE INTERNAL "" FORCE)
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)

if(TARGET Exiv2::exiv2lib)
target_link_libraries(AnalyzeView PRIVATE Exiv2::exiv2lib)
target_include_directories(AnalyzeView PRIVATE ${CMAKE_BINARY_DIR})
return()
endif()
12 changes: 6 additions & 6 deletions src/Comms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ endif()
############# ZEROConf

if(QGC_ZEROCONF_ENABLED)
set(BUILD_DOC OFF CACHE INTERNAL "")
set(BUILD_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_TESTS OFF CACHE INTERNAL "")

include(FetchContent)
message(STATUS "Building QMDNSEngine")
FetchContent_Declare(qmdnsengine
GIT_REPOSITORY https://github.com/nitroshare/qmdnsengine.git
GIT_TAG 4e54bc86c8ed2d4fa2e7449d4ba6a6a2742d9eb1
GIT_TAG master
GIT_SHALLOW TRUE
)
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)
Expand Down
8 changes: 8 additions & 0 deletions src/FirmwarePlugin/APM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ target_link_libraries(APMFirmwarePlugin

target_include_directories(APMFirmwarePlugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

message(STATUS "Fetching ArduPilot Parameters")
FetchContent_Declare(ArduPilotParams
GIT_REPOSITORY https://github.com/ArduPilot/ParameterRepository.git
GIT_TAG main
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(ArduPilotParams)

# file(GLOB QML_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.qml)
# # file(GLOB QML_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/res/*/*.*)
# qt_add_qml_module(APMFirmwarePlugin
Expand Down
2 changes: 1 addition & 1 deletion src/GPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(QGC_NO_SERIAL_LINK)
return()
endif()

include(FetchContent)
message(STATUS "Building GPS Drivers")
FetchContent_Declare(PX4-GPSDrivers
GIT_REPOSITORY https://github.com/PX4/PX4-GPSDrivers.git
GIT_TAG main
Expand Down
34 changes: 18 additions & 16 deletions src/Geo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,38 @@ target_link_libraries(Geo

target_include_directories(Geo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

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

set(MINIMUM_GEOGRAPHICLIB_VERSION 2.3)
set(TARGET_GEOGRAPHICLIB_VERSION 2.5)

if(NOT QGC_BUILD_DEPENDENCIES)
if(LINUX)
list(APPEND CMAKE_MODULE_PATH "/usr/share/cmake/geographiclib")
endif()
find_package(GeographicLib ${MINIMUM_GEOGRAPHICLIB_VERSION} COMPONENTS STATIC)
if(GeographicLib_FOUND)
message(STATUS "Found GeographicLib")
if(TARGET GeographicLib::GeographicLib)
target_link_libraries(Geo PRIVATE GeographicLib::GeographicLib)
return()
elseif(GeographicLib_FOUND)
target_link_libraries(Geo PRIVATE ${GeographicLib_LIBRARIES})
target_include_directories(Geo PRIVATE ${GeographicLib_INCLUDE_DIRS})
target_link_directories(Geo PRIVATE ${GeographicLib_LIBRARY_DIRS})
cmake_print_variables(GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS GeographicLib_LIBRARY_DIRS)
return()
else()
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(GeographicLib IMPORTED_TARGET GeographicLib>=${MINIMUM_GEOGRAPHICLIB_VERSION})
if(GeographicLib_FOUND)
message(STATUS "Found GeographicLib ${GeographicLib_VERSION}")
target_link_libraries(Geo PRIVATE PkgConfig::GeographicLib)
return()
endif()
endif()
endif()
endif()

message(STATUS "Building GeographicLib")
include(FetchContent)
FetchContent_Declare(GeographicLib
GIT_REPOSITORY https://github.com/geographiclib/geographiclib.git
GIT_TAG r2.5
GIT_TAG "r${TARGET_GEOGRAPHICLIB_VERSION}"
GIT_SHALLOW TRUE
)
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)
Expand All @@ -60,4 +58,8 @@ set(PKGDIR "" CACHE INTERNAL "" FORCE)
set(DOCDIR "" CACHE INTERNAL "" FORCE)
set(EXAMPLEDIR "" CACHE INTERNAL "" FORCE)
FetchContent_MakeAvailable(GeographicLib)
target_link_libraries(Geo PRIVATE GeographicLib::GeographicLib)

if(TARGET GeographicLib::GeographicLib)
target_link_libraries(Geo PRIVATE GeographicLib::GeographicLib)
return()
endif()
Loading

0 comments on commit cbbdea4

Please sign in to comment.