MSVC target_precompile_headers disables all warnings for the target
target_precompile_headers
causes CMake to generate a header to precompile, such as this one:
/* generated by CMake */
#pragma system_header
#ifdef __cplusplus
#include <sol/sol.hpp>
#include <osg/State>
#include <osg/StateSet>
#include <osg/Node>
#include <osg/Drawable>
#include <osg/Camera>
#include <MyGUI_Widget.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <functional>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
#endif // __cplusplus
It is then added to the target with the /Fp
and /Yu
flags.
For some reason, the #pragma system_header
then ends up affecting every file in the target, and if /external:W0
is set, as is generally sensible, no warnings will be generated any more.
This seems like an MSVC bug, but as far as I can tell, it affects every MSVC version that supports #pragma system_header
, so seems like something CMake should work around.