patrislav1 / cubemx.cmake

Script collection to build CubeMX projects with CMake and debug them with VSCode
The Unlicense
34 stars 10 forks source link

CMake error: CubeMX startup file not found #16

Closed luverolla closed 6 months ago

luverolla commented 6 months ago

I have generated a CubeMX project, called demo-mx, and the startup file is correctly present at the root directory. In my case, using an STM32F401RE, the startup file is startup_stm32f401xe.s. But, when trying to build with CMake this error is thrown:

[cmake] CMake Error at cubemx.cmake/cubemx.cmake:85 (message):
[cmake]   CubeMX startup file not found!

I followed all the steps under "How to use section", and below are attached the source tree and the content of the CMakeLists.txt file

Screenshot 2024-02-09 103429
cmake_minimum_required(VERSION 3.16)

# Possible values: openocd, pyocd, stlink, blackmagic. stlink is default
set(CMX_DEBUGGER "stlink")
# set(OPENOCD_CFG "${CMAKE_CURRENT_SOURCE_DIR}/openocd.cfg")

include(cubemx.cmake/cubemx.cmake)

# cross compilation
set(TOOLCHAIN_PATH  "C:\\ST\\STM32CubeCLT\\GNU-tools-for-STM32\\bin\\")
set(CMAKE_ASM_COMPILER  ${TOOLCHAIN_PATH}arm-none-eabi-gcc)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")

project(demo-mx)

add_executable(demo-mx Core/Src/*.c)
cubemx_target(
    TARGET demo-mx
    IOC "${CMAKE_CURRENT_LIST_DIR}/demo-mx.ioc"
)
target_compile_options(demo-mx PRIVATE -Og -Wpedantic -Wall -g -gdwarf-2)

# Depending on the project setup, sometimes one of these symbols must be omitted. (Cannot be reliably determined from the .ioc file)
target_compile_definitions(demo-mx PRIVATE USE_FULL_LL_DRIVER USE_HAL_DRIVER)
BenBE commented 6 months ago

Can you run cmake in trace mode and post a log of the call to add_startup (no need for the full log as that section should suffice).

Workaround: You can provide the STARTUP parameter to the cubemx_target invocation which will override the auto-detection.

Nonetheless it'd be nice to see, why this currently breaks for you.

patrislav1 commented 6 months ago

Workaround: You can provide the STARTUP parameter to the cubemx_target invocation which will override the auto-detection.

see also caveats (2nd point)

luverolla commented 6 months ago

I also tried the solution proposed in the caveats section with no result. But then I noticed I made a typo in the target definition. Now everything works correctly. Thank you two both anyway for your help.