Skip to main content
ADovn.1
Associate II
Apr 3, 2020 7:53 AM UTC
Solved

Is it possible to have CubeIDE project with multiple main functions?

I have a project which uses multiple identical boards and needs them to have slightly different firmware. So I thought that having a folder for each firmware with its own main function in one project will be efficient because all boards will use the same libraries and I won't need to maintain multiple projects at one time. 

So is it possible to set up a project with multiple main functions in Cube IDE? If yes, how I can do it?

This topic has been closed for replies.
berendi
berendiBest answer
Principal
Apr 3, 2020 10:02 AM UTC

You can create multiple configurations under Project / Build Configurations / Manage. Each configuration has its own set of project settings, so you can e.g. define preprocessor symbols to activate some #ifdef in the code, or exclude entire files or directories from build.

Another way is to create sub-projects within a project. Create the main project without a target, new projects for each configuration inside the main project folder, and additional directories for common code. CubeMX uses this approach to manage dual core MCUs, you might want to create a dummy project for a STM32H745 to see how does it look like.

2 replies

berendi
berendiBest answer
Principal
Apr 3, 2020 10:02 AM UTC

You can create multiple configurations under Project / Build Configurations / Manage. Each configuration has its own set of project settings, so you can e.g. define preprocessor symbols to activate some #ifdef in the code, or exclude entire files or directories from build.

Another way is to create sub-projects within a project. Create the main project without a target, new projects for each configuration inside the main project folder, and additional directories for common code. CubeMX uses this approach to manage dual core MCUs, you might want to create a dummy project for a STM32H745 to see how does it look like.

ADovn.1
ADovn.1Author
Associate II
Apr 3, 2020 11:00 AM UTC

Thanks a lot, I tried the first method, it is working as I desired.