diff --git a/cmake/compiler/gcc/target_imacros.cmake b/cmake/compiler/gcc/target_imacros.cmake index 804040411c5..0fba83819af 100644 --- a/cmake/compiler/gcc/target_imacros.cmake +++ b/cmake/compiler/gcc/target_imacros.cmake @@ -4,6 +4,12 @@ macro(toolchain_cc_imacros header_file) - zephyr_compile_options(--imacros=${header_file}) + # We cannot use the "-imacros foo" form here as CMake insists on + # deduplicating arguments, meaning that subsequent usages after the + # first one will see the "-imacros " part removed. + # gcc and clang support the "--imacros=foo" form but not xcc. + # Let's use the "combined" form (without space) which is supported + # by everyone so far. + zephyr_compile_options(-imacros${header_file}) endmacro()