# Generator for eclipse plugin for stm32 microcontrollers

**URL:** https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667
**Category:** Development
**Created:** [August 4, 2020, 5:33pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667 "2020-08-04T17:33:08Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![dudmuck](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@dudmuck](https://discourse.cmake.org/u/dudmuck)
#### Post date: [August 4, 2020, 5:33pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/1 "2020-08-04T17:33:08Z")

</div>

I’m looking into creating a new generator.

I’m able too see the Name given to add\_custom\_target from target-\>GetName(), and  
the target type is cmStateEnums::UTILITY. I am able to see the full path of generated file by calling target-\>GetSourceFiles() then cmSourceFile.ResolveFullPath(), i see one output file and one .rule.

However, I cannot figure out how to retrieve the COMMAND portion of add\_custom\_target given in the cmake file.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 4, 2020, 6:01pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/2 "2020-08-04T18:01:29Z")

</div>

For what build system is your new generator?

---

<div class="post-metadata">

### Author: ![dudmuck](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@dudmuck](https://discourse.cmake.org/u/dudmuck)
#### Post date: [August 4, 2020, 11:03pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/3 "2020-08-04T23:03:25Z")

</div>

Its a generator similar to Eclipse CDT4.  
This generator is for eclipse plugin for stm32 microcontrollers at [openstm32.org](http://openstm32.org)  
The .project and .cproject are the same type of XML, but generated specifically for this cross-compiler plugin for stm32.

I have it basically working, meaning the eclipse plugin is able to build the cmake generated project, but the post build steps are given in add\_custom\_target in cmake file. It should also work for stm32CubeIDE, since that imports these types of projects.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 5, 2020, 12:49pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/4 "2020-08-05T12:49:42Z")

</div>

CMake’s Eclipse CDT4 generation support is an “extra generator” that doesn’t actually provide the build system. The build system is still expressed as Makefiles and the CDT4 project files are just for viewing. The Makefiles have all the compiler, linker, and custom commands. It is not a good example for how to write a full generator.

Does the stm32 cross-compiler only work under the Eclipse plugin or can it work independently and you’re just trying to integrate with an IDE?

---

<div class="post-metadata">

### Author: ![15knots](https://discourse.cmake.org/user_avatar/discourse.cmake.org/15knots/32/188_2.png) [@15knots](https://discourse.cmake.org/u/15knots)
#### Post date: [August 5, 2020, 6:06pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/5 "2020-08-05T18:06:53Z")

</div>

The generated .cproject might not work with recent versions of CDT. See [https://bugs.eclipse.org/bugs/show\_bug.cgi?id=530090#c5](https://bugs.eclipse.org/bugs/show_bug.cgi?id=530090#c5)

Martin

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 5, 2020, 6:22pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/6 "2020-08-05T18:22:02Z")

</div>

The path forward for Eclipse to provide an IDE experience for CMake projects is [Eclipse Issue 545905](https://bugs.eclipse.org/bugs/show_bug.cgi?id=545905) to add support for CMake’s [file-api](https://cmake.org/cmake/help/v3.18/manual/cmake-file-api.7.html). The file-api has superseded the old “extra genrator” approach.

---

<div class="post-metadata">

### Author: ![dudmuck](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@dudmuck](https://discourse.cmake.org/u/dudmuck)
#### Post date: [August 6, 2020, 2:02am UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/7 "2020-08-06T02:02:50Z")

</div>

I am only using eclipse CDT generator as an example. I did notice myself that it goes crazy with indexing subprojects.  
I currently have my generator basically working using the extra generator approach, but i would move to file-api, if there is an example. .

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 6, 2020, 12:22pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/8 "2020-08-06T12:22:17Z")

</div>

The file-api is meant for _external tooling_ to access CMake’s codemodel for IDEs. There are no file-api clients in CMake itself, except for the test suite. It is also not sufficient for actually building the project.

I’m still trying to understand what you’re trying to accomplish. Does the stm32 compiler work with the Ninja or Makefile generators or not?

---

<div class="post-metadata">

### Author: ![dudmuck](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@dudmuck](https://discourse.cmake.org/u/dudmuck)
#### Post date: [August 6, 2020, 3:42pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/9 "2020-08-06T15:42:39Z")

</div>

the stm32 compiler works fine with unix makefile generator. Its actually called gcc-arm. It behaves just like gcc, it just cross compiles for arm.

The purpose of another generator is that some users want the IDE, because it provides the compiler, debugger, make, and all the tools.

Also, the microcontroller vendor makes a separate copy of IDE project files for every combination of hardware boards and software application, and cmake would generate the project for them, instead of manually creating IDE project files for infinite number of hardware + software combinations.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 7, 2020, 12:51pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/10 "2020-08-07T12:51:18Z")

</div>

> The purpose of another generator is that some users want the IDE

The purpose of the file-api is to offer IDEs a way to integrate with CMake build trees using any generator, including Makefiles and Ninja.

> every combination of hardware boards and software application, and cmake would generate the project for them

CMake doesn’t support more than one target architecture in a single build tree.

---

<div class="post-metadata">

### Author: ![dudmuck](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@dudmuck](https://discourse.cmake.org/u/dudmuck)
#### Post date: [August 11, 2020, 3:48pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/11 "2020-08-11T15:48:16Z")

</div>

ok, thats all good.

Just one thing i’ve noticed with file-api.  
There are command fragments for target with target type is OBJECT\_LIBRARY or EXECUTABLE.  
But when type is UTILITY, no fragments are present in json reply.

cmake script can have add\_custom\_target() with COMMAND, then target type is utility for this target, and there should be fragments present from whatever command was given.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 11, 2020, 6:25pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/12 "2020-08-11T18:25:15Z")

</div>

> [@dudmuck](#):
>
> But when type is UTILITY, no fragments are present in json reply.

See [CMake Issue 20463](https://gitlab.kitware.com/cmake/cmake/-/issues/20463).

---

<div class="post-metadata">

### Author: ![mdma](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mdma/32/2082_2.png) [@mdma](https://discourse.cmake.org/u/mdma)
#### Post date: [January 7, 2022, 12:15am UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/13 "2022-01-07T00:15:52Z")

</div>

Were you able to get the STM32CubeIDE generator working? I’d love to be able to create STM32CubeIDE projects from CMake files 🙂

---

<div class="post-metadata">

### Author: ![Wayne\_Roberts](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wayne_roberts/32/2084_2.png) [@Wayne\_Roberts](https://discourse.cmake.org/u/Wayne_Roberts)
#### Post date: [January 7, 2022, 2:24am UTC](https://discourse.cmake.org/t/generator-for-eclipse-plugin-for-stm32-microcontrollers/1667/14 "2022-01-07T02:24:50Z")

</div>

yes here [GitHub - dudmuck/cmake\_ide\_generator: create IDE project files from cmake](https://github.com/dudmuck/cmake_ide_generator)

in hindsight, its probably easier to do that using jinja with python. But for now it makes easier for people who dont want to install python (non linux users)
