Skip to content
Browse files

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()

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


Signed-off-by: Nicolas Pitre <>
  • Loading branch information...
Nicolas Pitre authored and nashif committed Jun 13, 2019
1 parent d4b60d6 commit f57ba2d30c2d7aaea8298f4d931901f09f5c1fc0
Showing with 1 addition and 1 deletion.
  1. +1 −1 cmake/compiler/gcc/target_imacros.cmake
@@ -4,6 +4,6 @@

macro(toolchain_cc_imacros header_file)

zephyr_compile_options(-imacros ${header_file})


0 comments on commit f57ba2d

Please sign in to comment.
You can’t perform that action at this time.