Skip to content

Add CMake build files#101

Open
rhgndf wants to merge 4 commits intoskuep:masterfrom
rhgndf:cmakefile
Open

Add CMake build files#101
rhgndf wants to merge 4 commits intoskuep:masterfrom
rhgndf:cmakefile

Conversation

@rhgndf
Copy link
Copy Markdown
Contributor

@rhgndf rhgndf commented Jan 9, 2025

Allows building with cmake instead, so there is no need to install STM32CubeIDE to build the project. The CMakeLists.txt are generated from creating a STM32 project in STMCube32IDE.

Build commands:

cmake -DCMAKE_TOOLCHAIN_FILE=cubeide-gcc.cmake  -S ./ -B Release -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
make -C Release VERBOSE=1 -j $(nproc)

Replace Release with Debug for debug build.

@das-Iro
Copy link
Copy Markdown

das-Iro commented Jan 9, 2025

I have tested compiling on macOS 15.2 & Archlinux
Release works 👍 (flashed file from macOS compile and tested audio input to verify function)
Debug seems broken in linking step (both systems, same error)

  • undefined reference to `_sbrk'

Side node to -j will spawn an unlimited amount of jobs which may result in out of memory situations, I recommend -j 8

@skuep
Copy link
Copy Markdown
Owner

skuep commented Jan 9, 2025

I don't really use the Debug build, but you're right, it shouldn't be broken.

Thanks for the contribution, will take me some time to look at it

@das-Iro
Copy link
Copy Markdown

das-Iro commented Jan 9, 2025

I don't really use the Debug build, but you're right, it shouldn't be broken.

Neither do I so no hurry.

@rhgndf
Copy link
Copy Markdown
Contributor Author

rhgndf commented Jan 9, 2025

Same error with Release builds, but it was fixed with:

  • Removing ${RUNTIME_LIBRARY} from CMAKE_C_FLAGS
  • Removing ${RUNTIME_LIBRARY_SYSCALLS} from CMAKE_EXE_LINKER_FLAGS

@rhgndf
Copy link
Copy Markdown
Contributor Author

rhgndf commented Jan 10, 2025

Side node to -j will spawn an unlimited amount of jobs which may result in out of memory situations, I recommend -j 8

Fixed!

@skuep
Copy link
Copy Markdown
Owner

skuep commented Sep 25, 2025

I don't really work with CMake, but am I right in the assumption, that I need to adjust the CMakeLists.txt everytime I add files to the project in the future?

Does this have any usage in combination with STMCubeIDE or is it just for building without it?

Btw, I think there is a $ missing: https://github.com/skuep/AIOC/pull/101/files#diff-1633612828a396f218b1b411fa1630102f089b6e386fad0823638b988bf7b69dR15

@rhgndf
Copy link
Copy Markdown
Contributor Author

rhgndf commented Sep 27, 2025

I don't really work with CMake, but am I right in the assumption, that I need to adjust the CMakeLists.txt everytime I add files to the project in the future?

Yes, the CMakeLists.txt needs to be updated, although if you are concerned about this, CMake can automatically add all files matching a pattern like '*.c' to the build if needed.

Does this have any usage in combination with STMCubeIDE or is it just for building without it?

This is just for building without it. I use it with vscode IDE which I think has a better interface than stm32cubeide since it has features like finding definitions and declaration of functions and structs and integration with git.

Btw, I think there is a $ missing: https://github.com/skuep/AIOC/pull/101/files#diff-1633612828a396f218b1b411fa1630102f089b6e386fad0823638b988bf7b69dR15

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants