GithubHelp home page GithubHelp logo

Comments (6)

atsju avatar atsju commented on August 16, 2024

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.

Posejdos avatar Posejdos commented on August 16, 2024

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:

  1. Clone this repo
  2. Set your environment variables if needed to allow compilation
  3. Go to examples/blinky
  4. 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)

  1. 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 )

  2. 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.

atsju avatar atsju commented on August 16, 2024

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.

Posejdos avatar Posejdos commented on August 16, 2024

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.

atsju avatar atsju commented on August 16, 2024

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.

Posejdos avatar Posejdos commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.