Making the compiler strict (about unused variables and the likes)

So something I realized while doing bits of development in Juce c++ and bits of development in SC c++ that there were big differences in strictness in the two Cmake / compiler configurations. The default SC Cmake one (for plugins) is pretty lax compared to JUCE’s and will allow you to have unused variables for example.

Apparantly there’s an easy fix for this, if you want to have the compiler tell you off if you do small errors like this. It’s just a matter of adding this section to your CMakeLists.txt:

# Extra compiler options
if (MSVC)
    # warning level 4 and all warnings as errors
    add_compile_options(/W4 /WX)
    # lots of warnings and all warnings as errors
    add_compile_options(-Wall -Wextra -pedantic)