cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE CMake integration

rwx
Associate III

Since it took a tremendous amount of effort in getting CMake working within STM32CubeIDE, I'd thought I'd share a method of getting it done. I've only tested this working in Windows. Many an hour could have been saved if ST, in their infinite wisdom, did not disable the Toolchain tree entry in the project C/C++ properties!

Disclaimer: I'm not an experienced Eclipse user, so there is a very good chance that the steps below are not the correct way of doing things, and in future, ST might lock-down or hide more UI rendering these steps useless - you have been warned!

There are a huge number of steps required, so this is not for the fainthearted!

Prerequisite: You must have an existing CMake GNU Arm project up and running, if not, find out how set one up, or use CLion to create a CMake project from an existing STM32CubeMX .ioc.

For the steps, I'm using the following folder layout (adjust to fit your preferences):

Source (source code, folders, etc)
  build
    .. this where I set CMake to run the builds..
  cmake
    gnu-arm-stm32.cmake
  ...
  CMakeLists.txt
Tools
  STM32CubeIDE
    MyProject (the skeleton project created in the below steps)
      .cproject
      .project
  svd
    STM32F446.svd
 

 Matthew.

16 REPLIES 16

Hi @xlrl​ ,

It is recommended to describe the issue you are currently facing in a new post.

Any way I add our STM32CubeIDE expert in the loop in order to update us on the status of the CMake integration with latest IDE release @Semer CHERNI​ .

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Okay, understand. Thanks! I created a new question.

-Alex

jerry_sandc
Associate III

Seems like CMake is now integrated with CubeIDE, making this thread irrelevant ?

 

I follow this steps but I cannot find CMAKE_EXPORT_COMPILE_COMMANDS Compiler Built-ins in Provider.

Could anyone help me? thanks

have you seen this page yet?  I take a very different approach to cmake with STM32

https://community.st.com/t5/stm32cubeide-mcus/my-solution-for-building-project-for-stm32f7-evaluation-board/m-p/594258

This solution did not work. I just upgraded to STMCubeIDE 1.16.1. It is the

21st October 2024.

I got the following error. Also, a few things could not be completed as shown.

 

19:22:51 Buildscript generation: DevHeadsFreeRTOS::Debug in D:\Documents\STM32CubeIDE\workspace\DevHeadsFreeRTOS\build\cmake-cubeide-Debug

cmake -DCMAKE_BUILD_TYPE:STRING=Debug -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON "D:\\Documents\\STM32CubeIDE\\workspace\\DevHeadsFreeRTOS"

CMake Warning:

Ignoring extra path from command line:

 

"D:\Documents\STM32CubeIDE\workspace\DevHeadsFreeRTOS"

 

 

CMake Error: The source directory "D:/Documents/STM32CubeIDE/workspace/DevHeadsFreeRTOS" does not appear to contain CMakeLists.txt.

Specify --help for usage, or press the help button on the CMake GUI.

 

Here the instructions led to the workspace directory being used for the source directory.

The sources are there also. But the CMakeLists.txt file is in the sources directory

somewhere else, which was specified.

- D:\Documents\Embedded Systems\IoT\DevHeadsDiscord\FreeRTOS\FreeRTOS_samples-main

 

By going through this again I could specify the actual sources directory again but

the error was the same.

 

A few other details are not as they are explained in the IDE:

 

Requires: STM32CubeIDE 1.5.0+, CMake and Ninja-build installed

- Ninja-build gives Cmake4eclipse in Eclipse Market place. - is installed

Switch indexer to use CMake providers

  • Project > Properties > C/C++ General > Indexer
    • Restore defaults
    • Apply
  • Project > Properties > C/C++ General > Preprocessor include paths... > Providers
    • Deselect all current providers
    • Select
      • CMAKE_EXPORT_COMPILE_COMMANDS Compiler Built-ins -- These two entries are missing
      • CMAKE_EXPORT_COMPILE_COMMANDS Parser
    • Apply
    • Repeat for all other configurations
  • Apply and close

--> I only have the entry - CMake Compilation DB - which I selected

Add root source code folder containing CMakeLists.txt

  • Delete all the project folders and files (except Includes) - this is unclear - so not done
  • New > Folder
    • Advanced > Link to alternate location > Browse : Choose folder which holds the existing CMakeLists.txt (Source)
    • Finish
  • Project > Properties > Resource > Linked resources > Linked Resources: Convert linked source root to relative

The last step was done - 

- D:\Documents\Embedded Systems\IoT\DevHeadsDiscord\FreeRTOS\FreeRTOS_samples-main

Configure CMake settings

  • Project > Properties > C/C++ Build > Cmake4eclipse
  • Configuration: [ All configurations ]
  • Build output folder: set path (ie, Source/build/cmake-cubeide-${ConfigName} )
  • Apply
  • Configuration: Debug
    • Cmake4eclipse > Symbols -- This field does not exist - maybe under Environment - I set vars there
      • Set symbols (use your toolchain file here and any needed settings), ie:
        • CMAKE_TOOLCHAIN_FILE:FILEPATH = ../cmake/gnu-arm-stm32.cmake
        • CMAKE_BUILD_TYPE:STRING = Debug
      • Apply
    • Cmake4eclipse > Host OS overrides > Windows -- this does not exist
      • Buildscript generator: Ninja
      • Apply
  • Configuration: Release
    • Cmake4eclipse > Symbols -- same as above
      • Set symbols (use your toolchain file here and any needed settings), ie:
        • CMAKE_TOOLCHAIN_FILE:FILEPATH = ../cmake/gnu-arm-stm32.cmake
        • CMAKE_BUILD_TYPE:STRING = RelWithDebInfo
      • Apply
    • Cmake4eclipse > Host OS overrides > Windows -- This doesn't exist
      • Buildscript generator: Ninja
      • Apply
  • Apply and close

 

CMake Error: The source directory "D:/Documents/STM32CubeIDE/workspace/DevHeadsFreeRTOS" does not appear to contain CMakeLists.txt.

 

You have to run the cmake command in the folder with the CMakeLists.txt