[gtkmm/use-dllexport-3-24-meson: 16/16] Meson: Fix linking demos and tests on Visual Studio
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/use-dllexport-3-24-meson: 16/16] Meson: Fix linking demos and tests on Visual Studio
- Date: Wed, 13 May 2020 09:14:45 +0000 (UTC)
commit 20b75103e8666e2600feb67a83123646b8976871
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed May 13 17:08:25 2020 +0800
Meson: Fix linking demos and tests on Visual Studio
GTK (and therefore gtkmm) applications require a linker flag
'-entry:mainCRTStartup' if building with 'gui_app' is set to be true (which
means, we are using /subsystem:windows in the linker flags on Visual Studio)
unless a WinMain() is defined in the individual application's sources.
This fixes the build of such programs by adding this linker flag where it is
needed.
demos/gtk-demo/meson.build | 3 ++-
meson.build | 9 ++++++++-
tests/meson.build | 3 ++-
3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/meson.build b/demos/gtk-demo/meson.build
index b80b3069..3faf21a0 100644
--- a/demos/gtk-demo/meson.build
+++ b/demos/gtk-demo/meson.build
@@ -1,6 +1,6 @@
# demos/gtk-demo
-# Input: gtkmm_dep, epoxy_dep, build_demos
+# Input: gtkmm_dep, epoxy_dep, build_demos, gui_app_ldflags
# Output: -
gtkmm_demo_cc_files = [
@@ -49,6 +49,7 @@ if epoxy_dep.found()
dependencies: [gtkmm_dep, epoxy_dep],
gui_app: true,
build_by_default: build_demos,
+ link_args: gui_app_ldflags,
install: false,
)
endif
diff --git a/meson.build b/meson.build
index b80d1271..e6d9b9f8 100644
--- a/meson.build
+++ b/meson.build
@@ -278,13 +278,20 @@ endif
warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
add_project_arguments(warning_flags, language: 'cpp')
+gui_app_ldflags = []
+
# MSVC: Ignore warnings that aren't really harmful, but make those
-# that should not be overlooked stand out.
+# that should not be overlooked stand out. For gtkmm applications
+# where we do not want a console window to show up with Visual Studio
+# builds, we must use '-entry:mainCRTStartup' in the linker flags,
+# otherwise the program will fail to link unless we defined a WinMain()
+# for them
if is_msvc
foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/wd4530', '/wd4250', '/wd4251', '/wd4273',
'/wd4275', '/wd4805']
disabled_warning = cpp_compiler.get_supported_arguments(wd)
add_project_arguments(disabled_warning, language: 'cpp')
endforeach
+ gui_app_ldflags += '-entry:mainCRTStartup'
endif
subdir('tools/extra_defs_gen')
diff --git a/tests/meson.build b/tests/meson.build
index 07411a27..23f9c32c 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,6 @@
# tests
-# Input: gdkmm_dep, gtkmm_dep, build_tests
+# Input: gdkmm_dep, gtkmm_dep, build_tests, gui_app_ldflags
# Output: -
test_programs = [
@@ -37,6 +37,7 @@ foreach ex : test_programs
dependencies: ex[3] ? gtkmm_dep : gdkmm_dep,
gui_app: ex[3],
build_by_default: build_tests,
+ link_args: ex[3] ? gui_app_ldflags : [],
install: false,
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]