ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
459 stars 123 forks source link

Trouble with Including CMSIS-DSP Source Files in CLion #114

Closed WangHunZi closed 11 months ago

WangHunZi commented 11 months ago

Issue Report: Trouble with Including CMSIS-DSP Source Files in CLion

Develop Environment: CLion

Problem Description: I followed the documentation to add the following commands to my CMakeLists.txt file:

set(CMSISCORE "CMSIS-DSP/Source")
add_subdirectory(CMSIS-DSP/Source bin_dsp)

After reloading CMake and compiling, I encountered the first issue of missing arm_math.h. To address this, I included the paths CMSIS-DSP/Include and CMSIS-DSP/PrivateInclude using include_directories().

Upon compiling again, I encountered a new error: main.c:(.text.startup.main+0x14): undefined reference to 'arm_cos_q31'. To resolve this, I added the line file(GLOB_RECURSE SOURCES "CMSIS-DSP/Source/*.*") to the CMakeLists.txt.

However, this led to yet another issue with multiple definitions. After inspecting the files, I discovered that each sub-file in the Source directory included the others, causing the conflicts. As a temporary solution, I manually deleted specific files like CMSIS-DSP/Source/WindowFunctions/WindowFunctions.c, which allowed the project to compile successfully.

While this approach worked, it requires deleting multiple files, which is cumbersome and unsatisfactory. I also attempted to remove the file(GLOB_RECURSE SOURCES "CMSIS-DSP/Source/*.*") by using list(REMOVE ITEM ...) and foreach(), but it was unsuccessful and time-consuming.

Request for Assistance: I would like to seek guidance on how to properly include the CMSIS-DSP source files in my project without facing the issues of missing headers and multiple definitions. If the problem lies with my approach, I would appreciate advice on the correct method to resolve this situation. Additionally, if feasible, I propose considering the removal of conflicting files like WindowFunctions.c to streamline the usage of the CMSIS-DSP library.

christophe0606 commented 11 months ago

@suguguan CMSIS Core is not from CMSIS-DSP but from the https://github.com/ARM-software/CMSIS_5 project. You need to point to the folder Core.

Something like : set(CMSISCORE CMSIS_5/CMSIS/Core)

You'll need also to link the CMSIS-DSP library by adding something like:

target_link_libraries(my_application PUBLIC CMSISDSP)

Then you can include the arm_math.h from your project.

christophe0606 commented 11 months ago

Also you may add a target_compile_options(CMSISDSP PRIVATE -Ofast) to build the library with right performances. You can add other flags too (for instance on gcc -ffunction-sections -fdata-sections to optimize code size)

WangHunZi commented 11 months ago

@suguguan CMSIS Core is not from CMSIS-DSP but from the https://github.com/ARM-software/CMSIS_5 project. You need to point to the folder Core.

Something like : set(CMSISCORE CMSIS_5/CMSIS/Core)

You'll need also to link the CMSIS-DSP library by adding something like:

target_link_libraries(my_application PUBLIC CMSISDSP)

Then you can include the arm_math.h from your project.

Thank you very, very much for your advice. I have understood your point, and I don't need to make many modifications to compile successfully, which is exactly what I wanted. Let me summarize: CMSIS-DSP is part of CMSIS_5, and it still requires some related files from CMSIS_5. Therefore, we need to specify the location of CMSIS_5, which corresponds to the 'Drivers/CMSIS' path generated by CubeMX. As a result, we should set the value of the 'CMSISCORE' variable to the 'Drivers/CMSIS' path, not the 'Include' or 'Source' folders of CMSIS-DSP or any other folders.

Mexico-zyy-lost commented 2 months ago

@suguguan CMSIS Core is not from CMSIS-DSP but from the https://github.com/ARM-software/CMSIS_5 project. You need to point to the folder Core. Something like : set(CMSISCORE CMSIS_5/CMSIS/Core) You'll need also to link the CMSIS-DSP library by adding something like: target_link_libraries(my_application PUBLIC CMSISDSP) Then you can include the arm_math.h from your project.

Thank you very, very much for your advice. I have understood your point, and I don't need to make many modifications to compile successfully, which is exactly what I wanted. Let me summarize: CMSIS-DSP is part of CMSIS_5, and it still requires some related files from CMSIS_5. Therefore, we need to specify the location of CMSIS_5, which corresponds to the 'Drivers/CMSIS' path generated by CubeMX. As a result, we should set the value of the 'CMSISCORE' variable to the 'Drivers/CMSIS' path, not the 'Include' or 'Source' folders of CMSIS-DSP or any other folders.

could u share ur last cmakelists.txt file?