diff options
| author | Angus Gratton <angus@redyak.com.au> | 2025-02-11 17:44:19 +1100 |
|---|---|---|
| committer | Angus Gratton <angus@redyak.com.au> | 2025-02-18 12:09:23 +1100 |
| commit | 516709be88571da0195125c840e772a3ec70fa66 (patch) | |
| tree | bc893b43850179d769c7760473308be8ef059a3e /py | |
| parent | 71df9d0636c8b0b95ab009f82bde7d5b970835ec (diff) | |
py/mkrules.cmake: Support passing CFLAGS_EXTRA in environment variable.
This works similarly to the existing support in "bare metal" make ports,
with the caveat that CMake will only set this value on a clean build and
will reuse the previous value otherwise.
This is slightly different to the CMake built-in support for CFLAGS,
as this variable is used when evaluating source files for qstr
generation, etc.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'py')
| -rw-r--r-- | py/mkrules.cmake | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/py/mkrules.cmake b/py/mkrules.cmake index 3ee4c4c31..907500dd6 100644 --- a/py/mkrules.cmake +++ b/py/mkrules.cmake @@ -53,6 +53,15 @@ foreach(_arg ${MICROPY_CPP_DEF}) endforeach() list(APPEND MICROPY_CPP_FLAGS ${MICROPY_CPP_FLAGS_EXTRA}) +# Include anything passed in via CFLAGS_EXTRA +# in both MICROPY_CPP_FLAGS and CMAKE_C_FLAGS +if(DEFINED ENV{CFLAGS_EXTRA}) + set(CFLAGS_EXTRA $ENV{CFLAGS_EXTRA}) + string(APPEND CMAKE_C_FLAGS " ${CFLAGS_EXTRA}") # ... not a list + separate_arguments(CFLAGS_EXTRA) + list(APPEND MICROPY_CPP_FLAGS ${CFLAGS_EXTRA}) # ... a list +endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) target_sources(${MICROPY_TARGET} PRIVATE |
