[gedit/master-msvc: 6/10] Meson: Support building gedit with MSVC




commit 341700c1a5ea138368ac3d87112027eec591588d
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Aug 23 18:56:16 2021 +0800

    Meson: Support building gedit with MSVC
    
    Make the build force-include msvc_recommended_pragmas.h so that we have
    the compiler warning-related flags enabled when building with Visual
    Studio, which will more-or-less cover the GCC warnings that we want to
    filter out or look out for.
    
    Also add the necessary linker flags to:
    
    *  Build gedit as a GUI program on Visual Studio, using
       /entry:mainCRTStartup
    *  Delay-load gedit-*.dll, since it is installed in $(prefix)\lib\gedit
       rather than being together with gedit.exe, and link to items as
       necessary for this support.
    *  Override GEDIT_API with __declspec(dllexport), so that we really
       export the public symbols during the build.

 gedit/meson.build |  3 ++-
 meson.build       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/gedit/meson.build b/gedit/meson.build
index e9d42bfc2..969e24f5a 100644
--- a/gedit/meson.build
+++ b/gedit/meson.build
@@ -277,8 +277,9 @@ endif
 executable(
   'gedit',
   'gedit.c',
-  dependencies: libgedit_dep,
+  dependencies: [libgedit_dep, win32_delay_load_libs],
   c_args: gedit_c_args,
+  link_args: extra_gedit_gui_ldflags,
   install: true,
   install_rpath: get_option('prefix') / get_option('libdir') / 'gedit',
   gui_app: true,
diff --git a/meson.build b/meson.build
index 86e23c42a..17f4ea705 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,8 @@ project(
   meson_version: '>= 0.53'
 )
 
+cc = meson.get_compiler('c')
+
 if host_machine.system() == 'darwin'
   add_languages('objc')
 endif
@@ -15,6 +17,20 @@ python = import('python')
 
 api_version = '41'
 
+extra_gedit_gui_ldflags = []
+win32_delay_load_libs = []
+if cc.get_argument_syntax() == 'msvc'
+  msvc_c_cflags = [
+    '/utf-8',
+    '/FImsvc_recommended_pragmas.h',
+    '/DGEDIT_API=__declspec(dllexport)extern',
+  ]
+  add_project_arguments(cc.get_supported_arguments(msvc_c_cflags), language: 'c')
+  extra_gedit_gui_ldflags += '/entry:mainCRTStartup'
+  extra_gedit_gui_ldflags += '/delayload:gedit-@0@.dll'.format(api_version)
+  win32_delay_load_libs += cc.find_library('delayimp')
+endif
+
 # Paths
 root_include_dir = include_directories('.')
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]