Reputation: 560
I am trying to do something extremely simple:
I have to work on a C++ project that raises a lot of compilation warnings. Temporarily, I want to only see errors when I run make. What do I need to add to my CMakeLists.txt to make that happen? The simpler, the better.
Upvotes: 13
Views: 21370
Reputation: 15237
Nobody properly cared about MSVC so here is my answer, which also make use of add_compile_options
:
# Hide all warnings for 3rdparty code
if (MSVC)
add_compile_options(/W0)
else()
add_compile_options(-w)
endif()
If you try to use -w
or /w
with MSVC you'll get plenty of Command line warning D9025: overriding '/W1' with '/w'
warnings or similar ones, which can't be really fixed. In general it seems /W[1-4]
flags can be overridden only with a similar /W
flag
Upvotes: 0
Reputation: 560
It turns out the answer was to simply add the line
add_definitions(-w)
To CMakeLists.txt
It took me a lot longer than it should have to find this simple answer.
Upvotes: 18