Skip to content

Commit f57ba2d

Browse files
Nicolas Pitrenashif
authored andcommitted
cmake: toolchain_cc_imacros: don't use space separated arguments
Because CMake explicitly deduplicates arguments, it is not possible to use toolchain_cc_imacros() multiple times as the later "-imacros" are stripped away, leaving the associated file arguments dangling. The documented workaround in the CMake manual involves some "SHELL:..." construct but that doesn't get through zephyr_compile_options() undammaged. Let's simply remove this issue altogether by replacing "-imacros x.h" with the joined form "--imacros=x.h" instead. Both gcc and clang support this syntax. FYI, this joined form is also available for other arguments such as: -include x.h --> --include=x.h -A foo --> --assert=foo -D foo --> --define-macro=foo -U foo --> --undefine-macro=foo Etc. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
1 parent d4b60d6 commit f57ba2d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎cmake/compiler/gcc/target_imacros.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
macro(toolchain_cc_imacros header_file)
66

7-
zephyr_compile_options(-imacros ${header_file})
7+
zephyr_compile_options(--imacros=${header_file})
88

99
endmacro()

0 commit comments

Comments
 (0)