Compiler options for warnings


I have a question about setting the compiler options for warnings.
I read in the documentation this:

if (MSVC)
    # warning level 4
    # additional warnings
    add_compile_options(-Wall -Wextra -Wpedantic)


I wonder why the documentation didn’t use /Wall for MSVC.
I mean it added even -Wpedantic for other compilers, but only /W4 for MSVC, even /Wall do more tests.

So what is the reason for this? Maybe because of older MSVC versions?

Thank you

/Wall for MSVC can produce a lot of warnings that I’m guessing most folks don’t find particularly useful. Almost to the point where it’s overly chatty and loses its utility.

I’ve gone to looking at this CMake template to serve as an example of what’s considered the current best practices for warnings for each of the compilers. You’ll notice it also doesn’t use /Wall on MSVC. The CMake documentation itself is likely just trying to show an example rather than what’s the current best practice.

As an aside, it’s preferred to use target_compile_options and assign the options to the target itself rather than using the directory functions add_compile_options. You’ll notice in the template I linked, it’s using an interface target to manage the compile options being applied. This leaves it to project targets to link with this interface target to apply the compile options.

Thank you for your answer. And thank you for the link! I need more time to read and understand everything, but it already looks like a very good answer.