cancel
Showing results for 
Search instead for 
Did you mean: 

How to integrate CMSIS-DSP libraries on a CMake STM32 project

sanmveg
Associate

Hello all

I am trying to integrate CMSIS-DSP in my CMake project. From CubeMX, I have the following options:

sanmveg_0-1749869209863.png

and I see the following folder struct:

sanmveg_1-1749869245284.png

and to include DSP folder in my project, I have done the following changes in my top level CMakeLists.txt

.... some code 

# Enable CMake support for ASM and C languages
enable_language(C ASM)

# Create an executable object type
add_executable(${CMAKE_PROJECT_NAME})

# Add STM32CubeMX generated sources
add_subdirectory(cmake/stm32cubemx)
add_subdirectory(Drivers/CMSIS/DSP/Source)

# Link directories setup
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
    # Add user defined library search paths
)

# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
    # Add user sources here
    ${CMAKE_SOURCE_DIR}/Core/Src/tm1638.c
)

# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
    # Add user defined include paths
    # Include CMSIS core headers
    ${CMAKE_SOURCE_DIR}/Drivers/CMSIS/Include
    ${CMAKE_SOURCE_DIR}/Drivers/CMSIS/DSP/Source
)

# Add project symbols (macros)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
    # Add user defined symbols
)

# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME}
    stm32cubemx
    
    # Add user defined libraries
    CMSISDSP
)

..... more code

 

However, while performing add_directory for DSP, I get the following error

[cmake] Build type: Debug
[cmake] CMake Error at Drivers/CMSIS/DSP/Source/CMakeLists.txt:12 (include):
[cmake]   include could not find requested file:
[cmake] 
[cmake]     configLib
[cmake] 
[cmake] 
[cmake] CMake Error at Drivers/CMSIS/DSP/Source/BasicMathFunctions/CMakeLists.txt:5 (include):
[cmake]   include could not find requested file:
[cmake] 
[cmake]     configLib
[cmake] 
[cmake] 
[cmake] CMake Error at Drivers/CMSIS/DSP/Source/BasicMathFunctions/CMakeLists.txt:6 (include):
[cmake]   include could not find requested file:
[cmake] 
[cmake]     configDsp
[cmake] 
[cmake] 
[cmake] CMake Error at Drivers/CMSIS/DSP/Source/BasicMathFunctions/CMakeLists.txt:34 (configLib):
[cmake]   Unknown CMake command "configLib".
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE=Debug 

Question is, am I configuring anything wrong in CubeMX? From where should I bring configDSP and configLib?

3 REPLIES 3
BMcDo.3
Associate III

I'm working on this now, too (except using VSCode w/ extensions instead of STM32CubeIDE).

 


@sanmveg wrote:

Question is, am I configuring anything wrong in CubeMX?

Maybe not.

 

@sanmveg wrote:

From where should I bring configDSP and configLib?


I suspect STM32CubeMX is probably giving you Drivers/CMSIS/DSP/Source/configDsp.cmake, but if not, you can find that here:

STM32CubeF4/Drivers/CMSIS/DSP at v1.28.2 · STMicroelectronics/STM32CubeF4

 

Seems somethings got lost in migration. You should find the missing files here:

CMSIS_5/CMSIS/DSP at 5.9.0 · ARM-software/CMSIS_5

such as

Drivers/CMSIS/DSP/configCore.cmake
Drivers/CMSIS/DSP/configLib.cmake
Drivers/CMSIS/DSP/Toolchain/*.cmake

I believe you'll need to set() the variables that they and the CMakeLists.txt files need (e.g. in your CMakeLists.txt), something like

 

set(PROJECTNAME CMSISDSP)
set(ROOT "${CMAKE_CURRENT_LIST_DIR}/Drivers")
set(ARM_CPU cortex-m4)

# set only ONE of these, according to your compiler
set(GCC 1)
set(ARMAC5 1)
set(ARMAC6 1)
set(ICCARM 1)

before you

add_subdirectory(Drivers/CMSIS/DSP/Source)

 

See Drivers/CMSIS/DSP/Source/CMakeLists.txt and the *.cmake files for the variables they consume/expect.

BMcDo.3
Associate III
BMcDo.3
Associate III

I edited to add a line

set(ARM_CPU cortex-m4)

in my post above.