diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-03-26 15:23:25 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-03-26 15:23:25 +0100 |
commit | 473f835911ca967a178edad3c6dd8c69183c2038 (patch) | |
tree | d8af7df1d595149ef2e1068ff631e7ab8193f32b | |
parent | f4f6dff1c96f60b93e47d6850a43e3e747ce3154 (diff) |
Meson build: Make it possible to use cairomm as a subproject
cairo and sigc++ can be subprojects of cairomm.
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | cairomm/meson.build | 9 | ||||
-rw-r--r-- | data/meson.build | 3 | ||||
-rw-r--r-- | docs/reference/meson.build | 8 | ||||
-rw-r--r-- | examples/meson.build | 4 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | subprojects/cairo.wrap | 8 | ||||
-rw-r--r-- | subprojects/sigc++-2.0.wrap | 8 | ||||
-rw-r--r-- | tests/meson.build | 4 |
9 files changed, 49 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am index 1f67414..4887a0d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,6 +50,8 @@ EXTRA_DIST = \ data/meson.build \ docs/reference/meson.build \ examples/meson.build \ + subprojects/cairo.wrap \ + subprojects/sigc++-2.0.wrap \ tests/meson.build \ untracked/README diff --git a/cairomm/meson.build b/cairomm/meson.build index 1c3304b..f940268 100644 --- a/cairomm/meson.build +++ b/cairomm/meson.build @@ -2,7 +2,7 @@ # Input: cairomm_build_dep, cairomm_pcname, cairomm_libversion, cairomm_rc, # is_msvc, cairomm_libname, macos_darwin_versions -# Output: source_h_files, cairomm_dep +# Output: source_h_files, cairomm_own_dep # There are no built source files in cairomm. @@ -83,15 +83,16 @@ cairomm_library = library(cairomm_libname, cairomm_cc, extra_cairomm_objects, version: cairomm_libversion, darwin_versions: macos_darwin_versions, + implicit_include_directories: false, include_directories: extra_include_dirs, cpp_args: cairomm_cpp_args, dependencies: cairomm_build_dep, install: true, ) -# This is useful in the main project when cairomm is used as a subproject. -# It's also used when building example programs and test programs. -cairomm_dep = declare_dependency( +# This is used when building example programs and test programs. +# It's also a part of cairomm_dep, when cairomm is a subproject. +cairomm_own_dep = declare_dependency( link_with: cairomm_library, include_directories: extra_include_dirs, dependencies: cairomm_build_dep diff --git a/data/meson.build b/data/meson.build index 775035b..d4e3bf4 100644 --- a/data/meson.build +++ b/data/meson.build @@ -33,6 +33,9 @@ foreach cairomm_mod : ['ft', 'pdf', 'png', 'ps', 'quartz', 'quartz-font', # Install the module only if there is a corresponding cairo module. if cairo_dep.type_name() == 'pkgconfig' do_install = dependency('cairo-' + cairomm_mod, required: false).found() + elif cairo_dep.type_name() == 'internal' + do_install = dependency('cairo-' + cairomm_mod, fallback: 'cairo', + required: false).found() else if cairomm_mod == 'png' do_install = cpp_compiler.has_function('cairo_surface_write_to_png', diff --git a/docs/reference/meson.build b/docs/reference/meson.build index c0fa34a..aebc8b9 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -3,7 +3,7 @@ # Input: project_build_root, project_source_root, cairomm_pcname, # build_documentation, source_h_files, install_datadir, python3, # doc_reference_py -# Output: install_docdir, install_devhelpdir, book_name +# Output: install_docdir, install_devhelpdir, book_name, tag_file # There are no built source files in cairomm. @@ -16,9 +16,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 1f60aea..c383432 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,6 +1,6 @@ # examples -# input: cairomm_dep, build_examples +# input: cairomm_own_dep, build_examples examples = [ # [[dir-name], exe-name, [sources]] @@ -26,7 +26,7 @@ foreach ex : examples executable(ex_name, ex_sources, cpp_args: '-DCAIROMM_DISABLE_DEPRECATED', - dependencies: cairomm_dep, + dependencies: cairomm_own_dep, gui_app: false, build_by_default: build_examples ) diff --git a/meson.build b/meson.build index ba158d6..17e004e 100644 --- a/meson.build +++ b/meson.build @@ -6,7 +6,8 @@ project('cairomm', 'cpp', default_options: [ 'cpp_std=c++11', ], - meson_version: '>= 0.50.0', # required for python3.path() + meson_version: '>= 0.54.0', # required for meson.override_dependency() + # and dep.get_variable(internal:) ) cairomm_api_version = '1.0' @@ -274,6 +275,19 @@ if not meson.is_subproject() project_source_root, 'untracked' / 'build_scripts', ) +else + # This is a subproject. + cairomm_dep = declare_dependency( + dependencies: cairomm_own_dep, + variables: { + 'doxytagfile': tag_file.full_path(), + 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', + 'htmlrefpub': 'http://www.cairographics.org/documentation/cairomm/reference' + } + ) + + # A main project that looks for cairomm_pcname.pc shall find cairomm_dep. + meson.override_dependency(cairomm_pcname, cairomm_dep) endif # Print a summary. diff --git a/subprojects/cairo.wrap b/subprojects/cairo.wrap new file mode 100644 index 0000000..954daa3 --- /dev/null +++ b/subprojects/cairo.wrap @@ -0,0 +1,8 @@ +[wrap-git] +directory=cairo +url=https://gitlab.freedesktop.org/cairo/cairo.git +revision=master +depth=1 + +[provide] +dependency_names = cairo diff --git a/subprojects/sigc++-2.0.wrap b/subprojects/sigc++-2.0.wrap new file mode 100644 index 0000000..3efff75 --- /dev/null +++ b/subprojects/sigc++-2.0.wrap @@ -0,0 +1,8 @@ +[wrap-git] +directory=libsigcplusplus-2.0 +url=https://github.com/libsigcplusplus/libsigcplusplus.git +revision=libsigc++-2-10 +depth=1 + +[provide] +dependency_names = sigc++-2.0 diff --git a/tests/meson.build b/tests/meson.build index 530eb73..9aa6742 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,6 @@ # tests -# input: cairomm_dep, build_tests, can_test, test_dep, USE_SHARED_BOOST +# input: cairomm_own_dep, build_tests, can_test, test_dep, USE_SHARED_BOOST cairomm_tests_extra_cppargs = [] if USE_SHARED_BOOST @@ -34,7 +34,7 @@ if can_test boost_test_modname_flag = [ '-DBOOST_TEST_MODULE=@0@'.format(ex[1]) ] exe_file = executable(ex_name, ex_sources, cpp_args: ex[3] + boost_test_modname_flag + cairomm_tests_extra_cppargs, - dependencies: [cairomm_dep, test_dep], + dependencies: [cairomm_own_dep, test_dep], gui_app: false, build_by_default: build_tests, ) |