Skip to content

Commit

Permalink
Update compile definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Mar 3, 2024
1 parent 56aa04f commit d354fca
Show file tree
Hide file tree
Showing 42 changed files with 421 additions and 281 deletions.
20 changes: 8 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ if(QGC_STABLE_BUILD)
message(STATUS "Stable Build")
else()
message(STATUS "Daily Build")
add_definitions(-DDAILY_BUILD)
add_compile_definitions(DAILY_BUILD)
endif()

include(CMakeDependentOption)
cmake_dependent_option(QGC_BUILD_TESTING "Enable testing" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)

include(CompileOptions)

#######################################################
# Qt6 Configuration
#######################################################

add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060600)
add_compile_definitions(QT_DEBUG_FIND_PACKAGE=ON)

include(Qt6QGCConfiguration)
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Qt version: ${QT_VERSION}")
Expand Down Expand Up @@ -114,8 +113,7 @@ option(QGC_DEBUG_QML "Build QGroundControl with QML debugging/profiling support.
add_feature_info(DEBUG_QML DEBUG_QML "Build QGroundControl with QML debugging/profiling support.")
if(QGC_DEBUG_QML)
message(STATUS "To enable the QML debugger/profiler, run with: '-qmljsdebugger=port:1234'")
add_definitions(-DQMLJSDEBUGGER)
add_definitions(-DQT_QML_DEBUG)
add_compile_definitions(QMLJSDEBUGGER QT_QML_DEBUG)
endif()

#######################################################
Expand All @@ -126,10 +124,10 @@ set(COMPANY "Mavlink")
set(COPYRIGHT "Copyright (c) 2018 QGroundControl. All rights reserved.")
set(IDENTIFIER "io.mavlink.qgroundcontrol")

add_definitions(
-DQGC_APPLICATION_NAME="QGroundControl"
-DQGC_ORG_NAME="QGroundControl.org"
-DQGC_ORG_DOMAIN="org.qgroundcontrol"
add_compile_definitions(
QGC_APPLICATION_NAME="QGroundControl"
QGC_ORG_NAME="QGroundControl.org"
QGC_ORG_DOMAIN="org.qgroundcontrol"
)

#######################################################
Expand All @@ -140,8 +138,6 @@ include(Git)
message(STATUS "QGroundControl version: ${APP_VERSION_STR}")
# set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0)

include(CompileOptions)

#######################################################
# QGroundControl Resources
#######################################################
Expand Down
38 changes: 32 additions & 6 deletions cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
if(UNIX AND NOT APPLE AND NOT ANDROID)
set(LINUX TRUE)
endif()

if(APPLE AND NOT IOS)
set(MACOS TRUE)
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
include(CTest)
enable_testing()
if(QGC_BUILD_TESTING)
message("Building tests")
add_definitions(-DUNITTEST_BUILD)
add_compile_definitions(UNITTEST_BUILD) # TODO: QGC_UNITTEST_BUILD
else()
# will prevent the definition of QT_DEBUG, which enables code that uses MockLink
add_compile_definitions(QT_NO_DEBUG)
endif()
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_compile_definitions(QGC_INSTALL_RELEASE)
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# clang and AppleClang
add_compile_options(
-Wall
-Wextra
-Wno-address-of-packed-member # ignore for mavlink
)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
add_compile_options(-fdiagnostics-color=always)
Expand All @@ -28,9 +37,26 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-Wall
-Wextra
)
elseif (WIN32)
add_definitions(-D_USE_MATH_DEFINES)
elseif(WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
add_compile_options(
/wd4244 # warning C4244: '=': conversion from 'double' to 'float', possible loss of data
)
endif()

add_compile_definitions(
QT_DISABLE_DEPRECATED_BEFORE=0x060600
QT_DEBUG_FIND_PACKAGE=ON
)

if(ANDROID OR IOS)
set(MOBILE TRUE)
add_compile_definitions(__mobile__)
endif()

if(NOT EXISTS ${CMAKE_SOURCE_DIR}/libs/mavlink/include/mavlink/v2.0/ardupilotmega)
add_compile_definitions(NO_ARDUPILOT_DIALECT) # TODO: Make this QGC_NO_ARDUPILOT_DIALECT
endif()

# option(QGC_CUSTOM_BUILD "Enable Custom Build" OFF)
# option(QGC_DISABLE_MAVLINK_INSPECTOR "Disable Mavlink Inspector" OFF) # This removes QtCharts which is GPL licensed
8 changes: 0 additions & 8 deletions cmake/Qt6QGCConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ if(DEFINED ENV{QT_MKSPEC})
set(QT_MKSPEC $ENV{QT_MKSPEC})
endif()

if(UNIX AND NOT APPLE AND NOT ANDROID)
set(LINUX TRUE)
endif()

if(APPLE AND NOT IOS)
set(MACOS TRUE)
endif()

if(NOT QT_MKSPEC)
if(APPLE)
set(QT_MKSPEC clang_64)
Expand Down
66 changes: 47 additions & 19 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
add_subdirectory(libevents)

if(ANDROID)
include(${CMAKE_CURRENT_SOURCE_DIR}/OpenSSL/android_openssl/android_openssl.cmake)
add_subdirectory(qtandroidserialport)
elseif(WIN32)
add_subdirectory(sdl2)
add_subdirectory(zlib)
endif()

option(QGC_ENABLE_VIDEOSTREAMING "Enable video streaming" ON)
if(QGC_ENABLE_VIDEOSTREAMING)
message(STATUS "Enabling video streaming support")
add_subdirectory(qmlglsink)
else()
message(STATUS "Video streaming disabled")
endif()
add_subdirectory(OpenSSL)
add_subdirectory(qtandroidserialport)
add_subdirectory(sdl2)
add_subdirectory(zlib)
add_subdirectory(qmlglsink)

set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force qmdnsengine & shapelib to build as static" FORCE)
add_subdirectory(shapelib)

option(QGC_QT6_DISABLE_DNSENGINE "Disable DNS Engine" OFF)
if(QGC_QT6_DISABLE_DNSENGINE)
option(QGC_DISABLE_DNSENGINE "Disable DNS Engine" OFF)
if(QGC_DISABLE_DNSENGINE)
message(STATUS "DNS Engine disabled")
add_compile_definitions(QT6_DISABLE_DNSENGINE=ON)
add_compile_definitions(QGC_DISABLE_DNSENGINE)
else()
message(STATUS "DNS Engine enabled")
add_subdirectory(qmdnsengine)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()


qt_add_library(xz STATIC
xz-embedded/linux/include/linux/xz.h
xz-embedded/linux/include/linux/decompress/unxz.h
# xz-embedded/linux/lib/decompress_unxz.c
xz-embedded/linux/lib/xz/xz_crc32.c
xz-embedded/linux/lib/xz/xz_crc64.c
xz-embedded/linux/lib/xz/xz_dec_bcj.c
xz-embedded/linux/lib/xz/xz_dec_lzma2.c
xz-embedded/linux/lib/xz/xz_dec_stream.c
# xz-embedded/linux/lib/xz/xz_dec_syms.c
# xz-embedded/linux/lib/xz/xz_dec_test.c
xz-embedded/linux/lib/xz/xz_lzma2.h
xz-embedded/linux/lib/xz/xz_private.h
xz-embedded/linux/lib/xz/xz_stream.h
# xz-embedded/userspace/boottest.c
# xz-embedded/userspace/buftest.c
# xz-embedded/userspace/bytetest.c
xz-embedded/userspace/xz_config.h
# xz-embedded/userspace/xzminidec.c
)

target_include_directories(xz
PUBLIC
xz-embedded/linux/include
xz-embedded/linux/include/linux
xz-embedded/linux/include/linux/decompress
xz-embedded/linux/lib/xz
xz-embedded/userspace
)

target_compile_definitions(xz
PUBLIC
XZ_DEC_ANY_CHECK
XZ_USE_CRC64
)
3 changes: 3 additions & 0 deletions libs/OpenSSL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(ANDROID)
include(android_openssl/android_openssl.cmake)
endif()
81 changes: 64 additions & 17 deletions libs/libevents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
find_package(Qt6 COMPONENTS Core REQUIRED)

add_library(libevents_generated)
target_include_directories(libevents_generated INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libevents/libs/cpp/generated)

add_library(libevents_parser
definitions.cpp
libevents/libs/cpp/parse/parser.cpp
libevents/libs/cpp/protocol/receive.cpp
)
target_include_directories(libevents_parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(libevents_parser PUBLIC Qt6::Core)
target_link_libraries(libevents_parser PUBLIC comm)

add_library(libevents_health_and_arming_checks
libevents/libs/cpp/parse/health_and_arming_checks.cpp)
target_link_libraries(libevents_health_and_arming_checks PRIVATE comm)
find_package(Qt6 REQUIRED COMPONENTS Core)

qt_add_library(libevents_generated STATIC
libevents/libs/cpp/generated/events_generated.h
)

target_include_directories(libevents_generated
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
libevents/libs/cpp/generated
)


qt_add_library(libevents_parser STATIC
definitions.cpp
libevents_definitions.h
libevents/libs/cpp/parse/parser.cpp
libevents/libs/cpp/parse/parser.h
libevents/libs/cpp/protocol/receive.cpp
libevents/libs/cpp/protocol/receive.h
)

add_subdirectory(libevents/libs/cpp/parse/nlohmann_json)

target_include_directories(libevents_parser
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
libevents/libs/cpp/parse
libevents/libs/cpp/protocol
)

target_link_libraries(libevents_parser
PRIVATE
qgc
PUBLIC
Qt6::Core
comm
)


qt_add_library(libevents_health_and_arming_checks STATIC
libevents/libs/cpp/parse/health_and_arming_checks.cpp
libevents/libs/cpp/parse/health_and_arming_checks.h
)

target_include_directories(libevents_health_and_arming_checks
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
libevents/libs/cpp/parse
)

target_link_libraries(libevents_health_and_arming_checks
PUBLIC
libevents_parser
)


qt_add_library(libevents STATIC)

target_link_libraries(libevents
PUBLIC
libevents_generated
libevents_health_and_arming_checks
)
Loading

0 comments on commit d354fca

Please sign in to comment.