CMake (cotire) precompiled headers and disable warnings

I use the cotire plugin ( https://github.com/sakra/cotire ) for CMake, which handles several nice things related to compilation speed (for example, precompiled headers).

The problem is that I include several headers (Boost related or Protobuf) as system ones - in which warnings are disabled. After they were precompiled, I got a lot of warnings.

Is it possible to disable warnings in precompiled headers?

+6
source share
1 answer

I don’t think there is a built-in way to do this, we changed the cotire cotire_add_pch_compilation_flags function (line 1244 cotire.cmake version 1.5.1) to add the -w flag when compiling a precompiled header. We changed the GNU section | CLang for reading

elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used # -x specify the source language # -c compile but do not link # -o place output in file set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") if (_flags) # append to list list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-w" "-c" "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string set (_flags "-x ${_xLanguage_${_language}} -w -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() 

This suppresses all warnings for us, we have many warnings, including -Werror, so this was a significant change!

+1
source

All Articles