vs: respect 'b_pch' option

Fixes #4681.
pull/4711/head
Nicolas Schneider 6 years ago committed by Jussi Pakkanen
parent 211a60dc99
commit f1b32aa4bb
  1. 3
      mesonbuild/backend/vs2010backend.py
  2. 2
      test cases/failing build/3 pch disabled/c/meson.build
  3. 1
      test cases/failing build/3 pch disabled/c/pch/prog.h
  4. 5
      test cases/failing build/3 pch disabled/c/pch/prog_pch.c
  5. 10
      test cases/failing build/3 pch disabled/c/prog.c
  6. 5
      test cases/failing build/3 pch disabled/meson.build

@ -982,7 +982,6 @@ class Vs2010Backend(backends.Backend):
target_defines.append('%(PreprocessorDefinitions)')
ET.SubElement(clconf, 'PreprocessorDefinitions').text = ';'.join(target_defines)
ET.SubElement(clconf, 'FunctionLevelLinking').text = 'true'
pch_node = ET.SubElement(clconf, 'PrecompiledHeader')
# Warning level
warning_level = self.get_option_for_target('warning_level', target)
ET.SubElement(clconf, 'WarningLevel').text = 'Level' + str(1 + int(warning_level))
@ -990,6 +989,8 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(clconf, 'TreatWarningAsError').text = 'true'
# Note: SuppressStartupBanner is /NOLOGO and is 'true' by default
pch_sources = {}
if self.environment.coredata.base_options.get('b_pch', False):
pch_node = ET.SubElement(clconf, 'PrecompiledHeader')
for lang in ['c', 'cpp']:
pch = target.get_pch(lang)
if not pch:

@ -0,0 +1,2 @@
exe = executable('prog', 'prog.c',
c_pch : ['pch/prog_pch.c', 'pch/prog.h'])

@ -0,0 +1,5 @@
#if !defined(_MSC_VER)
#error "This file is only for use with MSVC."
#endif
#include "prog.h"

@ -0,0 +1,10 @@
// No includes here, they need to come from the PCH
void func() {
fprintf(stdout, "This is a function that fails if stdio is not #included.\n");
}
int main(int argc, char **argv) {
return 0;
}

@ -0,0 +1,5 @@
# Disable PCH usage to make sure backends respect this setting.
# Since the .c file requires PCH usage (it does not include necessary
# headers itself), the build should fail.
project('pch test', 'c', default_options: ['b_pch=false'])
subdir('c')
Loading…
Cancel
Save