Skip to content

Commit e2392c3

Browse files
committed
fix(mosq): Fix clean compilation addressing _GNU_SOURCE redefined
1 parent a20c0c9 commit e2392c3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/mosq__build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525
with:
2626
submodules: recursive
2727
- name: Build with IDF-${{ matrix.idf_ver }}
28-
env:
29-
EXPECTED_WARNING: "\"_GNU_SOURCE\" redefined"
3028
shell: bash
3129
run: |
3230
. ${IDF_PATH}/export.sh

components/mosquitto/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ idf_component_register(SRCS ${m_srcs}
8282

8383
target_compile_definitions(${COMPONENT_LIB} PRIVATE "WITH_BROKER")
8484
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
85+
86+
# Some mosquittos source unconditionally define `_GNU_SOURCE` which collides with IDF build system
87+
# producing warning: "_GNU_SOURCE" redefined
88+
# This workarounds this issue by undefining the macro for the selected files
89+
set(sources_that_define_gnu_source ${m_lib_dir}/net_mosq.c ${m_src_dir}/loop.c ${m_src_dir}/mux_poll.c)
90+
foreach(offending_src ${sources_that_define_gnu_source})
91+
set_source_files_properties(${offending_src} PROPERTIES COMPILE_OPTIONS "-U_GNU_SOURCE")
92+
endforeach()

0 commit comments

Comments
 (0)