Explicitly set the Windows subsystem for ninja/VisualC

pull/3885/head
Jon Turney 6 years ago committed by Nirbheek Chauhan
parent 399f8553b7
commit 94f09a8454
  1. 6
      mesonbuild/backend/ninjabackend.py
  2. 9
      mesonbuild/compilers/c.py
  3. 4
      mesonbuild/compilers/compilers.py

@ -2234,9 +2234,9 @@ rule FORTRAN_DEP_HACK%s
if isinstance(target, build.Executable):
# Currently only used with the Swift compiler to add '-emit-executable'
commands += linker.get_std_exe_link_args()
# If gui_app, and that's significant on this platform
if target.gui_app and hasattr(linker, 'get_gui_app_args'):
commands += linker.get_gui_app_args()
# If gui_app is significant on this platform
if hasattr(linker, 'get_gui_app_args'):
commands += linker.get_gui_app_args(target.gui_app)
# If export_dynamic, add the appropriate linker arguments
if target.export_dynamic:
commands += linker.gen_export_dynamic_link_args(self.environment)

@ -1276,8 +1276,13 @@ class VisualStudioCCompiler(CCompiler):
def linker_to_compiler_args(self, args):
return ['/link'] + args
def get_gui_app_args(self):
return ['/SUBSYSTEM:WINDOWS']
def get_gui_app_args(self, value):
# the default is for the linker to guess the subsystem based on presence
# of main or WinMain symbols, so always be explicit
if value:
return ['/SUBSYSTEM:WINDOWS']
else:
return ['/SUBSYSTEM:CONSOLE']
def get_pic_args(self):
return [] # PIC is handled by the loader on Windows

@ -1277,8 +1277,8 @@ class GnuCompiler:
# For other targets, discard the .def file.
return []
def get_gui_app_args(self):
if self.gcc_type in (GCC_CYGWIN, GCC_MINGW):
def get_gui_app_args(self, value):
if self.gcc_type in (GCC_CYGWIN, GCC_MINGW) and value:
return ['-mwindows']
return []

Loading…
Cancel
Save