aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py14
-rw-r--r--mesonbuild/compilers/compilers.py4
2 files changed, 14 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 2466fac..16962a4 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2327,8 +2327,6 @@ 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 is significant on this platform, add the appropriate linker arguments
- 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)
@@ -2361,6 +2359,15 @@ rule FORTRAN_DEP_HACK%s
raise RuntimeError('Unknown build target type.')
return commands
+ def get_target_type_link_args_post_dependencies(self, target, linker):
+ commands = []
+ if isinstance(target, build.Executable):
+ # If gui_app is significant on this platform, add the appropriate linker arguments.
+ # Unfortunately this can't be done in get_target_type_link_args, because some misguided
+ # libraries (such as SDL2) add -mwindows to their link flags.
+ commands += linker.get_gui_app_args(target.gui_app)
+ return commands
+
def get_link_whole_args(self, linker, target):
target_args = self.build_target_link_arguments(linker, target.link_whole_targets)
return linker.get_link_whole_for(target_args) if len(target_args) else []
@@ -2539,6 +2546,9 @@ rule FORTRAN_DEP_HACK%s
if need_threads:
commands += linker.thread_link_flags(self.environment)
+ # Add link args specific to this BuildTarget type that must not be overridden by dependencies
+ commands += self.get_target_type_link_args_post_dependencies(target, linker)
+
# Add link args for c_* or cpp_* build options. Currently this only
# adds c_winlibs and cpp_winlibs when building for Windows. This needs
# to be after all internal and external libraries so that unresolved
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 65df0e7..3d4cce8 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1578,8 +1578,8 @@ class GnuLikeCompiler(abc.ABC):
return ['-Wl,--allow-shlib-undefined']
def get_gui_app_args(self, value):
- if self.compiler_type.is_windows_compiler and value:
- return ['-mwindows']
+ if self.compiler_type.is_windows_compiler:
+ return ['-mwindows' if value else '-mconsole']
return []
def compute_parameters_with_absolute_paths(self, parameter_list, build_dir):