From 83c10268f1d71a3d19c1e2790a183246e3c36838 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 29 Sep 2021 00:27:06 +0000 Subject: [PATCH] cmake: add EXTRA_CFLAGS support Example: EXTRA_CFLAGS="-Werror -g0" ./scripts/xtensa-build-all.sh Signed-off-by: Marc Herbert --- scripts/xtensa-build-all.sh | 1 + src/arch/xtensa/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/scripts/xtensa-build-all.sh b/scripts/xtensa-build-all.sh index 2df924e86..5e6ff050e 100755 --- a/scripts/xtensa-build-all.sh +++ b/scripts/xtensa-build-all.sh @@ -393,6 +393,7 @@ do "${MEU_PATH_OPTION}" \ "${PRIVATE_KEY_OPTION}" \ -DINIT_CONFIG=${PLATFORM}${DEFCONFIG_PATCH}_defconfig \ + -DEXTRA_CFLAGS="${EXTRA_CFLAGS}" \ "$SOF_TOP" ) diff --git a/src/arch/xtensa/CMakeLists.txt b/src/arch/xtensa/CMakeLists.txt index 97e63aa5f..ef385569a 100644 --- a/src/arch/xtensa/CMakeLists.txt +++ b/src/arch/xtensa/CMakeLists.txt @@ -119,6 +119,8 @@ target_compile_options(sof_options INTERFACE ${stdlib_flag} -fno-inline-function # 3) custom function that is used instead of target_sources and sets flags # for each added source based on file extension +separate_arguments(EXTRA_CFLAGS_AS_LIST NATIVE_COMMAND ${EXTRA_CFLAGS}) + # No space between -imacros and its argument to avoid CMake # de-duplication "feature" target_compile_options(sof_options INTERFACE @@ -129,6 +131,7 @@ target_compile_options(sof_options INTERFACE -Wmissing-prototypes -Wpointer-arith ${XTENSA_C_FLAGS} + ${EXTRA_CFLAGS_AS_LIST} > -imacros${CONFIG_H_PATH} )