diff --git a/.github/workflows/mosq__build.yml b/.github/workflows/mosq__build.yml index b1fc163f6..476d174d6 100644 --- a/.github/workflows/mosq__build.yml +++ b/.github/workflows/mosq__build.yml @@ -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 diff --git a/components/mosquitto/CMakeLists.txt b/components/mosquitto/CMakeLists.txt index eccfaa913..ef43060db 100644 --- a/components/mosquitto/CMakeLists.txt +++ b/components/mosquitto/CMakeLists.txt @@ -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()