Comments (6)
Hi, warnings is not something you want to normalize, ignore or disable in general except if you know exactly what you are doing.
Maybe you want to share the warning you are facing ? and/or a minimal code to reproduce the issue ? We won't be able to help if we can't reproduce.
from stm32-cmake.
Hi, thanks for the quick answer!
I know I shouldn't ignore my own warnings, but I don't want to be told about warnings in libraries. Especially when they are mostly about unused variables. I also very much don't want to edit them in any way (to get rid of warnings), because that's just bad practice - what happens when the libraries get updated?
Sorry, I should've listed the steps to reproduce in the first place. Here they are:
- Clone this repo
- Set your environment variables if needed to allow compilation
- Go to examples/blinky
- Add the PWR HAL module in CMakeLists.txt:
set(HAL_COMP_LIST RCC GPIO CORTEX PWR)
target_link_libraries(stm32-blinky-f4 HAL::STM32::F4::RCC HAL::STM32::F4::GPIO HAL::STM32::F4::CORTEX HAL::STM32::F4::PWR CMSIS::STM32::F407VG STM32::NoSys)
-
Edit cmake/stm32/f4.cmake to enable all warnings:
target_compile_options(STM32::F4 INTERFACE -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wall -Wextra -Wundef )
-
Build the blinky example and you'll see a warning about an unused parameter.
In my projects I have more modules and they emit more warnings - this clutters my build output and makes it difficult to fix my own warnings. I'm pretty sure it should be possible to flag those libraries as third-party (system?) and disable these warnings for them, I just don't know how to do it.
Sorry for the closing and reopening the issue BTW. Missclick.
from stm32-cmake.
maybe something like target_compile_options(stm32-blinky-f4 PRIVATE -Wall -Wextra -Wundef)
to add the options only on the target you need them instead to lowest target and propagate? This is what targets are for.
Sorry I have not been able to try out the code but maybe this will unlock you in the meantime.
from stm32-cmake.
Removing the warning options from f4.cmake and adding them in the project CMakeLists.txt with
target_compile_options(stm32-blinky-f4 PRIVATE -Wall -Wextra -Wundef)
makes no difference, the warning from HAL still shows, unfortunately.
There's no time pressure, so don't worry - I have been struggling with this for some time now, I'm used to it :) Take it easy.
from stm32-cmake.
One ugly solution is to add property specifically to your sources set_source_files_properties(blinky.c PROPERTIES COMPILE_FLAGS -Wall -Wundef -Wextra)
I tried to compile HAL as a static library and then link it against blinky while adding compile options only to blinky but this also let the compile options down to hal... So following did not work :
add_executable(stm32-blinky-f4 ${MAIN_SOURCE_FILE} )
target_link_libraries(stm32-blinky-f4 PRIVATE hal_lib)
add_library(hal_lib STATIC stm32f4xx_hal_conf.h)
target_link_libraries(hal_lib PUBLIC
HAL::STM32::F4::RCC
HAL::STM32::F4::GPIO
HAL::STM32::F4::CORTEX
HAL::STM32::F4::PWR
CMSIS::STM32::F407VG
STM32::NoSys
)
target_compile_options(stm32-blinky-f4 PRIVATE -Wall -Wundef -Wextra)
stm32_print_size_of_target(stm32-blinky-f4)
from stm32-cmake.
Oh my, it works! Thank you kindly. My cmake-fu wasn't strong enough to find this solution by myself.
I'm closing this issue - thanks again!
from stm32-cmake.
Related Issues (20)
- NO LUCK : Iam trying to build the project on windows 10 HOT 2
- Unable to configure/build Blinky example on windows 10. (No STM32_TARGET_TRIPLET specified) HOT 7
- CMake CMP0057 Policy Error HOT 2
- Check the cmake version and inform the user if it's not at least the requested one
- Support Dual Core Project WL55JCX HOT 11
- Add Branch with only CMAKE functions called `lib ` HOT 5
- FetchContent_Declare does not show progress HOT 5
- Wrong HAL family in find_package HOT 2
- quotes in --sysroot breaks clangd HOT 3
- To the next release and beyond HOT 1
- we need integration of H5 family and C0 family HOT 6
- How to include middleware? HOT 3
- How to include CMSIS arm_math? HOT 8
- Target all HAL libraries for a family HOT 10
- Template on multi-level directories with custom libraries HOT 2
- Calling find_package() to find CMSIS multiple times leads to errors HOT 7
- Incorrect TARGET_TRIPLET variable handling
- Linking fails with `-lstm_cube: no such file or directory` HOT 1
- UT: Make unit test run for all existing and future families HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stm32-cmake.