From 90c17ea2f0fa357b7f55a205bf1720ec0bc3245c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 26 Mar 2021 15:13:07 +0100 Subject: Meson build: Make it possible to use sigc++ as a subproject mm-common can be a subproject of sigc++. --- Makefile.am | 1 + docs/reference/meson.build | 8 ++++---- examples/meson.build | 4 ++-- meson.build | 16 +++++++++++++++- sigc++/meson.build | 14 ++++++++------ subprojects/mm-common.wrap | 9 +++++++++ tests/meson.build | 6 +++--- 7 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 subprojects/mm-common.wrap diff --git a/Makefile.am b/Makefile.am index 4c24f42..9a6f4a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,7 @@ EXTRA_DIST = \ docs/reference/meson.build \ examples/meson.build \ sigc++/meson.build \ + subprojects/mm-common.wrap \ tests/meson.build \ tools/handle-built-files.py \ tools/tutorial-custom-cmd.py \ diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 4eb402d..c968bfe 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -4,7 +4,7 @@ # sigcxx_api_version, build_documentation, source_h_files, # built_h_files, install_datadir, python3, doc_reference, # built_h_file_targets -# Output: install_docdir, install_devhelpdir +# Output: install_docdir, install_devhelpdir, tag_file tag_file_modules = [ 'mm-common-libstdc++', @@ -14,9 +14,9 @@ docinstall_flags = [] foreach module : tag_file_modules depmod = dependency(module, required: false) if depmod.found() - doxytagfile = depmod.get_pkgconfig_variable('doxytagfile') - htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '') - htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '') + doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile') + htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') + htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') if htmlrefpub == '' htmlrefpub = htmlrefdir elif htmlrefdir == '' diff --git a/examples/meson.build b/examples/meson.build index 501f196..d6efd8b 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,6 +1,6 @@ # examples -# input: sigcxx_dep, build_examples +# input: sigcxx_own_dep, build_examples examples = [ # [[dir-name], exe-name, [sources]] @@ -21,7 +21,7 @@ foreach ex : examples exe_file = executable(ex_name, ex_sources, cpp_args: '-DSIGCXX_DISABLE_DEPRECATED', - dependencies: sigcxx_dep, + dependencies: sigcxx_own_dep, gui_app: false, build_by_default: build_examples ) diff --git a/meson.build b/meson.build index b31ac07..7eb97aa 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,8 @@ project('libsigc++', 'cpp', 'cpp_std=c++11', 'warning_level=0', ], - meson_version: '>= 0.50.0', # required for python3.path() + meson_version: '>= 0.54.0', # required for meson.override_dependency() + # and dep.get_variable(internal:) ) sigcxx_api_version = '2.0' @@ -240,6 +241,19 @@ if not meson.is_subproject() project_source_root, 'untracked' / 'build_scripts', ) +else + # This is a subproject. + sigcxx_dep = declare_dependency( + dependencies: sigcxx_own_dep, + variables: { + 'doxytagfile': tag_file.full_path(), + 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', + 'htmlrefpub': 'http://library.gnome.org/devel/libsigc++/unstable/' + } + ) + + # A main project that looks for sigcxx_pcname.pc shall find sigcxx_dep. + meson.override_dependency(sigcxx_pcname, sigcxx_dep) endif # Print a summary. diff --git a/sigc++/meson.build b/sigc++/meson.build index 07212a0..ca453d8 100644 --- a/sigc++/meson.build +++ b/sigc++/meson.build @@ -2,7 +2,7 @@ # Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version, # install_includedir, project_source_root, sigc_res -# Output: source_h_files, built_h_files, sigcxx_dep, built_files_root, +# Output: source_h_files, built_h_files, sigcxx_own_dep, built_files_root, # built_h_file_targets source_cc_files = [ @@ -166,10 +166,11 @@ if maintainer_mode source_cc_files, built_cc_file_targets, built_h_file_targets, extra_sigc_objects, version: sigcxx_libversion, + darwin_versions: darwin_versions, cpp_args: extra_sigc_cppflags, + implicit_include_directories: false, include_directories: extra_include_dirs, dependencies: sigcxx_build_dep, - darwin_versions: darwin_versions, install: true, ) @@ -210,10 +211,11 @@ else # not maintainer_mode source_cc_files, untracked_built_cc_files, extra_sigc_objects, version: sigcxx_libversion, + darwin_versions: darwin_versions, cpp_args: extra_sigc_cppflags, + implicit_include_directories: false, include_directories: extra_include_dirs, dependencies: sigcxx_build_dep, - darwin_versions: darwin_versions, install: true, ) @@ -240,9 +242,9 @@ if not meson.is_subproject() ) endif -# This is useful in the main project when libsigc++ is used as a subproject. -# It's also used when building example programs and test programs. -sigcxx_dep = declare_dependency( +# This is used when building example programs and test programs. +# It's also a part of sigcxx_dep, when libsigc++ is a subproject. +sigcxx_own_dep = declare_dependency( sources: built_h_file_targets, link_with: sigcxx_library, include_directories: extra_include_dirs, diff --git a/subprojects/mm-common.wrap b/subprojects/mm-common.wrap new file mode 100644 index 0000000..296109f --- /dev/null +++ b/subprojects/mm-common.wrap @@ -0,0 +1,9 @@ +[wrap-git] +directory=mm-common +url=https://gitlab.gnome.org/GNOME/mm-common.git +revision=master +depth=1 + +[provide] +dependency_names = mm-common-libstdc++ +program_names = mm-common-get diff --git a/tests/meson.build b/tests/meson.build index ca5c318..5bdb407 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,6 @@ # tests -# input: sigcxx_dep, do_benchmark, can_benchmark, benchmark_dep +# input: sigcxx_own_dep, do_benchmark, can_benchmark, benchmark_dep benchmark_timeout = 100 @@ -57,7 +57,7 @@ foreach ex : test_programs endforeach exe_file = executable(ex_name, ex_sources, - dependencies: sigcxx_dep, + dependencies: sigcxx_own_dep, gui_app: false, build_by_default: true ) @@ -78,7 +78,7 @@ if can_benchmark endforeach exe_file = executable(ex_name, ex_sources, - dependencies: [sigcxx_dep, benchmark_dep], + dependencies: [sigcxx_own_dep, benchmark_dep], gui_app: false, build_by_default: do_benchmark ) -- cgit v1.2.1