[gtkmm/gtkmm-3-24] Meson/Visual Studio builds: Include toolset version by default
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-3-24] Meson/Visual Studio builds: Include toolset version by default
- Date: Tue, 30 Jun 2020 03:43:44 +0000 (UTC)
commit c06eb8f8f3c86167bf6309e30b3167fc696df38e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Jun 30 11:42:19 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.
configure.ac | 1 +
gdk/gdkmm-uninstalled.pc.in | 2 +-
gdk/gdkmm.pc.in | 2 +-
gdk/gdkmm/meson.build | 8 ++++----
gtk/gtkmm-uninstalled.pc.in | 2 +-
gtk/gtkmm.pc.in | 2 +-
gtk/gtkmm/meson.build | 9 +++++----
meson.build | 21 +++++++++++++++++++++
meson_options.txt | 2 ++
tools/extra_defs_gen/meson.build | 4 ++--
10 files changed, 39 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index caef2701..e649745d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,6 +136,7 @@ MM_ARG_WITH_TAGFILE_DOC([atkmm-1.6.tag], [atkmm-1.6])
# glib-compile-resources and C compiler are needed to generate and compile
# resource files in demo programs.
AC_SUBST(GLIB_COMPILE_RESOURCES, [`$PKG_CONFIG --variable=glib_compile_resources gio-2.0`])
+AC_SUBST([MSVC_TOOLSET_VER], [''])
AC_PROG_CC
AC_LANG([C++])
diff --git a/gdk/gdkmm-uninstalled.pc.in b/gdk/gdkmm-uninstalled.pc.in
index a8fb5c5d..6e1647bb 100644
--- a/gdk/gdkmm-uninstalled.pc.in
+++ b/gdk/gdkmm-uninstalled.pc.in
@@ -6,5 +6,5 @@ Description: C++ binding for the GDK drawing kit, not installed
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @GDKMM_MODULES@
-Libs: ${pc_top_builddir}/${pcfiledir}/gdkmm/libgdkmm-@GDKMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/gdkmm/libgdkmm@MSVC_TOOLSET_VER@-@GDKMM_API_VERSION@.la
Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/gdk/gdkmm.pc.in b/gdk/gdkmm.pc.in
index 286dc8f6..4cd92522 100644
--- a/gdk/gdkmm.pc.in
+++ b/gdk/gdkmm.pc.in
@@ -15,5 +15,5 @@ Description: C++ binding for the GDK drawing kit
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @GDKMM_MODULES@
-Libs: -L${libdir} -lgdkmm-@GDKMM_API_VERSION@
+Libs: -L${libdir} -lgdkmm@MSVC_TOOLSET_VER@-@GDKMM_API_VERSION@
Cflags: -I${includedir}/@GDKMM_MODULE_NAME@ -I${libdir}/@GDKMM_MODULE_NAME@/include
diff --git a/gdk/gdkmm/meson.build b/gdk/gdkmm/meson.build
index 22dc4648..8d9e74f3 100644
--- a/gdk/gdkmm/meson.build
+++ b/gdk/gdkmm/meson.build
@@ -4,7 +4,7 @@
# generate_binding_py, m4_files, gtkmm_libversion, install_includedir,
# python3, gdkmm_rc, dummy_header_py, gmmproc_dir, build_shared_libs_directly,
# build_deprecated_api, gmmproc_extra_m4_dirs, is_host_windows,
-# gdkmm_extra_gendef_cpp_args
+# gdkmm_extra_gendef_cpp_args, gdkmm_libname
# Output: gdkmm_hg_ccg_basenames, gdkmm_extra_h_files, built_files_root,
# gdkmm_built_h_file_targets, gdkmm_used_built_h_file_targets, gdkmm_dep
@@ -224,7 +224,7 @@ if is_host_windows
endif
if build_shared_libs_directly
- gdkmm_library = library(gdkmm_pcname, extra_gdkmm_objects,
+ gdkmm_library = library(gdkmm_libname, extra_gdkmm_objects,
gdk_gen_sources, built_dummy_h_file_target, gdkmm_extra_cc_files,
include_directories: extra_include_dirs,
cpp_args: gdkmm_cpp_args,
@@ -250,14 +250,14 @@ else
depends: gdk_int_lib,
command: [ gendef,
'@OUTPUT@',
- '@0@-@1@.dll'.format(gdkmm_pcname, gtkmm_libversion.split('.')[0]),
+ '@0@-@1@.dll'.format(gdkmm_libname, gtkmm_libversion.split('.')[0]),
gdk_int_lib.full_path(),
],
install: false,
)
gdkmm_extra_link_args = ['/def:@0@'.format(gdkmm_def.full_path())]
- gdkmm_library = library(gdkmm_pcname, extra_gdkmm_objects,
+ gdkmm_library = library(gdkmm_libname, extra_gdkmm_objects,
objects: gdk_int_lib.extract_all_objects(),
version: gtkmm_libversion,
dependencies: gdkmm_build_dep,
diff --git a/gtk/gtkmm-uninstalled.pc.in b/gtk/gtkmm-uninstalled.pc.in
index 2a569d6b..36dd366e 100644
--- a/gtk/gtkmm-uninstalled.pc.in
+++ b/gtk/gtkmm-uninstalled.pc.in
@@ -6,5 +6,5 @@ Description: C++ binding for the GTK+ toolkit, not installed
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @GTKMM_MODULES@ @GDKMM_MODULE_NAME@-uninstalled
-Libs: ${pc_top_builddir}/${pcfiledir}/gtkmm/libgtkmm-@GTKMM_API_VERSION@.la
+Libs: ${pc_top_builddir}/${pcfiledir}/gtkmm/libgtkmm@MSVC_TOOLSET_VER@-@GTKMM_API_VERSION@.la
Cflags: -I${pc_top_builddir}/${pcfiledir} -I${pc_top_builddir}/${pcfiledir}/@srcdir@
diff --git a/gtk/gtkmm.pc.in b/gtk/gtkmm.pc.in
index 33bcf5cf..3f8dd5eb 100644
--- a/gtk/gtkmm.pc.in
+++ b/gtk/gtkmm.pc.in
@@ -17,5 +17,5 @@ Description: C++ binding for the GTK+ toolkit
Version: @PACKAGE_VERSION@
URL: http://www.gtkmm.org/
Requires: @GTKMM_MODULES@ @GDKMM_MODULE_NAME@
-Libs: -L${libdir} -lgtkmm-@GTKMM_API_VERSION@
+Libs: -L${libdir} -lgtkmm@MSVC_TOOLSET_VER@-@GTKMM_API_VERSION@
Cflags: -I${includedir}/@GTKMM_MODULE_NAME@ -I${libdir}/@GTKMM_MODULE_NAME@/include
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index c8ffbd43..4f300920 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -4,7 +4,8 @@
# generate_binding_py, m4_files, gtkmm_libversion, install_includedir,
# python3, gtkmm_rc, dummy_header_py, gmmproc_dir, build_shared_libs_directly,
# build_deprecated_api, build_x11_api, gmmproc_extra_m4_dirs, is_host_windows,
-# gdkmm_library, gdkmm_used_built_h_file_targets, gtkmm_extra_gendef_cpp_args
+# gdkmm_library, gdkmm_used_built_h_file_targets, gtkmm_extra_gendef_cpp_args,
+# gtkmm_libname
# Output: gtkmm_hg_ccg_basenames, gtkmm_extra_h_files, built_files_root,
# gtkmm_built_h_file_targets, gtkmm_dep
@@ -489,7 +490,7 @@ if is_host_windows
endif
if build_shared_libs_directly
- gtkmm_library = library(gtkmm_pcname, extra_gtkmm_objects,
+ gtkmm_library = library(gtkmm_libname, extra_gtkmm_objects,
gtk_gen_sources, built_dummy_h_file_target, gtkmm_extra_used_cc_files,
include_directories: extra_include_dirs,
cpp_args: gtkmm_cpp_args,
@@ -517,14 +518,14 @@ else
depends: gtk_int_lib,
command: [ gendef,
'@OUTPUT@',
- '@0@-@1@.dll'.format(gtkmm_pcname, gtkmm_libversion.split('.')[0]),
+ '@0@-@1@.dll'.format(gtkmm_libname, gtkmm_libversion.split('.')[0]),
gtk_int_lib.full_path(),
],
install: false,
)
gtkmm_extra_link_args = ['/def:@0@'.format(gtkmm_def.full_path())]
- gtkmm_library = library(gtkmm_pcname, extra_gtkmm_objects,
+ gtkmm_library = library(gtkmm_libname, extra_gtkmm_objects,
objects: gtk_int_lib.extract_all_objects(),
version: gtkmm_libversion,
dependencies: gtkmm_build_dep,
diff --git a/meson.build b/meson.build
index c2c8e045..c31b3292 100644
--- a/meson.build
+++ b/meson.build
@@ -220,6 +220,12 @@ dummy_header_py = gtkmm_script_dir / 'dummy-header.py'
# Do we build the gdkmm/gtkmm without using gendef.exe?
gdkmm_extra_gendef_cpp_args = []
gtkmm_extra_gendef_cpp_args = []
+
+# Include Visual Studio toolset version in DLL/.lib file names
+# in Visual Studio 2015 and later (enabled by default)
+use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
+msvc14x_toolset_ver = ''
+
if is_msvc
add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp')
add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8']), language: 'c')
@@ -246,10 +252,25 @@ if is_msvc
gdkmm_extra_gendef_cpp_args += '-DGDKMM_USE_GENDEF'
gtkmm_extra_gendef_cpp_args = gdkmm_extra_gendef_cpp_args + [ '-DGTKMM_USE_GENDEF' ]
endif
+
+ 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
else
build_shared_libs_directly = true
endif
+gtkmm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + gtkmm_api_version
+gdkmm_libname = 'gdkmm' + msvc14x_toolset_ver + '-' + gtkmm_api_version
+
# Set compiler warnings.
warning_flags = []
if warning_level == 'min'
diff --git a/meson_options.txt b/meson_options.txt
index 521e6d85..26ff3180 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -14,3 +14,5 @@ option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-m
value: 'if-maintainer-mode', description: 'Build and install the documentation')
option('build-demos', type: 'boolean', value: true, description: 'Build demo programs')
option('build-tests', type: 'boolean', value: true, description: 'Build test 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 8c654c71..942afcde 100644
--- a/tools/extra_defs_gen/meson.build
+++ b/tools/extra_defs_gen/meson.build
@@ -1,11 +1,11 @@
# tools/extra_defs_gen
# Input: cpp_compiler, gdkmm_build_dep, gtkmm_build_dep, install_libdir,
-# gtkmm_pcname
+# gtkmm_pcname, msvc14x_toolset_ver
# Output: m4_files, install_m4dir
glibmm_generate_extra_defs_dep = cpp_compiler.find_library(
- 'glibmm_generate_extra_defs-2.4',
+ 'glibmm_generate_extra_defs@0@-2.4'.format(msvc14x_toolset_ver),
)
executable('generate_defs_gdk', 'generate_defs_gdk.cc',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]