Skip to main content
Mohamed_BACHOUCH
ST Employee
Apr 14, 2026 2:03 PM UTC

How to import a STM32CubeMX2 CMake project into STM32CubeIDE

Summary

This guide explains how to take an existing STM32CubeMX2 project, generate a CMake project from it, and then import it into STM32CubeIDE.

Prerequisites

1. Generate a CMake project from STM32CubeMX2

  1. Create an STM32CubeMX2 .ioc project.
  2. In Project Manager → IDE Project (IDE Project Generation area), set:
    • Format: CMake
    • CMake toolchain: GCC
    • Destination: a folder where the CMake project should generate.
  3. Click Generate IDE project.

When generation completes, verify that the destination folder contains:

  • CMakeLists.txt
  • Core/, Drivers/, and other generated folders.
  • The .ioc file.

Figure 1. IDE project generationFigure 1. IDE project generation

 

2. Open the STM32CubeMX2 CMake project in STM32CubeIDE

  1. Launch STM32CubeIDE V2.1.1 and select your workspace.
  2. From the main menu, choose:
    [File] → [New] → [STM32 Project] → [STM32 Project Create/Import].
    Select [STM32CubeMX2 project] under [Create New STM32 Project].

Figure 2. Import STM32 projectFigure 2. Import STM32 project

 

 

Figure 3. Import STM32CubeMX2 projectFigure 3. Import STM32CubeMX2 project

3. Point the project to the existing CMake sources

You are now on the Project with existing CMake sources page. Fill in the fields as follows:

  • Project name
    Enter a name for your STM32CubeIDE project.
  • Source directory
    Click [Browse...], and select the folder generated in section 1.

Figure 4. Point the project to the existing CMake sourcesFigure 4. Point the project to the existing CMake sources

4. Configure the toolchain and MCU

The wizard opens the "Configure default tool‑chain settings for the project" page.

  1. Configure:
    • Toolchain: MCU ARM GCC (or matching your setup).
    • MCU: Select the same device as in the STM32CubeMX2 project.
    • Example used: STM32C562VETx.
  2. Click Finish.

Figure 5. Configure the toolchain and MCUFigure 5. Configure the toolchain and MCU

5. Build and use the imported project

In "Project Explorer", the new STM32 CMake project should be visible:

  • CMakeLists.txt at the root.
  • Core/, Drivers/, and other generated folders.

[Right‑click] the project → [Build Project].

STM32CubeIDE runs CMake, configures the build system, and compiles the code.

Related links

5 replies

Associate III
Apr 17, 2026 9:32 AM UTC

Minor typo in section 4. The image show STM32C562VETx and the description says "Example used: STM32C562RETx"

Laurids_PETERSEN
ST Community Manager
Apr 20, 2026 11:32 AM UTC

Thanks for catching that @Tom_pm. I have updated the article accordingly.

Visitor II
Jun 15, 2026 1:40 AM UTC

I am getting the following error in Build Project. Is there any way to fix it?

 

CMake Error at cmake/components.cmake:41 (target_link_libraries):

Error evaluating generator expression:

 

$<QUOTE>

 

Expression did not evaluate to a known generator expression

Call Stack (most recent call first):

CMakeLists.txt:15 (include)

MikaelM
ST Employee
Jul 16, 2026 8:49 AM UTC

hello ​@saakiyama ,
You need to use cubeIde V2.1.1 min version,
Thanks

If you feel a post has answered your question, please click Accept as Solution.
Explorer
Oct 21, 2026 2:23 PM UTC

how do you generate the Core and Driver folders? and how do you move the main.c and main.h folder to a subdirectory like in the stm32Cubemx? I cant seem to find those options. while they are needed in bigger projects.