[template-glib: 1/2] Error out build early when is a subproject without -Dpackage_subdir




commit 8f50f0da5d3821137c5626e2bda20a31f4eb54a9
Author: Tristan Partin <tristan partin io>
Date:   Sat May 7 11:25:28 2022 -0500

    Error out build early when is a subproject without -Dpackage_subdir

 meson.build     |  7 ++++++-
 src/meson.build | 12 ------------
 2 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/meson.build b/meson.build
index 4d485b3..ca39a71 100644
--- a/meson.build
+++ b/meson.build
@@ -5,6 +5,12 @@ project('template-glib', 'c',
   default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
 )
 
+package_subdir = get_option('package_subdir')
+
+if meson.is_subproject() and package_subdir == ''
+  error('-Dpackage_subdir must be set when using @0@ as a subproject'.format(meson.project_name()))
+endif
+
 version_arr = meson.project_version().split('.')
 template_glib_version_major = version_arr[0].to_int()
 template_glib_version_minor = version_arr[1].to_int()
@@ -119,7 +125,6 @@ add_project_arguments(
 )
 
 # Setup various paths that subdirectory meson.build files need
-package_subdir = get_option('package_subdir')
 libdir = join_paths(get_option('libdir'), package_subdir)
 includedir = join_paths(get_option('includedir'), package_subdir)
 girdir = join_paths(get_option('datadir'), package_subdir, 'gir-1.0')
diff --git a/src/meson.build b/src/meson.build
index 7ba2c62..6495bc0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -133,10 +133,6 @@ libtemplate_glib_sources = [
   'tmpl-util.c',
 ]
 
-if libdir == '' or includedir == ''
-  error('You must set pkglibdir and pkgincludedir when using as a subproject')
-endif
-
 core_lib = static_library('template_glib', libtemplate_glib_sources,
    dependencies: libtemplate_glib_deps,
          c_args: release_args,
@@ -167,10 +163,6 @@ libtemplate_glib_dep = declare_dependency(
 )
 
 if generate_gir
-  if girdir == '' or typelibdir == ''
-    error('You must set pkggirdir and pkgtypelidir when using as a subproject')
-  endif
-
   libtemplate_glib_gir = gnome.generate_gir(libtemplate_glib,
                 sources: libtemplate_glib_generated_headers + libtemplate_glib_public_headers + 
libtemplate_glib_public_sources,
               nsversion: apiversion,
@@ -189,10 +181,6 @@ if generate_gir
   )
 
   if get_option('vapi')
-    if vapidir == ''
-      error('You must set pkgvapidir when using as a subproject')
-    endif
-
     libtemplate_glib_vapi = gnome.generate_vapi('template-glib-' + apiversion,
           sources: libtemplate_glib_gir[0],
          packages: [ 'gio-2.0' ],


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