Hello all, I am evaluating the mbed-cmake toolset (GitHub - USCRPL/mbed-cmake: Use the power of CMake to create your MBed applications) and I have successfuly compiled the hello_world program on different targets, next step is to follow the process to use custom targets. I have decided to use a very simple way to try it out. I copied the current target TARGET_NUCLEO_G474RE into the mbed-cmake-example-project directory and renamed it to TARGET_NUCLEOS_G474RE, I changed the CMakeLists into this directory in that way:
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(mbed-nucleos-g474re INTERFACE)
target_sources(mbed-nucleos-g474re
INTERFACE
PeripheralPins.c
)
target_include_directories(mbed-nucleos-g474re
INTERFACE
.
)
target_link_libraries(mbed-nucleos-g474re INTERFACE mbed-stm32g474xe)
I created a custom_targets.json in same directory as follows (I took same json portion from the targets.json for this board):
{
"NUCLEOS_G474RE": {
"inherits": [
"MCU_STM32G474xE"
],
"supported_form_factors": [
"ARDUINO_UNO"
],
"overrides": {
"hse_value": 24000000
},
"detect_code": [
"0841"
],
"device_name": "STM32G474RETx"
}
}
Next I executed the following commands:
python3 mbed-cmake/configure_for_target.py -a mbed_app.json -i .mbedignore -x C:\Mbed-Cmake\mbed_ws\mbed-cmake-example-project\TARGET_NUCLEOS_G474RE NUCLEOS_G474RE
create a build directory , enter into it
cmake --fresh "-G Ninja" C:\Mbed-Cmake\mbed_ws\mbed-cmake-example-project -DUPLOAD_METHOD=STM32CUBE
ninja -j2 hello_world
And this error appears …
In file included from C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/mbed-cmake/mbed-src/targets/TARGET_STM/device.h:38,
from C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/mbed-cmake/mbed-src/platform/include/platform/platform.h:28,
from c:\mbed-cmake\mbed_ws\mbed-cmake-example-project\mbed-cmake\mbed-src\mbed.h:40,
from C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/HelloWorld.cpp:1:
C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/mbed-cmake/mbed-src/targets/TARGET_STM/TARGET_STM32G4/objects.h:22:10: fatal error: PinNames.h: No such file or directory
22 | #include "PinNames.h"
| ^~~~~~~~~~~~
compilation terminated.
[7/262] Building C object mbed-cmake/mbed-src/CMakeFiles/mbed-os-static.dir/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Library/cmsis_os1.c.obj
ninja: build stopped: subcommand failed.
The file structure is as follows:
mbed-cmake-example-project
|
---build
---cmake
---mbed-cmake
---mbed-cmake-config
---TARGET_NUCLEOS_G474RE
---CMakeLists
---custom_targets
---PeripheralPins
---PinNames
---.gitignore
---.gitmodules
---.mbedignore
---CMakeLists
---HelloWorld
---mbed_app
---README
I have tried to follow the documentation but probably I missed something, any idea?
Thank you very much