[tepl/master.msvc: 6/7] meson.build: Improve ICU dependency search



commit bc4aea3c5bfdcb23077bf1de889149bd4da47342
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jul 1 16:03:28 2020 +0800

    meson.build: Improve ICU dependency search
    
    Unfortunately the Visual Studio projects for ICU do not generate pkg-config
    files for us, so we need to look for the icu-i18n and icu-uc libraries manually
    if their pkg-config files could not be found on Visual Studio-style builds.
    
    Note that for debug ICU builds, the .lib files will have a 'd' suffix in the
    filename part, so we ought to look for such .lib files if we are doing a
    'debug' build, since we are linking to the debug Microsoft CRT, or when we
    explicitly request to link against a debug Visual Studio CRT.  Meson's
    'debugoptimized' builds on Visual Studio are actually release builds with
    debug symbols since they link to the release Microsoft CRT (with perhaps
    some more debug capabilities activated as needed per library), so
    we use the ICU release variants on 'debugoptimized' builds as well, in
    addition to the 'release' builds, at least.

 meson.build | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 15548c5..8cb3bb0 100644
--- a/meson.build
+++ b/meson.build
@@ -47,10 +47,44 @@ TEPL_PUBLIC_DEPS = [
   dependency('gtksourceview-4', version: '>= 4.0'),
   dependency('amtk-5', version: '>= 5.0')
 ]
+
+c_compiler = meson.get_compiler('c')
+
+# ICU's Visual Studio project files do not create pkg-config files for us, so look
+# for icuin(d).lib and icuuc(d).lib manually, if needed
+icu_uc_dep = dependency('icu-uc', required: c_compiler.get_argument_syntax() != 'msvc')
+icu_i18n_dep = dependency('icu-i18n', required: c_compiler.get_argument_syntax() != 'msvc')
+
+if c_compiler.get_argument_syntax() == 'msvc'
+  # We need to know the CRT being used to determine what .lib files we need on
+  # Visual Studio for dependencies that don't normally come with pkg-config files
+  vs_crt = 'release'
+  vs_crt_opt = get_option('b_vscrt')
+  if vs_crt_opt in ['mdd', 'mtd']
+    vs_crt = 'debug'
+  elif vs_crt_opt == 'from_buildtype'
+    if get_option('buildtype') == 'debug'
+      vs_crt = 'debug'
+    endif
+  endif
+
+  icu_lib_debug_suffix = ''
+  if vs_crt == 'debug'
+    icu_lib_debug_suffix = 'd'
+  endif
+  if not icu_uc_dep.found()
+    icu_uc_dep = c_compiler.find_library('icuuc@0@'.format(icu_lib_debug_suffix))
+  endif
+  if not icu_i18n_dep.found()
+    icu_i18n_dep = c_compiler.find_library('icuin@0@'.format(icu_lib_debug_suffix))
+  endif
+endif
+
 tepl_private_deps = [
-  dependency('icu-uc'),
-  dependency('icu-i18n'),
+  icu_uc_dep,
+  icu_i18n_dep,
 ]
+
 TEPL_DEPS = [TEPL_PUBLIC_DEPS, tepl_private_deps]
 
 # config.h
@@ -80,7 +114,6 @@ add_project_arguments(
 # even at the maximum level.
 # The following warning_cflags suppose that warning_level=2.
 
-c_compiler = meson.get_compiler('c')
 warning_cflags = []
 
 if c_compiler.get_id() == 'msvc'


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