"Fossies" - the Fresh Open Source Software Archive

Member "glibmm-2.74.0/meson.build" (19 Sep 2022, 15474 Bytes) of package /linux/misc/glibmm-2.74.0.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes reports for "meson.build": 2.73.2_vs_2.74.0 or 2.72.1_vs_2.74.0.

    1 # This file is part of glibmm.
    2 
    3 project('glibmm', 'cpp',
    4   version: '2.74.0',
    5   license: 'LGPLv2.1+',
    6   default_options: [
    7     'cpp_std=c++17',
    8     'warning_level=1',
    9   ],
   10   meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
   11                               # and meson.add_install_script(python3, ...)
   12 )
   13 
   14 glibmm_api_version = '2.68'
   15 glibmm_pcname = meson.project_name() + '-' + glibmm_api_version
   16 giomm_pcname = 'giomm-' + glibmm_api_version
   17 
   18 glibmm_version_array = meson.project_version().split('.')
   19 glibmm_major_version = glibmm_version_array[0].to_int()
   20 glibmm_minor_version = glibmm_version_array[1].to_int()
   21 glibmm_micro_version = glibmm_version_array[2].to_int()
   22 
   23 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
   24 # The relation between libtool's current:revison:age interface versioning
   25 # and the .so filename, .so.x.y.z, is
   26 # x = current - age
   27 # y = age
   28 # z = revision
   29 # If libtool_soversion is updated as described in libtool's documentation,
   30 # x.y.z will usually *not* be equal to meson.project_version().
   31 libtool_soversion = [4, 0, 3]
   32 glibmm_libversion = '@0@.@1@.@2@'.format(
   33   libtool_soversion[0] - libtool_soversion[2],
   34   libtool_soversion[2],
   35   libtool_soversion[1]
   36 )
   37 macos_darwin_versions = [
   38   libtool_soversion[0] + 1,
   39   '@0@.@1@'.format(libtool_soversion[0] + 1, libtool_soversion[1])
   40 ]
   41 
   42 # Use these instead of meson.source_root() and meson.build_root() in subdirectories.
   43 # source_root() and build_root() are not useful, if this is a subproject.
   44 project_source_root = meson.current_source_dir()
   45 project_build_root = meson.current_build_dir()
   46 
   47 cpp_compiler = meson.get_compiler('cpp')
   48 is_msvc = cpp_compiler.get_id() == 'msvc'
   49 is_host_windows = host_machine.system() == 'windows'
   50 is_os_cocoa = host_machine.system() == 'darwin'
   51 
   52 python3 = import('python').find_installation()
   53 python_version = python3.language_version()
   54 python_version_req = '>= 3.5'
   55 if not python_version.version_compare(python_version_req)
   56   error('Requires Python @0@, found @1@.'.format(python_version_req, python_version))
   57 endif
   58 
   59 # Do we build from a git repository?
   60 # Suppose we do if and only if a '.git' directory or file exists.
   61 cmd_py = '''
   62 import os
   63 import sys
   64 sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
   65 '''.format(project_source_root / '.git')
   66 is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0
   67 
   68 # Are we testing a dist tarball while it's being built?
   69 # There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866
   70 is_dist_check = project_source_root.contains('dist-unpack') and \
   71                 project_build_root.contains('dist-build')
   72 
   73 # Options.
   74 maintainer_mode_opt = get_option('maintainer-mode')
   75 maintainer_mode = maintainer_mode_opt == 'true' or \
   76                  (maintainer_mode_opt == 'if-git-build' and is_git_build)
   77 if is_dist_check
   78   message('Looks like a tarball is being tested. ' + \
   79           'Option "dist-warnings" is used instead of "warnings".')
   80   cpp_warnings = get_option('dist-warnings')
   81 else
   82   cpp_warnings = get_option('warnings')
   83 endif
   84 warning_level = get_option('warning_level').to_int()
   85 werror = get_option('werror')
   86 build_deprecated_api = get_option('build-deprecated-api')
   87 build_documentation_opt = get_option('build-documentation')
   88 build_documentation = build_documentation_opt == 'true' or \
   89                      (build_documentation_opt == 'if-maintainer-mode' and maintainer_mode)
   90 build_examples = get_option('build-examples')
   91 
   92 use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable')
   93 
   94 # Installation directories are relative to {prefix}.
   95 install_prefix = get_option('prefix')
   96 install_includedir = get_option('includedir')
   97 install_libdir = get_option('libdir')
   98 install_datadir = get_option('datadir')
   99 install_pkgconfigdir = install_libdir / 'pkgconfig'
  100 
  101 # Dependencies. <pkg> = glib and gio
  102 # <pkg>mm_build_dep: Dependencies when building the <pkg>mm library.
  103 # <pkg>mm_dep (created in <pkg>/<pkg>mm/meson.build):
  104 #   Dependencies when using the <pkg>mm library.
  105 
  106 sigcxx_req = '>= 3.0.0'
  107 glib_req = '>= 2.73.2'
  108 
  109 # There are pkg-config files for sigc++ and glib on MSVC, so just use that.
  110 sigcxx_dep = dependency('sigc++-3.0', version: sigcxx_req)
  111 glib_dep = dependency('glib-2.0', version: glib_req)
  112 gobject_dep = dependency('gobject-2.0', version: glib_req)
  113 gmodule_dep = dependency('gmodule-2.0', version: glib_req)
  114 
  115 glibmm_build_dep = [sigcxx_dep, glib_dep, gobject_dep, gmodule_dep]
  116 glibmm_requires = [
  117   'sigc++-3.0', sigcxx_req,
  118   'glib-2.0', glib_req,
  119   'gobject-2.0', glib_req,
  120   'gmodule-2.0', glib_req,
  121 ]
  122 
  123 gio_dep = dependency('gio-2.0', version: glib_req)
  124 giomm_build_dep = glibmm_build_dep + [gio_dep]
  125 giomm_requires = glibmm_requires + ['gio-2.0', glib_req]
  126 if not is_host_windows
  127   gio_unix_dep = dependency('gio-unix-2.0', version: glib_req)
  128   giomm_build_dep += gio_unix_dep
  129   giomm_requires += ['gio-unix-2.0', glib_req]
  130 endif
  131 
  132 glibmm_requires = ' '.join(glibmm_requires)
  133 giomm_requires = ' '.join(giomm_requires)
  134 
  135 # Some dependencies are required only in maintainer mode and/or if
  136 # reference documentation shall be built.
  137 mm_common_get = find_program('mm-common-get', required: false)
  138 if maintainer_mode and not mm_common_get.found()
  139   message('Maintainer mode requires the \'mm-common-get\' command. If it is not found,\n' +
  140           'install the \'mm-common\' package, version 1.0.0 or higher.')
  141   # If meson --wrap-mode != forcefallback, Meson falls back to the mm-common
  142   # subproject only if mm-common-get is required.
  143   mm_common_get = find_program('mm-common-get', required: true)
  144 endif
  145 m4 = find_program('m4', required: maintainer_mode) # Used by gmmproc
  146 doxygen = find_program('doxygen', required: build_documentation)
  147 dot = find_program('dot', required: build_documentation) # Used by Doxygen
  148 xsltproc = find_program('xsltproc', required: build_documentation)
  149 
  150 # Where to find gmmproc and generate_wrap_init.pl.
  151 gmmproc_dir = project_build_root / 'tools'
  152 
  153 # Script files copied to 'untracked' by mm-common-get.
  154 script_dir = project_source_root / 'untracked' / 'build_scripts'
  155 generate_binding_py = script_dir / 'generate-binding.py'
  156 doc_reference_py = script_dir / 'doc-reference.py'
  157 dist_changelog_py = script_dir / 'dist-changelog.py'
  158 dist_build_scripts_py = script_dir / 'dist-build-scripts.py'
  159 
  160 if maintainer_mode
  161   # Copy files to untracked/build_scripts and untracked/docs.
  162   run_command(mm_common_get, '--force', script_dir,
  163     project_source_root / 'untracked' / 'docs',
  164     check: true,
  165   )
  166 else
  167   cmd_py = '''
  168 import os
  169 import sys
  170 sys.exit(os.path.isfile("@0@"))
  171 '''.format(generate_binding_py)
  172   file_exists = run_command(python3, '-c', cmd_py, check: false).returncode() != 0
  173   if not file_exists
  174     error('Missing files in untracked/. You must enable maintainer-mode.')
  175   endif
  176 endif
  177 
  178 # Check if perl is required and available.
  179 doc_perl_prop = run_command(
  180   python3, doc_reference_py, 'get_script_property',
  181   '', # MMDOCTOOLDIR is not used
  182   'requires_perl',
  183   check: false,
  184 )
  185 doc_requires_perl = true
  186 if doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false'
  187   doc_requires_perl = false
  188 endif
  189 
  190 perl = find_program('perl', required: maintainer_mode or \
  191   (build_documentation and doc_requires_perl))
  192 
  193 # glibmm's own script files.
  194 glibmm_script_dir = project_source_root / 'tools' / 'build_scripts'
  195 handle_built_files_py = glibmm_script_dir / 'handle-built-files.py'
  196 dummy_header_py = glibmm_script_dir / 'dummy-header.py'
  197 compile_schemas_py = glibmm_script_dir / 'compile-schemas.py'
  198 
  199 # Set compiler warnings.
  200 # Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
  201 # compiler options are added with add_project_arguments().
  202 # Avoid such warnings, when possible.
  203 # See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
  204 warning_flags = []
  205 if cpp_warnings == 'min'
  206   if warning_level == 0
  207     warning_flags = is_msvc ? ['/W2'] : ['-Wall']
  208   endif
  209 elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
  210   if warning_level < 3
  211     warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
  212   endif
  213   if not is_msvc
  214     warning_flags += '-Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
  215   endif
  216   if cpp_warnings == 'fatal'
  217     if not werror
  218       warning_flags += is_msvc ? ['/WX'] : ['-Werror']
  219     endif
  220     deprecations = 'G SIGCXX'.split()
  221     foreach d : deprecations
  222       warning_flags += '-D@0@_DISABLE_DEPRECATED'.format(d)
  223     endforeach
  224   endif
  225 endif
  226 
  227 warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
  228 add_project_arguments(warning_flags, language: 'cpp')
  229 
  230 # Add toolset version in builds done with Visual Studio 2015 (v14x) or later
  231 msvc14x_toolset_ver = ''
  232 
  233 # MSVC: Ignore warnings that aren't really harmful, but make those
  234 #       that should not be overlooked stand out.
  235 if is_msvc
  236   disable_warnings_list = [
  237     '/FImsvc_recommended_pragmas.h', # Turn off harmless warnings but make potentially
  238                                      # dangerous ones glaring, distributed with GLib
  239     '/EHsc',  # avoid warnings caused by exception handling model used
  240     '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales
  241     '/wd4589', # Constructor of abstract class 'bb' ignores
  242                # initializer for virtual base class 'aa'
  243     '/wd4702', # unreachable code
  244   ]
  245   if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64'
  246   # 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds)
  247     disable_warnings_list += '/wd4267'
  248   endif
  249   add_project_arguments(
  250     cpp_compiler.get_supported_arguments(disable_warnings_list),
  251     language: 'cpp',
  252   )
  253 
  254   if use_msvc14x_toolset_ver
  255     if cpp_compiler.version().version_compare('>=19.30')
  256       msvc14x_toolset_ver = '-vc143'
  257     elif cpp_compiler.version().version_compare('>=19.20')
  258       msvc14x_toolset_ver = '-vc142'
  259     elif cpp_compiler.version().version_compare('>=19.10')
  260       msvc14x_toolset_ver = '-vc141'
  261     elif cpp_compiler.version().version_compare('>=19.00')
  262       msvc14x_toolset_ver = '-vc140'
  263     else
  264       message('Visual Studio toolset version not applied for pre-Visual Studio 2015 builds')
  265     endif
  266   endif
  267 endif
  268 
  269 glibmm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + glibmm_api_version
  270 giomm_libname = 'giomm' + msvc14x_toolset_ver + '-' + glibmm_api_version
  271 
  272 # add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0.
  273 can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0')
  274 
  275 subdir('tools')
  276 subdir('glib')
  277 subdir('MSVC_NMake/glibmm')
  278 subdir('glib/glibmm')
  279 subdir('gio')
  280 subdir('MSVC_NMake/giomm')
  281 subdir('gio/giomm')
  282 subdir('examples')
  283 subdir('tests')
  284 subdir('docs/reference')
  285 
  286 if can_add_dist_script
  287   # Add a ChangeLog file to the distribution directory.
  288   meson.add_dist_script(
  289     python3, dist_changelog_py,
  290     project_source_root,
  291   )
  292 
  293   # Don't distribute this file.
  294   dont_distribute = [
  295     '.gitlab-ci.yml',
  296   ]
  297   # Add build scripts to the distribution directory, and delete .gitignore
  298   # files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
  299   meson.add_dist_script(
  300     python3, dist_build_scripts_py,
  301     project_source_root,
  302     'untracked' / 'build_scripts',
  303     dont_distribute,
  304   )
  305 endif
  306 
  307 if meson.is_subproject()
  308   # A version of gmmproc that can be executed uninstalled by a main project.
  309   conf_data_subproj = configuration_data()
  310   conf_data_subproj.merge_from(gmmproc_conf_data)
  311   conf_data_subproj.set('configure_input', 'tools/gmmproc (for execution uninstalled).  Generated from gmmproc.in')
  312   conf_data_subproj.set('libdir', project_build_root)
  313   gmmproc_subproj = configure_file(
  314     input: 'tools' / 'gmmproc.in',
  315     output: '@BASENAME@',
  316     configuration: conf_data_subproj,
  317     install: false,
  318   )
  319   gmmproc_subproj_dir = project_build_root / glibmm_pcname / 'proc'
  320   run_command(
  321     python3, handle_built_files_py, 'copy_built_files',
  322     project_build_root,
  323     gmmproc_subproj_dir,
  324     'gmmproc',
  325     check: true,
  326   )
  327   run_command(
  328     python3, handle_built_files_py, 'copy_built_files',
  329     project_build_root / 'tools',
  330     gmmproc_subproj_dir,
  331     'generate_wrap_init.pl',
  332     check: true,
  333   )
  334 
  335   # Copy files needed by gmmproc from source dir to build dir.
  336   # The directory structure must be the same as in the installation directory.
  337   run_command(
  338     python3, handle_built_files_py, 'copy_built_files',
  339     project_source_root / 'tools' / 'm4',
  340     gmmproc_subproj_dir / 'm4',
  341     m4_basefiles,
  342     check: true,
  343   )
  344   run_command(
  345     python3, handle_built_files_py, 'copy_built_files',
  346     project_source_root / 'tools' / 'pm',
  347     gmmproc_subproj_dir / 'pm',
  348     pm_basefiles,
  349     check: true,
  350   )
  351 
  352   pkgconfig_vars = {
  353     'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html',
  354     'htmlrefpub': 'http://library.gnome.org/devel/' + pkg_conf_data.get_unquoted('PACKAGE_TARNAME') + '/unstable/'
  355   }
  356   if build_documentation
  357     pkgconfig_vars += {'doxytagfile': tag_file.full_path()}
  358     # May be used in a main project.
  359     global_tag_file_target = tag_file
  360   endif
  361   giomm_dep = declare_dependency(
  362     dependencies: giomm_own_dep,
  363     variables: pkgconfig_vars,
  364   )
  365 
  366   pkgconfig_vars += {'gmmprocdir': gmmproc_subproj_dir}
  367   glibmm_dep = declare_dependency(
  368     dependencies: glibmm_own_dep,
  369     variables: pkgconfig_vars,
  370   )
  371 
  372   # A main project that looks for glibmm_pcname.pc and giomm_pcname.pc
  373   # shall find glibmm_dep and giomm_dep.
  374   meson.override_dependency(glibmm_pcname, glibmm_dep)
  375   meson.override_dependency(giomm_pcname, giomm_dep)
  376 endif
  377 
  378 # Print a summary.
  379 real_maintainer_mode = ''
  380 if maintainer_mode_opt == 'if-git-build'
  381   real_maintainer_mode = ' (@0@)'.format(maintainer_mode)
  382 endif
  383 
  384 real_build_documentation = ''
  385 if build_documentation_opt == 'if-maintainer-mode'
  386   real_build_documentation = ' (@0@)'.format(build_documentation)
  387 endif
  388 
  389 summary = [
  390   '',
  391   '------',
  392   meson.project_name() + ' ' + meson.project_version(),
  393   '',
  394   '         Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
  395   '       Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
  396                              format(cpp_warnings, warning_level, werror),
  397   '    Build deprecated API: @0@'.format(build_deprecated_api),
  398   'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
  399   '  Build example programs: @0@'.format(build_examples),
  400   'Directories:',
  401   '                  prefix: @0@'.format(install_prefix),
  402   '              includedir: @0@'.format(install_prefix / install_includedir),
  403   '        includeglibmmdir: @0@'.format(install_prefix / install_includedir / glibmm_pcname),
  404   '         includegiommdir: @0@'.format(install_prefix / install_includedir / giomm_pcname),
  405   '                  libdir: @0@'.format(install_prefix / install_libdir),
  406   '         glibmmconfigdir: @0@'.format(install_prefix / install_glibmmconfigdir),
  407   '          giommconfigdir: @0@'.format(install_prefix / install_giommconfigdir),
  408   '              gmmprocdir: @0@'.format(install_prefix / install_procdir),
  409   '            pkgconfigdir: @0@'.format(install_prefix / install_pkgconfigdir),
  410   '                 datadir: @0@'.format(install_prefix / install_datadir),
  411   '                  docdir: @0@'.format(install_prefix / install_docdir),
  412   '              devhelpdir: @0@'.format(install_prefix / install_devhelpdir),
  413   '------'
  414 ]
  415 
  416 message('\n'.join(summary))