Skip to content

MSVC builds: Improve build process (was: MSVC builds: Always enable items from msvc_recommended_pragmas.h)

Chun-wei Fan requested to merge improve-msvc-force-include into main

Hi,

From merge requests such as !6099 (merged), we often couldn't catch compiler issues in the code that are raised by the Visual Studio compiler when GLib is found (i.e. not built as a subproject) as the CI always built GTK with GLib built as a subproject, causing msvc_recommended_pragmas.h not to be force-included, which is designed to catch such code issues.

So, this tries to improve the build in the following ways, to solve the problem and add some improvements:

* Look harder for msvc_recommended_pragmas.h, first in GLib's ${includedir}, if not building GLib as a subproject, or otherwise look for it in the GLib subproject directory, and then look for it standalone in %INCLUDE% as we did before. If msvc_recommended_pragmas.h still cannot be found, do things the brute-force way: enable all that #pragma's and #define's that are found in msvc_recommended_pragms.h in current GLib stable, if we couldn't just force-include msvc_recommended_pragms.h.(I decided not to go the brute-force way as going into the subprojects directory should do)

  • Copy msvc_recommended_pragmas.h into the source tree and force-include it during the build
  • Also, drop the -utf-8 compiler flag, since Meson already enabled it by default for some time for VS 2015 and later, quite a bit before 0.63.0.
  • Require that -Zc:preprocessor is available if building the debug code (debug is enabled).

With blessings, thank you!

Edited by Chun-wei Fan

Merge request reports