build(windows): harden native SITL toolchains

Add compiler-specific CMake helpers and use them across Windows-sensitive targets so MSVC and MinGW can share the native SITL build without leaking unsupported flags between compilers.

Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
Nuno Marques
2026-05-05 20:56:00 -07:00
parent 9d54657475
commit 88af828724
60 changed files with 637 additions and 179 deletions
+5 -1
View File
@@ -90,7 +90,11 @@ jobs:
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install jinja2 pyyaml toml numpy packaging jsonschema future empy pyros-genmsg
# empy pinned <4: PX4's msg/uxrce_dds/flight_tasks/zenoh generators
# use the empy 3.x Interpreter(...options={em.RAW_OPT: True,
# em.BUFFERED_OPT: True}) API removed in empy 4.x. Matches the pin
# in Tools/setup/requirements.txt and Tools/setup/windows.ps1.
python -m pip install jinja2 pyyaml toml numpy packaging jsonschema future "empy>=3.3,<4" pyros-genmsg kconfiglib
- name: Install Ninja (MSVC)
if: matrix.toolchain == 'MSVC'
+4 -4
View File
@@ -1,5 +1,5 @@
[
{
"name": "PX4 detect"
}
]
{
"name": "PX4 detect"
}
]
+6 -1
View File
@@ -318,7 +318,12 @@ endif()
set(package-contact "px4users@googlegroups.com")
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
+1 -1
View File
@@ -31,7 +31,7 @@
#
############################################################################
add_compile_options(-Wno-cast-align)
px4_add_compile_options_for_compiler(GNU_LIKE -Wno-cast-align)
include(ExternalProject)
ExternalProject_Add(librobotcontrol
+3 -1
View File
@@ -81,7 +81,9 @@ if("${PX4_PLATFORM}" STREQUAL "qurt")
add_library(mavlink_common_headers INTERFACE)
add_dependencies(mavlink_common_headers mavlink_common_generate)
target_compile_options(mavlink_common_headers INTERFACE -Wno-address-of-packed-member -Wno-cast-align)
px4_target_compile_options_for_compiler(mavlink_common_headers INTERFACE
GNU_LIKE -Wno-address-of-packed-member -Wno-cast-align
)
target_include_directories(mavlink_common_headers INTERFACE
${MAVLINK_LIBRARY_DIR}
${MAVLINK_LIBRARY_DIR}/common
+2 -2
View File
@@ -356,7 +356,7 @@ if(EXISTS ${BOARD_DEFCONFIG})
if(CONSTRAINED_FLASH)
set(px4_constrained_flash_build "1" CACHE INTERNAL "constrained flash build" FORCE)
add_definitions(-DCONSTRAINED_FLASH)
add_definitions(-DCONSTRAINED_FLASH=1)
endif()
if(NO_HELP)
@@ -378,7 +378,7 @@ if(EXISTS ${BOARD_DEFCONFIG})
if(CRYPTO)
set(PX4_CRYPTO "1" CACHE INTERNAL "PX4 crypto implementation" FORCE)
add_definitions(-DPX4_CRYPTO)
add_definitions(-DPX4_CRYPTO=1)
endif()
if(LINKER_PREFIX)
+154
View File
@@ -40,6 +40,159 @@
# Usage:
# px4_add_common_flags()
#
function(px4_msvc_compile_options_from_gnu out_var)
set(msvc_flags)
# Keep GNU-like warning names as the common policy vocabulary and translate
# the MSVC equivalents here when the mapping is exact enough to be useful.
foreach(flag IN LISTS ARGN)
if("${flag}" STREQUAL "-Werror")
list(APPEND msvc_flags /WX)
elseif("${flag}" STREQUAL "-Wno-error")
list(APPEND msvc_flags /WX-)
elseif("${flag}" STREQUAL "-Wall" OR "${flag}" STREQUAL "-Wextra")
list(APPEND msvc_flags /W4)
elseif("${flag}" STREQUAL "-Wno-array-bounds")
list(APPEND msvc_flags /wd4789)
elseif("${flag}" STREQUAL "-Wno-deprecated-copy")
list(APPEND msvc_flags /wd5267)
elseif("${flag}" STREQUAL "-Wno-deprecated-declarations")
list(APPEND msvc_flags /wd4996)
elseif("${flag}" STREQUAL "-Wno-empty-body")
list(APPEND msvc_flags /wd4390)
elseif("${flag}" STREQUAL "-Wno-implicit-function-declaration")
list(APPEND msvc_flags /wd4013)
elseif("${flag}" STREQUAL "-Wno-implicit-fallthrough")
list(APPEND msvc_flags /wd5262)
elseif("${flag}" STREQUAL "-Wno-incompatible-pointer-types")
list(APPEND msvc_flags /wd4133)
elseif("${flag}" STREQUAL "-Wno-maybe-uninitialized" OR "${flag}" STREQUAL "-Wno-uninitialized")
list(APPEND msvc_flags /wd4701 /wd4703)
elseif("${flag}" STREQUAL "-Wno-overloaded-virtual")
list(APPEND msvc_flags /wd4263 /wd4264)
elseif("${flag}" STREQUAL "-Wno-shadow")
list(APPEND msvc_flags /wd4456 /wd4457 /wd4458 /wd4459)
elseif("${flag}" STREQUAL "-Wno-sign-compare")
list(APPEND msvc_flags /wd4018 /wd4389)
elseif("${flag}" STREQUAL "-Wno-strict-prototypes")
list(APPEND msvc_flags /wd4255)
elseif("${flag}" STREQUAL "-Wno-switch")
list(APPEND msvc_flags /wd4061 /wd4062)
elseif("${flag}" STREQUAL "-Wno-type-limits")
list(APPEND msvc_flags /wd4296)
elseif("${flag}" STREQUAL "-Wno-unknown-pragmas")
list(APPEND msvc_flags /wd4068)
elseif("${flag}" STREQUAL "-Wno-unused")
list(APPEND msvc_flags /wd4100 /wd4101 /wd4189 /wd4505)
elseif("${flag}" STREQUAL "-Wno-unused-but-set-parameter")
list(APPEND msvc_flags /wd4100)
elseif("${flag}" STREQUAL "-Wno-unused-but-set-variable")
list(APPEND msvc_flags /wd4189)
elseif("${flag}" STREQUAL "-Wno-unused-function")
list(APPEND msvc_flags /wd4505)
elseif("${flag}" STREQUAL "-Wno-unused-parameter")
list(APPEND msvc_flags /wd4100)
elseif("${flag}" STREQUAL "-Wno-unused-variable")
list(APPEND msvc_flags /wd4101 /wd4189)
elseif("${flag}" STREQUAL "-Wno-write-strings")
list(APPEND msvc_flags /wd4090)
endif()
endforeach()
if(msvc_flags)
list(REMOVE_DUPLICATES msvc_flags)
endif()
set(${out_var} ${msvc_flags} PARENT_SCOPE)
endfunction()
function(px4_add_compile_options_for_compiler)
cmake_parse_arguments(arg "" "" "GNU_LIKE;MSVC" ${ARGN})
set(is_gnu_like_compiler FALSE)
if((CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang"))
set(is_gnu_like_compiler TRUE)
endif()
if(MSVC)
if(arg_MSVC)
add_compile_options(${arg_MSVC})
else()
px4_msvc_compile_options_from_gnu(msvc_flags ${arg_GNU_LIKE})
if(msvc_flags)
add_compile_options(${msvc_flags})
endif()
endif()
elseif(is_gnu_like_compiler AND arg_GNU_LIKE)
add_compile_options(${arg_GNU_LIKE})
endif()
endfunction()
function(px4_add_c_compile_options_for_compiler)
cmake_parse_arguments(arg "" "" "GNU_LIKE;MSVC" ${ARGN})
if(MSVC)
if(arg_MSVC)
set(msvc_flags ${arg_MSVC})
else()
px4_msvc_compile_options_from_gnu(msvc_flags ${arg_GNU_LIKE})
endif()
foreach(flag ${msvc_flags})
add_compile_options($<$<COMPILE_LANGUAGE:C>:${flag}>)
endforeach()
elseif(arg_GNU_LIKE AND (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang"))
foreach(flag ${arg_GNU_LIKE})
add_compile_options($<$<COMPILE_LANGUAGE:C>:${flag}>)
endforeach()
endif()
endfunction()
function(px4_target_compile_options_for_compiler target scope)
cmake_parse_arguments(arg "" "" "GNU_LIKE;MSVC" ${ARGN})
set(is_gnu_like_compiler FALSE)
if((CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang"))
set(is_gnu_like_compiler TRUE)
endif()
if(MSVC)
if(arg_MSVC)
target_compile_options(${target} ${scope} ${arg_MSVC})
else()
px4_msvc_compile_options_from_gnu(msvc_flags ${arg_GNU_LIKE})
if(msvc_flags)
target_compile_options(${target} ${scope} ${msvc_flags})
endif()
endif()
elseif(is_gnu_like_compiler AND arg_GNU_LIKE)
target_compile_options(${target} ${scope} ${arg_GNU_LIKE})
endif()
endfunction()
function(px4_target_c_compile_options_for_compiler target scope)
cmake_parse_arguments(arg "" "" "GNU_LIKE;MSVC" ${ARGN})
if(MSVC)
if(arg_MSVC)
set(msvc_flags ${arg_MSVC})
else()
px4_msvc_compile_options_from_gnu(msvc_flags ${arg_GNU_LIKE})
endif()
foreach(flag ${msvc_flags})
target_compile_options(${target} ${scope} $<$<COMPILE_LANGUAGE:C>:${flag}>)
endforeach()
elseif(arg_GNU_LIKE AND (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang"))
foreach(flag ${arg_GNU_LIKE})
target_compile_options(${target} ${scope} $<$<COMPILE_LANGUAGE:C>:${flag}>)
endforeach()
endif()
endfunction()
function(px4_add_common_flags)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
@@ -49,6 +202,7 @@ function(px4_add_common_flags)
/EHsc
/bigobj
/permissive-
/Zc:preprocessor
/utf-8
/FIvisibility.h
/W3
+20 -4
View File
@@ -91,6 +91,22 @@ function(px4_add_module)
REQUIRED MODULE MAIN
ARGN ${ARGN})
set(MODULE_COMPILE_FLAGS ${COMPILE_FLAGS})
if(MSVC AND MODULE_COMPILE_FLAGS)
set(MODULE_COMPILE_FLAGS_FILTERED)
px4_msvc_compile_options_from_gnu(MODULE_COMPILE_FLAGS_MSVC ${MODULE_COMPILE_FLAGS})
foreach(flag IN LISTS MODULE_COMPILE_FLAGS)
if(NOT flag MATCHES "^-W")
list(APPEND MODULE_COMPILE_FLAGS_FILTERED "${flag}")
endif()
endforeach()
list(APPEND MODULE_COMPILE_FLAGS_FILTERED ${MODULE_COMPILE_FLAGS_MSVC})
set(MODULE_COMPILE_FLAGS ${MODULE_COMPILE_FLAGS_FILTERED})
endif()
if(UNITY_BUILD AND (${PX4_PLATFORM} STREQUAL "nuttx"))
# build standalone test library to catch compilation errors and provide sane output
add_library(${MODULE}_original STATIC EXCLUDE_FROM_ALL ${SRCS})
@@ -117,8 +133,8 @@ function(px4_add_module)
target_include_directories(${MODULE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(${MODULE} ${MODULE}_original) # build standalone module first to get clean compile errors
if(COMPILE_FLAGS)
target_compile_options(${MODULE}_original PRIVATE ${COMPILE_FLAGS})
if(MODULE_COMPILE_FLAGS)
target_compile_options(${MODULE}_original PRIVATE ${MODULE_COMPILE_FLAGS})
endif()
if(DEPENDS)
@@ -229,8 +245,8 @@ function(px4_add_module)
message(FATAL_ERROR "MAIN required")
endif()
if(COMPILE_FLAGS)
target_compile_options(${MODULE} PRIVATE ${COMPILE_FLAGS})
if(MODULE_COMPILE_FLAGS)
target_compile_options(${MODULE} PRIVATE ${MODULE_COMPILE_FLAGS})
endif()
if (KERNEL)
+34 -10
View File
@@ -64,24 +64,48 @@ function(px4_add_git_submodule)
set(REL_PATH)
if(IS_ABSOLUTE ${PATH})
if(IS_ABSOLUTE "${PATH}")
set(ABS_PATH ${PATH})
file(RELATIVE_PATH REL_PATH ${PX4_SOURCE_DIR} ${PATH})
else()
file(RELATIVE_PATH REL_PATH ${PX4_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${PATH})
get_filename_component(ABS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}" ABSOLUTE)
file(RELATIVE_PATH REL_PATH ${PX4_SOURCE_DIR} ${ABS_PATH})
endif()
execute_process(
COMMAND Tools/check_submodules.sh ${REL_PATH}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
set(GIT_SUBMODULE_DEPS ${PX4_SOURCE_DIR}/.gitmodules ${ABS_PATH}/.git)
string(REPLACE "/" "_" NAME ${PATH})
string(REPLACE "." "_" NAME ${NAME})
if(CMAKE_GENERATOR STREQUAL "MinGW Makefiles")
set(GIT_SUBMODULE_DEPS)
endif()
if(CMAKE_HOST_WIN32)
if(NOT EXISTS "${ABS_PATH}/.git")
execute_process(
COMMAND git submodule sync --recursive -- ${REL_PATH}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
execute_process(
COMMAND git submodule update --init --recursive -- ${REL_PATH}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
endif()
set(CHECK_SUBMODULE_COMMAND ${CMAKE_COMMAND} -E true)
else()
execute_process(
COMMAND Tools/check_submodules.sh ${REL_PATH}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
set(CHECK_SUBMODULE_COMMAND Tools/check_submodules.sh ${REL_PATH})
endif()
string(MAKE_C_IDENTIFIER "${REL_PATH}" NAME)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
COMMAND Tools/check_submodules.sh ${REL_PATH}
COMMAND ${CHECK_SUBMODULE_COMMAND}
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
DEPENDS ${PX4_SOURCE_DIR}/.gitmodules ${PATH}/.git
DEPENDS ${GIT_SUBMODULE_DEPS}
COMMENT "git submodule ${REL_PATH}"
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
USES_TERMINAL
+5 -1
View File
@@ -430,7 +430,11 @@ add_custom_command(
)
add_library(uorb_msgs ${uorb_headers} ${msg_out_path}/uORBTopics.hpp ${uorb_sources} ${msg_source_out_path}/uORBTopics.cpp ${uorb_message_fields_cpp_file})
target_link_libraries(uorb_msgs PRIVATE m)
if(NOT MSVC)
target_link_libraries(uorb_msgs PRIVATE m)
endif()
add_dependencies(uorb_msgs prebuild_targets uorb_headers)
if(CONFIG_LIB_CDRSTREAM)
+2
View File
@@ -6,6 +6,8 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
elseif(MSVC)
add_compile_options(/W4)
endif()
find_package(ament_cmake REQUIRED)
+7 -1
View File
@@ -3,6 +3,8 @@ project(translation_node)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter -Werror)
elseif(MSVC)
add_compile_options(/W4 /WX /wd4100)
endif()
# find dependencies
@@ -69,7 +71,11 @@ if(BUILD_TESTING)
${TEST_SRC}
)
target_include_directories(${PROJECT_NAME}_unit_tests PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_compile_options(${PROJECT_NAME}_unit_tests PRIVATE -Wno-error=sign-compare) # There is a warning from gtest internal
if(MSVC)
target_compile_options(${PROJECT_NAME}_unit_tests PRIVATE /WX- /wd4018 /wd4389) # There is a warning from gtest internal
else()
target_compile_options(${PROJECT_NAME}_unit_tests PRIVATE -Wno-error=sign-compare) # There is a warning from gtest internal
endif()
target_link_libraries(${PROJECT_NAME}_unit_tests ${PROJECT_NAME}_lib)
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(${PROJECT_NAME}_unit_tests "${cpp_typesupport_target}")
+3 -1
View File
@@ -51,7 +51,9 @@ if(NOT "${PX4_PLATFORM}" MATCHES "nuttx")
work_thread.c
)
target_compile_definitions(work_queue PRIVATE MODULE_NAME="work_queue")
target_compile_options(work_queue PRIVATE -Wno-cast-align) # TODO: fix and enable
px4_target_compile_options_for_compiler(work_queue PRIVATE
GNU_LIKE -Wno-cast-align
)
add_dependencies(work_queue prebuild_targets)
endif()
+3 -2
View File
@@ -72,9 +72,10 @@ if (BUILD_TESTING)
${_px4_posix_math_libraries}
parameters
)
target_compile_options(mavlink_fuzz_tests
px4_target_compile_options_for_compiler(mavlink_fuzz_tests
PRIVATE
# There warnings come from within fuzztest
GNU_LIKE
# These warnings come from within fuzztest
-Wno-float-equal
-Wno-sign-compare
-Wno-shadow
@@ -20,16 +20,66 @@ set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
find_program(MINGW_C_COMPILER NAMES ${TOOLCHAIN_PREFIX}-gcc-posix ${TOOLCHAIN_PREFIX}-gcc)
find_program(MINGW_CXX_COMPILER NAMES ${TOOLCHAIN_PREFIX}-g++-posix ${TOOLCHAIN_PREFIX}-g++)
find_program(MINGW_RC_COMPILER NAMES ${TOOLCHAIN_PREFIX}-windres)
find_program(MINGW_AR NAMES ${TOOLCHAIN_PREFIX}-ar)
find_program(MINGW_RANLIB NAMES ${TOOLCHAIN_PREFIX}-ranlib)
set(MINGW_SEARCH_PATHS)
if(NOT MINGW_C_COMPILER OR NOT MINGW_CXX_COMPILER)
message(FATAL_ERROR
"MinGW-w64 (${TOOLCHAIN_PREFIX}) not found. "
"Install with: apt-get install mingw-w64 g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix")
if(CMAKE_HOST_WIN32)
list(APPEND MINGW_SEARCH_PATHS
"$ENV{MINGW_PREFIX}/bin"
"C:/msys64/mingw64/bin")
endif()
find_program(MINGW_REAL_C_COMPILER NAMES ${TOOLCHAIN_PREFIX}-gcc-posix ${TOOLCHAIN_PREFIX}-gcc HINTS ${MINGW_SEARCH_PATHS})
find_program(MINGW_REAL_CXX_COMPILER NAMES ${TOOLCHAIN_PREFIX}-g++-posix ${TOOLCHAIN_PREFIX}-g++ HINTS ${MINGW_SEARCH_PATHS})
find_program(MINGW_REAL_RC_COMPILER NAMES ${TOOLCHAIN_PREFIX}-windres HINTS ${MINGW_SEARCH_PATHS})
find_program(MINGW_AR NAMES ${TOOLCHAIN_PREFIX}-ar HINTS ${MINGW_SEARCH_PATHS})
find_program(MINGW_RANLIB NAMES ${TOOLCHAIN_PREFIX}-ranlib HINTS ${MINGW_SEARCH_PATHS})
if(NOT MINGW_REAL_C_COMPILER OR NOT MINGW_REAL_CXX_COMPILER)
if(CMAKE_HOST_WIN32)
message(FATAL_ERROR
"MinGW-w64 (${TOOLCHAIN_PREFIX}) not found. "
"Install the MSYS2 mingw-w64-x86_64 toolchain and add the MinGW bin directory "
"(for example C:/msys64/mingw64/bin) to PATH.")
else()
message(FATAL_ERROR
"MinGW-w64 (${TOOLCHAIN_PREFIX}) not found. "
"Install with: apt-get install mingw-w64 g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix")
endif()
endif()
get_filename_component(MINGW_BIN_DIR "${MINGW_REAL_C_COMPILER}" DIRECTORY)
if(CMAKE_HOST_WIN32)
# The GCC driver is enough to locate cc1/ld, but child tools still need
# the MinGW DLLs from the same bin directory.
set(ENV{PATH} "${MINGW_BIN_DIR};$ENV{PATH}")
set(MINGW_WRAPPER_DIR "${CMAKE_BINARY_DIR}/mingw_toolchain")
set(MINGW_WRAPPER_PATH "${MINGW_BIN_DIR};%SystemRoot%/system32;%SystemRoot%;%SystemRoot%/System32/Wbem")
file(MAKE_DIRECTORY "${MINGW_WRAPPER_DIR}")
file(WRITE "${MINGW_WRAPPER_DIR}/gcc.cmd"
"@echo off\r\n"
"set \"PATH=${MINGW_WRAPPER_PATH}\"\r\n"
"\"${MINGW_REAL_C_COMPILER}\" %*\r\n"
"exit /b %ERRORLEVEL%\r\n")
file(WRITE "${MINGW_WRAPPER_DIR}/gxx.cmd"
"@echo off\r\n"
"set \"PATH=${MINGW_WRAPPER_PATH}\"\r\n"
"\"${MINGW_REAL_CXX_COMPILER}\" %*\r\n"
"exit /b %ERRORLEVEL%\r\n")
file(WRITE "${MINGW_WRAPPER_DIR}/windres.cmd"
"@echo off\r\n"
"set \"PATH=${MINGW_WRAPPER_PATH}\"\r\n"
"\"${MINGW_REAL_RC_COMPILER}\" %*\r\n"
"exit /b %ERRORLEVEL%\r\n")
set(MINGW_C_COMPILER "${MINGW_WRAPPER_DIR}/gcc.cmd")
set(MINGW_CXX_COMPILER "${MINGW_WRAPPER_DIR}/gxx.cmd")
set(MINGW_RC_COMPILER "${MINGW_WRAPPER_DIR}/windres.cmd")
else()
set(MINGW_C_COMPILER "${MINGW_REAL_C_COMPILER}")
set(MINGW_CXX_COMPILER "${MINGW_REAL_CXX_COMPILER}")
set(MINGW_RC_COMPILER "${MINGW_REAL_RC_COMPILER}")
endif()
set(CMAKE_C_COMPILER ${MINGW_C_COMPILER})
@@ -43,7 +93,14 @@ set(CMAKE_RANLIB ${MINGW_RANLIB})
# PACKAGE uses BOTH so find_package() can locate packages installed by
# nested ExternalProject builds (microcdr under the PX4 build tree) as
# well as packages living in the MinGW sysroot.
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
if(CMAKE_HOST_WIN32)
get_filename_component(MINGW_PREFIX "${MINGW_BIN_DIR}" DIRECTORY)
set(CMAKE_FIND_ROOT_PATH
"${MINGW_PREFIX}"
"${MINGW_PREFIX}/${TOOLCHAIN_PREFIX}")
else()
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
endif()
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
@@ -58,6 +115,20 @@ get_filename_component(_px4_windows_shim_dir
"${CMAKE_CURRENT_LIST_DIR}/../include/windows_shim" ABSOLUTE)
include_directories(BEFORE SYSTEM "${_px4_windows_shim_dir}")
# Vendored upstream code (Micro-XRCE-DDS-Client, CycloneDDS, libvnc) writes
# `#include <Windows.h>`. MinGW only ships the lowercase header, so on
# case-sensitive hosts (Linux, macOS) we need an uppercase alias. On
# case-insensitive hosts (Windows itself) the alias must NOT exist on the
# include path: a shim `Windows.h` would match `#include <windows.h>` first
# and `#pragma once`-recurse to itself, hiding the real header. Generate
# the alias under the build tree only when we actually need it.
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(_px4_windows_case_alias_dir ${CMAKE_BINARY_DIR}/windows_case_alias)
file(WRITE ${_px4_windows_case_alias_dir}/Windows.h
"#pragma once\n#include <windows.h>\n")
include_directories(BEFORE SYSTEM ${_px4_windows_case_alias_dir})
endif()
# Target Windows 10 (1803+) so AF_UNIX is available in WinSock2.
add_compile_definitions(
_WIN32_WINNT=0x0A00 # Windows 10
+9 -5
View File
@@ -211,13 +211,17 @@ function(px4_posix_generate_symlinks)
if (MAIN)
set(ln_name "${PREFIX}${MAIN}")
if(WIN32 OR MINGW)
# Windows symlinks require admin; copy the exe instead so that
# px4-<module>.exe can be invoked the same way as on POSIX.
set(alias_executable "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ln_name}.exe")
# Windows symlinks require extra privileges. Hard links keep the
# px4-<module>.exe entry points without duplicating the MSVC exe.
add_custom_command(TARGET ${TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
COMMAND ${CMAKE_COMMAND} -E remove -f
${alias_executable}
COMMAND ${CMAKE_COMMAND} -E create_hardlink
$<TARGET_FILE:${TARGET}>
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ln_name}.exe
${alias_executable}
)
else()
add_custom_command(TARGET ${TARGET}
@@ -245,7 +249,7 @@ function(px4_os_add_flags)
add_definitions(-D__PX4_POSIX)
if(MSVC)
add_definitions(-Dnoreturn_function=__declspec\(noreturn\))
add_definitions(-Dnoreturn_function=)
else()
add_definitions(-Dnoreturn_function=__attribute__\(\(noreturn\)\))
endif()
+18
View File
@@ -38,6 +38,9 @@
set(PX4_POSIX_WINDOWS_ROOT "${PX4_SOURCE_DIR}/platforms/posix/src/px4/windows")
set(PX4_POSIX_WINDOWS_PRIVATE_INCLUDE_DIR "${PX4_POSIX_WINDOWS_ROOT}/include")
set(PX4_POSIX_WINDOWS_DYNAMIC_MODULE_HOST_EXPORTS
px4_log_modulename
)
function(px4_posix_windows_append_sources out_var)
list(APPEND ${out_var}
@@ -109,6 +112,20 @@ function(px4_posix_windows_configure_target target_name)
if(MSVC)
set_target_properties(${target_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_compile_options(${target_name} PRIVATE /bigobj)
# Reproducible builds: zero out the PE COFF TimeDateStamp and the debug
# directory timestamp so byte-identical sources produce a byte-identical
# px4.exe. Without /Brepro every link embeds time(NULL), making CI
# artifact diffing and supply-chain hashing meaningless.
target_compile_options(${target_name} PRIVATE /Brepro)
target_link_options(${target_name} PRIVATE /Brepro)
# WINDOWS_EXPORT_ALL_SYMBOLS only scans objects owned directly by
# px4.exe. Dynamic .px4mod modules also need host APIs that come from
# PX4 static libraries, so export those entry points explicitly.
foreach(host_export IN LISTS PX4_POSIX_WINDOWS_DYNAMIC_MODULE_HOST_EXPORTS)
target_link_options(${target_name} PRIVATE "/EXPORT:${host_export}")
endforeach()
else()
# Force an import library (`libpx4.dll.a`) to be generated alongside
# px4.exe so DYNAMIC `.px4mod` modules can link against it.
@@ -149,6 +166,7 @@ function(px4_posix_windows_link_libraries target_name)
iphlpapi
dbghelp
psapi
winmm # timeBeginPeriod / timeEndPeriod for 1 ms timer resolution
)
if(NOT MSVC)
@@ -51,7 +51,9 @@ add_library(px4_layer
SerialImpl.cpp
)
target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4")
target_compile_options(px4_layer PRIVATE -Wno-cast-align) # TODO: fix and enable
px4_target_compile_options_for_compiler(px4_layer PRIVATE
GNU_LIKE -Wno-cast-align # TODO: fix and enable
)
target_link_libraries(px4_layer PRIVATE work_queue px4_work_queue)
target_link_libraries(px4_layer PRIVATE px4_daemon drivers_board)
+4 -3
View File
@@ -46,9 +46,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
# src/px4/common/main.cpp
# )
add_compile_options(
-Wno-error
-Wno-float-equal # msg generated equality operator
px4_add_compile_options_for_compiler(
GNU_LIKE
-Wno-error
-Wno-float-equal # msg generated equality operator
)
include_directories(${PX4_BINARY_DIR})
+3 -1
View File
@@ -37,4 +37,6 @@ add_library(px4_layer STATIC
${PX4_SOURCE_DIR}/platforms/common/module_base.cpp
)
target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4")
target_compile_options(px4_layer PRIVATE -Wno-cast-align) # TODO: fix and enable
px4_target_compile_options_for_compiler(px4_layer PRIVATE
GNU_LIKE -Wno-cast-align # TODO: fix and enable
)
+3 -1
View File
@@ -143,4 +143,6 @@ px4_add_module(
)
# libcanard 3.0 introduces this warning, for now no intention to fix it thus we ignore this warning
set_source_files_properties(${LIBCANARD_DIR}/libcanard/canard.c PROPERTIES COMPILE_FLAGS -Wno-cast-align)
if(NOT MSVC)
set_source_files_properties(${LIBCANARD_DIR}/libcanard/canard.c PROPERTIES COMPILE_FLAGS -Wno-cast-align)
endif()
@@ -38,9 +38,8 @@ set(SOURCES
)
add_library(${LIBRARY_NAME} ${SOURCES})
target_compile_options(${LIBRARY_NAME}
PRIVATE
-Wno-unused-function
px4_target_compile_options_for_compiler(${LIBRARY_NAME} PRIVATE
GNU_LIKE -Wno-unused-function
)
target_include_directories(${LIBRARY_NAME} PUBLIC
@@ -42,6 +42,17 @@ set(BUILD_EXAMPLES "OFF" CACHE BOOL "" FORCE)
set(BUILD_TESTING "OFF" CACHE BOOL "" FORCE)
add_subdirectory(mip_sdk)
# The mip target lives in a vendored submodule; apply PX4's compiler-specific
# warning suppressions from the parent so the submodule tree stays clean.
if(TARGET mip)
px4_target_compile_options_for_compiler(mip PRIVATE
GNU_LIKE
-Wno-shadow
-Wno-strict-prototypes
-Wno-incompatible-pointer-types
)
endif()
px4_add_module(
MODULE drivers__ins__microstrain
MAIN microstrain
+10 -10
View File
@@ -51,16 +51,16 @@ add_dependencies(sbgECom prebuild_targets)
# If you add a flag here, it should address a warning emitted by vendor
# code only. Warnings triggered in PX4-authored code must be fixed at
# the source, not silenced here.
target_compile_options(sbgECom
PRIVATE
-Wno-format
-Wno-format-security
-Wno-bad-function-cast
-Wno-double-promotion
-Wno-type-limits
-Wno-maybe-uninitialized
-Wno-float-equal
-Wno-logical-op
px4_target_compile_options_for_compiler(sbgECom PRIVATE
GNU_LIKE
-Wno-format
-Wno-format-security
-Wno-bad-function-cast
-Wno-double-promotion
-Wno-type-limits
-Wno-maybe-uninitialized
-Wno-float-equal
-Wno-logical-op
)
# -Wno-typedef-redefinition is Clang-only. GCC rejects unrecognized
+19 -11
View File
@@ -56,17 +56,25 @@ add_library(libvnc ${SOURCES})
add_dependencies(libvnc prebuild_targets)
target_compile_options(libvnc
PRIVATE
-Wno-double-promotion
-Wno-pointer-sign
-Wno-cast-align
-Wno-unused-but-set-parameter
-Wno-sign-compare
-Wno-bad-function-cast
-Wno-empty-body
-Wno-switch
-Wno-unused-variable
-Wno-format
-Wno-format-security
$<$<C_COMPILER_ID:MSVC>:/wd4018>
$<$<C_COMPILER_ID:MSVC>:/wd4061>
$<$<C_COMPILER_ID:MSVC>:/wd4062>
$<$<C_COMPILER_ID:MSVC>:/wd4100>
$<$<C_COMPILER_ID:MSVC>:/wd4101>
$<$<C_COMPILER_ID:MSVC>:/wd4189>
$<$<C_COMPILER_ID:MSVC>:/wd4389>
$<$<C_COMPILER_ID:MSVC>:/wd4390>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-double-promotion>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-pointer-sign>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-cast-align>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-unused-but-set-parameter>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-sign-compare>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-bad-function-cast>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-empty-body>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-switch>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-unused-variable>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-format>
$<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-format-security>
)
if("${PX4_PLATFORM}" MATCHES "nuttx")
@@ -31,12 +31,14 @@
#
############################################################################
add_compile_options(-Wno-stringop-truncation) # full message intentional string truncation
px4_add_library(message_display
MessageDisplay.cpp
MessageDisplay.hpp
)
px4_target_compile_options_for_compiler(message_display PRIVATE
GNU_LIKE -Wno-stringop-truncation # full message intentional string truncation
)
# unit testing
px4_add_unit_gtest(SRC MessageDisplayTest.cpp LINKLIBS message_display)
+5 -4
View File
@@ -86,10 +86,11 @@ add_definitions(
-DUAVCAN_PLATFORM=${UAVCAN_PLATFORM}
)
add_compile_options(
-Wno-cast-align # TODO: fix and enable
-Wno-deprecated-copy # TODO: fix
-Wno-address-of-packed-member
px4_add_compile_options_for_compiler(
GNU_LIKE
-Wno-cast-align # TODO: fix and enable
-Wno-deprecated-copy # TODO: fix
-Wno-address-of-packed-member
)
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE) # silence libuavcan deprecation warning for now (TODO: fix and remove)
add_subdirectory(${LIBDRONECAN_DIR} libdronecan EXCLUDE_FROM_ALL)
@@ -2,7 +2,7 @@ include_directories(
./include
)
add_compile_options(-Wno-unused-variable)
px4_add_compile_options_for_compiler(GNU_LIKE -Wno-unused-variable)
add_library(uavcan_kinetis_driver STATIC
./src/uc_kinetis_flexcan.cpp
./src/uc_kinetis_clock.cpp
@@ -2,7 +2,7 @@ include_directories(
./include
)
add_compile_options(-Wno-unused-variable)
px4_add_compile_options_for_compiler(GNU_LIKE -Wno-unused-variable)
add_library(uavcan_socketcan_driver STATIC
src/socketcan.cpp
src/thread.cpp
+11 -5
View File
@@ -36,11 +36,17 @@ if(CONFIG_LIB_CDRSTREAM)
# CycloneDDS CDR serializer
include(${CMAKE_CURRENT_LIST_DIR}/cyclonedds/src/core/cdr/CMakeLists.txt)
target_compile_options(cdr PUBLIC
-Wno-cast-align
-Wno-double-promotion
$<$<COMPILE_LANGUAGE:C>:-Wno-implicit-function-declaration -Wno-nested-externs>
-DNDEBUG)
target_compile_options(cdr PUBLIC -DNDEBUG)
px4_target_compile_options_for_compiler(cdr PUBLIC
GNU_LIKE
-Wno-cast-align
-Wno-double-promotion
)
px4_target_c_compile_options_for_compiler(cdr PUBLIC
GNU_LIKE
-Wno-implicit-function-declaration
-Wno-nested-externs
)
px4_add_git_submodule(TARGET git_cyclonedds PATH "cyclonedds")
px4_add_git_submodule(TARGET git_rosidl PATH "rosidl")
add_dependencies(cdr git_cyclonedds git_rosidl uorb_headers parameters px4_platform)
+3 -1
View File
@@ -36,7 +36,9 @@ px4_add_library(CollisionPrevention
ObstacleMath.cpp
)
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/collisionprevention_params.yaml)
target_compile_options(CollisionPrevention PRIVATE -Wno-cast-align) # TODO: fix and enable
px4_target_compile_options_for_compiler(CollisionPrevention PRIVATE
GNU_LIKE -Wno-cast-align # TODO: fix and enable
)
target_include_directories(CollisionPrevention PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(CollisionPrevention PRIVATE mathlib)
@@ -31,11 +31,19 @@
#
############################################################################
set(controllib_test_compile_flags)
if(NOT MSVC)
list(APPEND controllib_test_compile_flags
-Wno-double-promotion # TODO: fix in Matrix library Vector::pow()
)
endif()
px4_add_module(
MODULE lib__controllib__controllib_test
MAIN controllib_test
COMPILE_FLAGS
-Wno-double-promotion # TODO: fix in Matrix library Vector::pow()
${controllib_test_compile_flags}
SRCS
controllib_test_main.cpp
MODULE_CONFIG
+6 -2
View File
@@ -48,7 +48,9 @@ target_include_directories(monocypher
)
# There is a one shadow warning in monocypher 3.1.2, ignore it
target_compile_options(monocypher PRIVATE -Wno-shadow)
px4_target_compile_options_for_compiler(monocypher PRIVATE
GNU_LIKE -Wno-shadow
)
@@ -97,7 +99,9 @@ target_link_libraries(libtomcrypt
# Fix for erroneous warning on some compilers:
# "der_encode_asn1_identifier.c:39:18: error: comparison is always false due to limited range of data type"
target_compile_options(libtomcrypt PRIVATE -Wno-type-limits)
px4_target_compile_options_for_compiler(libtomcrypt PRIVATE
GNU_LIKE -Wno-type-limits
)
# Re-define memory allocation macros if we are building for
# memory protected build in nuttx. All allocations happen in
+9 -1
View File
@@ -42,6 +42,14 @@ foreach(f ${all_px4_src_files})
list(APPEND all_px4_src_files_relative "${relative_path}")
endforeach(f)
# The relative list still blows past Windows' 8191-char cmd.exe line limit
# (~50 KB worth of paths). Write it to a response file and pass it through
# argparse's @file expansion so the python invocation stays a few hundred
# bytes regardless of source count.
set(events_srcs_response ${CMAKE_CURRENT_BINARY_DIR}/px4_event_srcs.rsp)
string(REPLACE ";" "\n" _events_srcs_lines "${all_px4_src_files_relative}")
file(WRITE ${events_srcs_response} "${_events_srcs_lines}\n")
set(generated_events_dir ${PX4_BINARY_DIR}/events)
set(generated_events_px4_file ${generated_events_dir}/px4.json)
set(generated_events_common_enums_file ${generated_events_dir}/common_with_enums.json)
@@ -49,7 +57,7 @@ add_custom_command(OUTPUT ${generated_events_px4_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${generated_events_dir}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_events.py
--base-path ${PX4_SOURCE_DIR}/src
--src-path ${all_px4_src_files_relative}
--src-path @${events_srcs_response}
--json ${generated_events_px4_file} #--verbose
DEPENDS
${all_px4_src_files}
+2 -2
View File
@@ -33,6 +33,6 @@
px4_add_library(led led.cpp)
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/led_params.yaml)
target_compile_options(led
PRIVATE -Wno-implicit-fallthrough # TODO: fix and remove
px4_target_compile_options_for_compiler(led PRIVATE
GNU_LIKE -Wno-implicit-fallthrough # TODO: fix and remove
)
+4 -3
View File
@@ -1,6 +1,7 @@
add_compile_options(
-Wno-double-promotion
-Wno-float-equal
px4_add_compile_options_for_compiler(
GNU_LIKE
-Wno-double-promotion
-Wno-float-equal
)
px4_add_unit_gtest(SRC MatrixAssignmentTest.cpp)
+5 -3
View File
@@ -201,11 +201,13 @@ if(NOT "${PX4_BOARD}" MATCHES "px4_io")
target_link_libraries(parameters PRIVATE perf tinybson px4_platform)
target_compile_definitions(parameters PRIVATE -DMODULE_NAME="parameters" -D__KERNEL__)
target_compile_options(parameters
PRIVATE
#-DDEBUG_BUILD
#target_compile_options(parameters PRIVATE -DDEBUG_BUILD)
px4_target_compile_options_for_compiler(parameters PRIVATE
GNU_LIKE
-Wno-cast-align # TODO: fix and enable
-Wno-sign-compare # TODO: fix and enable
MSVC
/wd4389
)
else()
add_library(parameters STATIC EXCLUDE_FROM_ALL ${PX4_SOURCE_DIR}/platforms/common/empty.c)
+2 -3
View File
@@ -40,9 +40,8 @@ add_library(rc
dsm.cpp
common_rc.cpp
)
target_compile_options(rc
PRIVATE
#-DDEBUG_BUILD
px4_target_compile_options_for_compiler(rc PRIVATE
GNU_LIKE
-Wno-unused-result
)
target_link_libraries(rc PRIVATE prebuild_targets)
+9 -1
View File
@@ -31,11 +31,19 @@
#
############################################################################
set(rc_tests_compile_flags)
if(NOT MSVC)
list(APPEND rc_tests_compile_flags
-Wno-unused-result
)
endif()
px4_add_module(
MODULE lib__rc__rc_tests
MAIN rc_tests
COMPILE_FLAGS
-Wno-unused-result
${rc_tests_compile_flags}
SRCS
RCTest.cpp
DEPENDS
+5 -4
View File
@@ -7,9 +7,10 @@ if(CONFIG_LIB_RL_TOOLS)
target_compile_features(rl_tools INTERFACE cxx_std_17)
target_compile_options(rl_tools INTERFACE
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-local-typedefs
px4_target_compile_options_for_compiler(rl_tools INTERFACE
GNU_LIKE
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-local-typedefs
)
endif()
+5 -8
View File
@@ -36,11 +36,6 @@ if(CONFIG_LIB_TFLM)
set(TFLITE_DOWNLOADS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro/tensorflow/lite/micro/tools/make/downloads)
get_directory_property(FLAGS COMPILE_OPTIONS)
list(REMOVE_ITEM FLAGS "-Wcast-align")
set_directory_properties(PROPERTIES COMPILE_OPTIONS "${FLAGS}")
file(GLOB TFLITE_MICRO_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro/tensorflow/lite/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro/tensorflow/lite/micro/*.cc
@@ -85,9 +80,11 @@ if(CONFIG_LIB_TFLM)
add_dependencies(tensorflow_lite_micro git_tflite-micro)
target_compile_features(tensorflow_lite_micro PRIVATE cxx_std_17)
target_compile_options(tensorflow_lite_micro PUBLIC
-Wno-float-equal
-Wno-shadow
px4_target_compile_options_for_compiler(tensorflow_lite_micro PUBLIC
GNU_LIKE
-Wno-cast-align
-Wno-float-equal
-Wno-shadow
)
+4 -1
View File
@@ -38,8 +38,11 @@ add_library(tinybson
target_compile_definitions(tinybson PRIVATE -DMODULE_NAME="tinybson")
target_compile_options(tinybson
PRIVATE
-Wno-sign-compare # TODO: fix this
${MAX_CUSTOM_OPT_LEVEL}
)
px4_target_compile_options_for_compiler(tinybson PRIVATE
GNU_LIKE -Wno-sign-compare
MSVC /wd4018 /wd4389
)
add_dependencies(tinybson prebuild_targets)
+1 -1
View File
@@ -54,7 +54,7 @@ endif()
set(px4_git_ver_header ${CMAKE_CURRENT_BINARY_DIR}/build_git_version.h)
add_custom_command(OUTPUT ${px4_git_ver_header}
COMMAND
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py ${px4_git_ver_header} --validate --git_tag '${PX4_GIT_TAG}'
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py ${px4_git_ver_header} --validate --git_tag ${PX4_GIT_TAG}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py
${git_dir_path}/HEAD
+4 -1
View File
@@ -57,5 +57,8 @@ target_compile_options(world_magnetic_model PRIVATE ${MAX_CUSTOM_OPT_LEVEL})
if(BUILD_TESTING)
px4_add_unit_gtest(SRC test_geo_lookup.cpp LINKLIBS world_magnetic_model)
target_compile_options(unit-test_geo_lookup PRIVATE ${PX4_DEBUG_OPT_LEVEL} -Wno-double-promotion)
target_compile_options(unit-test_geo_lookup PRIVATE ${PX4_DEBUG_OPT_LEVEL})
px4_target_compile_options_for_compiler(unit-test_geo_lookup PRIVATE
GNU_LIKE -Wno-double-promotion
)
endif()
+8 -1
View File
@@ -30,11 +30,18 @@
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
set(dataman_compile_flags)
if(NOT MSVC)
list(APPEND dataman_compile_flags -Wno-cast-align) # TODO: fix and enable
endif()
px4_add_module(
MODULE modules__dataman
MAIN dataman
COMPILE_FLAGS
-Wno-cast-align # TODO: fix and enable
${dataman_compile_flags}
SRCS
dataman.cpp
MODULE_CONFIG
+9 -2
View File
@@ -244,12 +244,19 @@ endif ()
add_subdirectory(EKF)
set(ekf2_compile_flags ${MAX_CUSTOM_OPT_LEVEL})
if(MSVC)
list(APPEND ekf2_compile_flags /fp:precise)
else()
list(APPEND ekf2_compile_flags -fno-associative-math)
endif()
px4_add_module(
MODULE modules__ekf2
MAIN ekf2
COMPILE_FLAGS
${MAX_CUSTOM_OPT_LEVEL}
-fno-associative-math
${ekf2_compile_flags}
#-DDEBUG_BUILD
#-O0
INCLUDES
+4 -1
View File
@@ -161,4 +161,7 @@ target_link_libraries(ecl_EKF
${EKF_LIBS}
)
target_compile_options(ecl_EKF PRIVATE -fno-associative-math)
px4_target_compile_options_for_compiler(ecl_EKF PRIVATE
GNU_LIKE -fno-associative-math
MSVC /fp:precise
)
@@ -89,8 +89,8 @@ add_custom_target(flighttasks_generated
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/FlightTasks_generated.cpp)
add_dependencies(prebuild_targets flighttasks_generated)
add_compile_options(
-Wno-cast-align
px4_add_compile_options_for_compiler(
GNU_LIKE -Wno-cast-align
) # TODO: fix and enable
# add subdirectory containing all tasks
+6 -2
View File
@@ -42,10 +42,14 @@ endif()
# CMSIS DSP contains ARM Cortex-M assembly that triggers clang warnings on 64-bit ARM.
# This code is unused on POSIX platforms - only the C fallback implementations run.
if(${PX4_PLATFORM} MATCHES "posix" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64|aarch64")
add_compile_options(-Wno-asm-operand-widths)
px4_add_compile_options_for_compiler(
GNU_LIKE -Wno-asm-operand-widths
)
endif()
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-nested-externs>)
px4_add_c_compile_options_for_compiler(
GNU_LIKE -Wno-nested-externs
)
px4_add_module(
MODULE modules__gyro_fft
+7 -2
View File
@@ -37,6 +37,12 @@ if(PX4_CRYPTO)
list(APPEND LOGGER_MODULE_PARAMS module_params_crypto.yaml)
endif()
set(logger_compile_flags ${MAX_CUSTOM_OPT_LEVEL})
if(NOT MSVC)
list(APPEND logger_compile_flags -Wno-cast-align) # TODO: fix and enable
endif()
px4_add_module(
MODULE modules__logger
MAIN logger
@@ -46,8 +52,7 @@ px4_add_module(
module.yaml
${LOGGER_MODULE_PARAMS}
COMPILE_FLAGS
${MAX_CUSTOM_OPT_LEVEL}
-Wno-cast-align # TODO: fix and enable
${logger_compile_flags}
SRCS
logged_topics.cpp
logger.cpp

Some files were not shown because too many files have changed in this diff Show More