ryankurte / efm32-base

Base project for Silicon Labs EFM32 microcontrollers
89 stars 33 forks source link

How do we pass in definitions and flags to our projects and the MCU SDK? #15

Open david-perez opened 4 years ago

david-perez commented 4 years ago

This is a question. I'm using the project as a submodule (so I don't want to alter any files from it).

I'd like to define some symbols (-DARM_MATH_CM4=1) and flags (-mfpu=fpv4-sp-d16 -mfloat-abi=hard) that are used by the MCU SDK (e.g. in CMSIS) to enable use of the FPU unit found in some boards. How can I pass them to both my project's source files and the MCU SDK?

I'm currently using cmake -DCMAKE_BUILD_TYPE=Release -DOPTIONAL_DEBUG_SYMBOLS="-DARM_MATH_CM4=1 -mfpu=fpv4-sp-d16 -mfloat-abi=hard" .. and it seems to be working, but I don't think OPTIONAL_DEBUG_SYMBOLS from toolchain/efm32-base.cmake is meant to be used for these purposes.

ryankurte commented 4 years ago

my usual approach with submoduling is to copy CMakeLists.txt into the top level project where you rename / do whatever you need to for your project, and in that file you can set(X y) whatever you need, so you don't have to pass anything in to the cli invocation.

It looks like OPTIONAL_DEBUG_SYMBOLS is the best place for these to be propagated at the moment, and since there are no other references to this perhaps it could be renamed to something more indicative of it's utility.

that said, these seem like features that could perhaps be configured for a given device here? afaik it should be CPU rather than board dependent?

david-perez commented 4 years ago

It looks like OPTIONAL_DEBUG_SYMBOLS is the best place for these to be propagated at the moment, and since there are no other references to this perhaps it could be renamed to something more indicative of it's utility.

Yes, the name threw me off. Shall we rename it to e.g. ADDITIONAL_SYMBOLS_AND_FLAGS?

that said, these seem like features that could perhaps be configured for a given device here? afaik it should be CPU rather than board dependent?

Yes, these are CPU dependent. I'm not sure about explicitly supporting these definitions and flags by activating them with a variable to enable FPU support, a user might want some other combination. I think just letting them have a placeholder to define additional symbols and flags is flexible and does the job.

ryankurte commented 4 years ago

Hey sorry for the delay

Shall we rename it to e.g. ADDITIONAL_SYMBOLS_AND_FLAGS?

Something like this seems good to me! maybe OPTIONAL_DEFINITIONS or ADDITIONAL_DEFINITIONS to be in line with cmake's add_definitions()?

(also in re-reading this I realise add_definitions(-DARM_MATH_CM4=1 -mfpu=fpv4-sp-d16 -mfloat-abi=hard) in the CMakeLists.txt file should also achieve what you need)

I think just letting them have a placeholder to define additional symbols and flags is flexible and does the job.

Yeah fair point