Building with CMake?

Post here first, or if you can't find a relevant section!
Post Reply
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Building with CMake?

Post by MGeo »

I've got Arduino IDE 1.8.19 with STM32Duino V2.7.1 installed, on Ubuntu 22.04.

I'd like to get CMake build up and running. I've downloaded CMake_workspace examples to my sketch folder. 1_Blink example compiles no problem in IDE using a NUCLEO_F401RE target.

Next, I've been following the instructions README_CMAKE.md at https://github.com/stm32duino/Arduino_C ... E_CMAKE.md

I've installed Prerequisites. In a terminal:
cmake --version gives 'cmake version 3.22.1'
python3 --version gives 'Python 3.10.12'
make --version gives 'GNU Make 4.3'
Python modules: graphviz, jinja2; install with pip install ...

I then go to my sketchbook folder where I put the CMake_workspace examples and open a terminal. I get a CMake error that CMake cannot find the toolchain file. I'm sure I'm missing some obvious step but have tried following the instruction in the README twice and get the same error.

Can someone help me out with what I am missing? Perhaps the README makes assumptions on where things are installed that I do not match on my machine?

Thanks,
George

Code: Select all

cmake -S ./1_Blink -B ./1_Blink/build

CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:130 (message):
  Could not find toolchain file: toolchain
Call Stack (most recent call first):
  CMakeLists.txt:14 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

by MGeo » Fri Jan 26, 2024 10:01 am
Thanks. Installing arduino-cli and rerunning CMake gave the same error.

After more time on Google I came across this https://github.com/orgs/stm32duino/disc ... nt-6414073

Where CMakeFile.txt line is edited to point to local install location.

Code: Select all

file(REAL_PATH "~/AppData\\Local\\Arduino15\\packages\\STMicroelectronics\\hardware\\stm32\\2.6.0" CORE_PATH EXPAND_TILDE)
The examples assume a location:

Code: Select all

file(REAL_PATH "~/Arduino_Core_STM32" CORE_PATH EXPAND_TILDE)
After editing this line in sketch CMakeFile.txt things work as expected. Probably obvious to someone more experienced in CMake than me.
Go to full post
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Building with CMake?

Post by fpiSTM »

You should have arduino-cli installed to be able to retreive info from the installed core:
https://github.com/stm32duino/Arduino_C ... rduino-cli
MGeo
Posts: 38
Joined: Thu Dec 19, 2019 10:29 am
Answers: 2

Re: Building with CMake?

Post by MGeo »

Thanks. Installing arduino-cli and rerunning CMake gave the same error.

After more time on Google I came across this https://github.com/orgs/stm32duino/disc ... nt-6414073

Where CMakeFile.txt line is edited to point to local install location.

Code: Select all

file(REAL_PATH "~/AppData\\Local\\Arduino15\\packages\\STMicroelectronics\\hardware\\stm32\\2.6.0" CORE_PATH EXPAND_TILDE)
The examples assume a location:

Code: Select all

file(REAL_PATH "~/Arduino_Core_STM32" CORE_PATH EXPAND_TILDE)
After editing this line in sketch CMakeFile.txt things work as expected. Probably obvious to someone more experienced in CMake than me.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Building with CMake?

Post by fpiSTM »

Right. Anyway using arduino cli avoid issue. It have to be in the path to be used by cmake.
Post Reply

Return to “General discussion”