elmot / clion-embedded-arm

OpenOCD + STM32CubeMX support for CLion
https://blog.jetbrains.com/clion/2017/12/clion-for-embedded-development-part-ii
Other
170 stars 29 forks source link

Document how to switch to a C++ Project #117

Closed johnthagen closed 6 years ago

johnthagen commented 6 years ago

It would be helpful if it were documented what needed to be done to switch to a C++ program.

From what I've read, renaming main.c to main.cpp is important, but beyond that I'm unsure what additional CMake changes need to be made to get everything (especially the STM32 HAL) to play nicely together.

For example, after making this change I seem to get linker issues building for the STM32F3DISCOVERY:

...
CMakeFiles/Project.elf.dir/startup/startup_stm32f303xc.s.obj: In function `LoopFillZerobss':
Project/startup/startup_stm32f303xc.s:111: undefined reference to `main'
elmot commented 6 years ago

@johnthagen thanks for the idea Here is a small but working example Documentation is not written yet. Note the major part of the project is in C, and some classes are used to control LEDs.

johnthagen commented 6 years ago

@elmot Thanks! What do you think of #118? It seems to be working for me so far.

Key to that was adding CXX to:

PROJECT(${projectName} C ASM)