From 18482abd9ee11b7bf1e6aef0e4b81eda33a372f7 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Tue, 21 Feb 2023 01:26:54 +0200 Subject: [PATCH] Don't install anything when building as subproject When a project is consuming unity as as subproject, unity headers, static library and pkg config files are installed by `meson install`. This can be fixed by using `meson install --skip-subprojects`, but this must be repeated in all the distros packaging a project. Fixed by disabling install when building as a subproject. Fixes: #661 --- extras/fixture/src/meson.build | 12 +++++++----- extras/memory/src/meson.build | 10 ++++++---- meson.build | 18 ++++++++++-------- src/meson.build | 12 +++++++----- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/extras/fixture/src/meson.build b/extras/fixture/src/meson.build index 5d11470..224911d 100644 --- a/extras/fixture/src/meson.build +++ b/extras/fixture/src/meson.build @@ -1,8 +1,10 @@ unity_inc += include_directories('.') unity_src += files('unity_fixture.c') -install_headers( - 'unity_fixture.h', - 'unity_fixture_internals.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity_fixture.h', + 'unity_fixture_internals.h', + subdir: meson.project_name() + ) +endif diff --git a/extras/memory/src/meson.build b/extras/memory/src/meson.build index 53a66ca..650ba32 100644 --- a/extras/memory/src/meson.build +++ b/extras/memory/src/meson.build @@ -1,7 +1,9 @@ unity_inc += include_directories('.') unity_src += files('unity_memory.c') -install_headers( - 'unity_memory.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity_memory.h', + subdir: meson.project_name() + ) +endif diff --git a/meson.build b/meson.build index 708b295..c5cf971 100644 --- a/meson.build +++ b/meson.build @@ -45,7 +45,7 @@ endif unity_lib = static_library(meson.project_name(), sources: unity_src, include_directories: unity_inc, - install: true + install: not meson.is_subproject(), ) unity_dep = declare_dependency( @@ -54,13 +54,15 @@ unity_dep = declare_dependency( ) # Generate pkg-config file. -pkg = import('pkgconfig') -pkg.generate( - name: meson.project_name(), - version: meson.project_version(), - libraries: [ unity_lib ], - description: 'C Unit testing framework.' -) +if not meson.is_subproject() + pkg = import('pkgconfig') + pkg.generate( + name: meson.project_name(), + version: meson.project_version(), + libraries: [ unity_lib ], + description: 'C Unit testing framework.' + ) +endif # Create a generator that can be used by consumers of our build system to generate # test runners. diff --git a/src/meson.build b/src/meson.build index 4d7751f..5365227 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,8 +8,10 @@ unity_inc += include_directories('.') unity_src += files('unity.c') -install_headers( - 'unity.h', - 'unity_internals.h', - subdir: meson.project_name() -) +if not meson.is_subproject() + install_headers( + 'unity.h', + 'unity_internals.h', + subdir: meson.project_name() + ) +endif