fix(mosq): Fix clean compilation addressing _GNU_SOURCE redefined

This commit is contained in:
David Cermak
2024-09-16 09:48:56 +02:00
parent a20c0c9d2c
commit e2392c36fe
2 changed files with 8 additions and 2 deletions

View File

@ -25,8 +25,6 @@ jobs:
with:
submodules: recursive
- name: Build with IDF-${{ matrix.idf_ver }}
env:
EXPECTED_WARNING: "\"_GNU_SOURCE\" redefined"
shell: bash
run: |
. ${IDF_PATH}/export.sh

View File

@ -82,3 +82,11 @@ idf_component_register(SRCS ${m_srcs}
target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_BROKER")
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
# Some mosquittos source unconditionally define `_GNU_SOURCE` which collides with IDF build system
# producing warning: "_GNU_SOURCE" redefined
# This workarounds this issue by undefining the macro for the selected files
set(sources_that_define_gnu_source ${m_lib_dir}/net_mosq.c ${m_src_dir}/loop.c ${m_src_dir}/mux_poll.c)
foreach(offending_src ${sources_that_define_gnu_source})
set_source_files_properties(${offending_src} PROPERTIES COMPILE_OPTIONS "-U_GNU_SOURCE")
endforeach()