[glibmm/meson-msvc-toolset-2-64] Meson/Visual Studio builds: Include toolset version by default



commit 0ac07ab6ba18192664402d16ea5fdbaedcdd4424
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Jun 18 11:34:39 2020 +0800

    Meson/Visual Studio builds: Include toolset version by default
    
    This makes the built DLL and .lib's contain the toolset version if the build is
    carried out using Visual Studio 2015 or later, unless the
    'msvc14x-parallel-installable' option is set to be false during configuration.
    
    The reasoning behind this change is that there are subtle problems when, for
    instance, one tries to link to a Visual Studio 2015-built glibmm when building
    gtkmm and libxml++ with Visual Studio 2017 or 2019.  This is unfortunate as
    Microsoft did try hard to make interoperating between binaries built with
    Visual Studio 2015, 2017 and 2019 as easy as possible in terms of ABI and API,
    but unfortunately this hits the corner cases where this compatibility does not
    work.
    
    As the name suggests, this attempts to make Visual Studio 2015, 2017 and 2019
    builds share a single set of underlying C DLLs easier, while avoiding breakages
    caused by such subtle differences.

 README.win32                     |  6 +++++-
 configure.ac                     |  1 +
 gio/giomm-uninstalled.pc.in      |  2 +-
 gio/giomm.pc.in                  |  2 +-
 gio/giomm/meson.build            |  6 +++---
 glib/glibmm-uninstalled.pc.in    |  2 +-
 glib/glibmm.pc.in                |  2 +-
 glib/glibmm/meson.build          |  6 +++---
 glib/meson.build                 |  3 ++-
 meson.build                      | 20 ++++++++++++++++++++
 meson_options.txt                |  2 ++
 tools/extra_defs_gen/meson.build |  4 ++--
 12 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/README.win32 b/README.win32
index f3846532..5f72c227 100644
--- a/README.win32
+++ b/README.win32
@@ -69,7 +69,11 @@ previously built glibmm with Visual Studio 2017 or 2019 and had DLL and
 `USE_COMPAT_LIBS=1` in your NMake build commandline to continue to build
 with the resulting DLL and .lib names be in the former form, but please
 note that this is not recommended unless rebuilding dependent code is
-not convenient.
+not convenient.  For the Meson builds, pass in the option
+'-Dmsvc14x-parallel-installable=false' to the Meson configure command line
+to avoid having the toolset version in the final DLL and .lib filenames;
+again, this is only recommended if it is inconvenient to re-build the
+dependent code.
 
 A 'tests' target will build the test programs for glibmm and giomm, an
 'install' target is provided to copy the built DLLs and LIBs, along with
diff --git a/configure.ac b/configure.ac
index 2474b63f..66a5daed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,7 @@ MM_CONFIG_DOCTOOL_DIR([docs])
 
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
 AC_SUBST([LIBGLIBMM_SO_VERSION], [4:0:3])
+AC_SUBST([MSVC_TOOLSET_VER], [''])
 
 AC_PROG_CXX
 MM_AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
diff --git a/gio/giomm-uninstalled.pc.in b/gio/giomm-uninstalled.pc.in
index a72da5b9..be132c61 100644
--- a/gio/giomm-uninstalled.pc.in
+++ b/gio/giomm-uninstalled.pc.in
@@ -6,5 +6,5 @@ Description: C++ binding for gio, not installed
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: gio-2.0 @GLIBMM_MODULE_NAME@-uninstalled
-Libs: ${pc_top_builddir}/${pcfiledir}/giomm/libgiomm-@GIOMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/giomm/libgiomm@MSVC_TOOLSET_VER@-@GIOMM_API_VERSION@.la
 Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/gio/giomm.pc.in b/gio/giomm.pc.in
index 2ec76a72..702fd777 100644
--- a/gio/giomm.pc.in
+++ b/gio/giomm.pc.in
@@ -15,5 +15,5 @@ Description: C++ binding for gio
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: gio-2.0 @GLIBMM_MODULE_NAME@
-Libs: -L${libdir} -lgiomm-@GIOMM_API_VERSION@
+Libs: -L${libdir} -lgiomm@MSVC_TOOLSET_VER@-@GIOMM_API_VERSION@
 Cflags: -I${includedir}/@GIOMM_MODULE_NAME@ -I${libdir}/@GIOMM_MODULE_NAME@/include
diff --git a/gio/giomm/meson.build b/gio/giomm/meson.build
index 99aa3d68..19bf5cb9 100644
--- a/gio/giomm/meson.build
+++ b/gio/giomm/meson.build
@@ -3,7 +3,7 @@
 # Input: giomm_build_dep, giomm_pcname, maintainer_mode, project_source_root,
 #        generate_binding_py, handle_built_files_py, m4_files, pm_files,
 #        glibmm_libversion, install_includedir, python3, giomm_rc, gmmproc_dir,
-#        is_host_windows, gmmproc, generate_wrap_init_pl
+#        is_host_windows, gmmproc, generate_wrap_init_pl, giomm_libname
 # Output: giomm_hg_ccg_basenames, giomm_extra_h_files, built_files_root,
 #         giomm_built_h_file_targets, giomm_dep
 
@@ -302,7 +302,7 @@ if maintainer_mode
 
   extra_include_dirs = ['..', '..' / '..' / 'glib']
 
-  giomm_library = library(giomm_pcname, extra_giomm_objects,
+  giomm_library = library(giomm_libname, extra_giomm_objects,
     giomm_used_built_cc_file_targets, giomm_extra_cc_files, built_dummy_h_file_target,
     version: glibmm_libversion,
     include_directories: extra_include_dirs,
@@ -350,7 +350,7 @@ else # not maintainer_mode
          '..' / '..' / 'glib', '..' / '..' / 'untracked' / 'glib',
   ]
 
-  giomm_library = library(giomm_pcname, extra_giomm_objects,
+  giomm_library = library(giomm_libname, extra_giomm_objects,
     built_cc_files, giomm_extra_cc_files,
     version: glibmm_libversion,
     include_directories: extra_include_dirs,
diff --git a/glib/glibmm-uninstalled.pc.in b/glib/glibmm-uninstalled.pc.in
index 5e700649..71d5091f 100644
--- a/glib/glibmm-uninstalled.pc.in
+++ b/glib/glibmm-uninstalled.pc.in
@@ -8,5 +8,5 @@ Description: C++ binding for GLib, not installed
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: gobject-2.0 sigc++-2.0
-Libs: ${pc_top_builddir}/${pcfiledir}/glibmm/libglibmm-@GLIBMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/glibmm/libglibmm@MSVC_TOOLSET_VER@-@GLIBMM_API_VERSION@.la
 Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/glib/glibmm.pc.in b/glib/glibmm.pc.in
index b08f62d0..313e1def 100644
--- a/glib/glibmm.pc.in
+++ b/glib/glibmm.pc.in
@@ -17,5 +17,5 @@ Description: C++ wrapper for GLib
 Version: @PACKAGE_VERSION@
 URL: http://www.gtkmm.org/
 Requires: gobject-2.0 sigc++-2.0
-Libs: -L${libdir} -lglibmm-@GLIBMM_API_VERSION@
+Libs: -L${libdir} -lglibmm@MSVC_TOOLSET_VER@-@GLIBMM_API_VERSION@
 Cflags: -I${includedir}/@GLIBMM_MODULE_NAME@ -I${libdir}/@GLIBMM_MODULE_NAME@/include
diff --git a/glib/glibmm/meson.build b/glib/glibmm/meson.build
index fc4630c9..cc71ebad 100644
--- a/glib/glibmm/meson.build
+++ b/glib/glibmm/meson.build
@@ -3,7 +3,7 @@
 # Input: glibmm_build_dep, glibmm_pcname, maintainer_mode, project_source_root,
 #        generate_binding_py, handle_built_files_py, m4_files, pm_files,
 #        glibmm_libversion, install_includedir, python3, glibmm_rc, gmmproc_dir,
-#        is_host_windows, gmmproc, generate_wrap_init_pl
+#        is_host_windows, gmmproc, generate_wrap_init_pl, glibmm_libname
 # Output: glibmm_hg_ccg_basenames, glibmm_extra_h_files, built_files_root,
 #         glibmm_built_h_file_targets, glibmm_dep
 
@@ -257,7 +257,7 @@ if maintainer_mode
 
   extra_include_dirs = ['..']
 
-  glibmm_library = library(glibmm_pcname, extra_glibmm_objects,
+  glibmm_library = library(glibmm_libname, extra_glibmm_objects,
     glibmm_built_cc_file_targets, glibmm_extra_cc_files, built_dummy_h_file_target,
     include_directories: extra_include_dirs,
     cpp_args: glibmm_cpp_args,
@@ -309,7 +309,7 @@ else # not maintainer_mode
 
   extra_include_dirs = [ '..', '..' / '..' / 'untracked' / 'glib' ]
 
-  glibmm_library = library(glibmm_pcname, extra_glibmm_objects,
+  glibmm_library = library(glibmm_libname, extra_glibmm_objects,
     built_cc_files, glibmm_extra_cc_files,
     include_directories: extra_include_dirs,
     cpp_args: glibmm_cpp_args,
diff --git a/glib/meson.build b/glib/meson.build
index 99c43772..4feee0fd 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -4,7 +4,7 @@
 #        glibmm_pcname, giomm_pcname, glibmm_api_version, glibmm_requires,
 #        giomm_requires, build_deprecated_api, install_pkgconfigdir,
 #        is_os_cocoa, cpp_compiler, glibmm_major_version, glibmm_minor_version,
-#        glibmm_micro_version
+#        glibmm_micro_version, msvc14x_toolset_ver
 # Output: pkg_conf_data, install_glibmmconfigdir, glibmmconfig_h
 
 pkg_conf_data = configuration_data()
@@ -32,6 +32,7 @@ pkg_conf_data.set('GLIBMM_MICRO_VERSION', glibmm_micro_version)
 pkg_conf_data.set('GIOMM_MAJOR_VERSION', glibmm_major_version)
 pkg_conf_data.set('GIOMM_MINOR_VERSION', glibmm_minor_version)
 pkg_conf_data.set('GIOMM_MICRO_VERSION', glibmm_micro_version)
+pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver)
 
 library_build_type = get_option('default_library')
 
diff --git a/meson.build b/meson.build
index 26482705..1790568c 100644
--- a/meson.build
+++ b/meson.build
@@ -94,6 +94,8 @@ build_documentation = build_documentation_opt == 'true' or \
                      (build_documentation_opt == 'if-maintainer-mode' and maintainer_mode)
 build_examples = get_option('build-examples')
 
+use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
+
 # Installation directories are relative to {prefix}.
 install_prefix = get_option('prefix')
 install_includedir = get_option('includedir')
@@ -209,6 +211,9 @@ endif
 warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
 add_project_arguments(warning_flags, language: 'cpp')
 
+# Add toolset version in builds done with Visual Studio 2015 or later
+msvc14x_toolset_ver = ''
+
 # MSVC: Ignore warnings that aren't really harmful, but make those
 #       that should not be overlooked stand out.
 if is_msvc
@@ -216,8 +221,23 @@ if is_msvc
     '/FImsvc_recommended_pragmas.h', '/wd4146', '/wd4251', '/wd4275', '/wd4267', '/wd4530', '/wd4589', 
'/utf-8'
   ])
   add_project_arguments(disabled_warnings, language: 'cpp')
+
+  if use_msvc14x_toolset_ver
+    if cpp_compiler.version().version_compare('>=19.20')
+      msvc14x_toolset_ver = '-vc142'
+    elif cpp_compiler.version().version_compare('>=19.10')
+      msvc14x_toolset_ver = '-vc141'
+    elif cpp_compiler.version().version_compare('>=19.00')
+      msvc14x_toolset_ver = '-vc140'
+    else
+      message('Visual Studio toolset version not applied for pre-Visual Studio 2015 builds')
+    endif
+  endif
 endif
 
+glibmm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + glibmm_api_version
+giomm_libname = 'giomm' + msvc14x_toolset_ver + '-' + glibmm_api_version
+
 subdir('tools')
 subdir('glib')
 subdir('MSVC_NMake/glibmm')
diff --git a/meson_options.txt b/meson_options.txt
index 0fc1e1d7..2a1da3ae 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -12,3 +12,5 @@ option('debug-refcounting', type: 'boolean', value: false,
   description: 'Print debug messages in connection with reference counting')
 option('build-examples', type: 'boolean', value: true,
   description: 'Build example programs')
+option('msvc14x-parallel-installable', type: 'boolean', value: true,
+  description: 'Use separate DLL and LIB filenames for Visual Studio 2015, 2017 and 2019')
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
index 65b56e96..5080b7d5 100644
--- a/tools/extra_defs_gen/meson.build
+++ b/tools/extra_defs_gen/meson.build
@@ -1,11 +1,11 @@
 # tools/extra_defs_gen
 
 # Input: glibmm_build_dep, giomm_build_dep, glibmm_api_version,
-#        glibmm_libversion, glibmm_pcname
+#        glibmm_libversion, glibmm_pcname, msvc14x_toolset_ver
 # Output: -
 
 glibmm_generate_extra_defs_library = library(
-  'glibmm_generate_extra_defs-' + glibmm_api_version,
+  'glibmm_generate_extra_defs' + msvc14x_toolset_ver + '-' + glibmm_api_version,
   'generate_extra_defs.cc',
   version: glibmm_libversion,
   cpp_args: '-DGLIBMM_GEN_EXTRA_DEFS_BUILD',


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