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



commit d403cf82ac7c71c13e9faa87bbb299718b860f93
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.  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 | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0a31d06..ddfca77 100644
--- a/meson.build
+++ b/meson.build
@@ -47,10 +47,32 @@ 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'
+  icu_lib_debug_suffix = ''
+  if get_option('buildtype') == '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 +102,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]