How do I select the target MCU from mbed cli?

I have a project I have inherited but I’m using a different board target but the same MCU target. I’m stuck with MBedOS 5.12 and MBedCLI. Here’s the build command from my Makefile:
mbed compile --build $(OUTDIR) $(VERBOSE) --app-config $(APP_CONFIG) -N $(CURDIR) $(DEFINES)

I have come into a situation where I would like modify my hardware configuration for some manufacturing tests so I would like to support two targets in the same project.

The project uses the .mbed file at the root directory, as near as I can tell, to select the target. I changed the TARGET= value to match my target. Everything seems to be working find and the correct macros are defined from the targets.json file.

Can I set TARGET in the my app config .json file? I like this option because it just seems like a nice way to set things up.

Does mbed compile give precedence to the --target command line switch or a key in the .mbed file? Or is --target used to select the MCU, not the target which inherits from an MCU?

Where is the use of the .mbed file described?

Can you point me to the documentation that discusses selecting the target?

I’ve read the MBedOS documentation that discusses how to add targets to the targets.json file but I can’t find documentation that says how to select the target in the config .json files. It is inferred by introducing the --target switch to mbed compile but again, not sure if --target is the MCU or the board. I’m wondering about a config file and just more general documentation on the subject.

I have since realized that the .mbed file is used by mbed config and mbed target and I can in fact set the TARGET= to my board (as opposed to MCU).

I think --target on the mbed compile is the MCU and so is the same thing. Can someone confirm?

With that information in hand, I have created a Make rule that runs an mbed target command to set my target.

Seems kinda hacky but it’ll work lacking something more elegant. Certainly, it isn’t much better than just running the mbed target command but I have two applications for my PSOC6 – one for the CM0+ processor and one for the CM4 processor. Also, I will pass this on to others so this is probably easier to remember for someone who didn’t write it.

Now I’m getting “Could not compile for : No Linker Script found” but I can’t find anything useful about it through an Internet search.

Turns out I was missing a directory for my MCU target.