Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling installation by default breaks projects using unity as meson subproject #661

Closed
nirs opened this issue Feb 21, 2023 · 0 comments · Fixed by #662
Closed

Enabling installation by default breaks projects using unity as meson subproject #661

nirs opened this issue Feb 21, 2023 · 0 comments · Fixed by #662

Comments

@nirs
Copy link
Contributor

nirs commented Feb 21, 2023

Since #658, when a project is consuming unity via meson subproject, installing the project
also install unity headers, static library, and pkgconfig file. I think this is always
unwanted since unity is a testing tool and never a runtime requirement.

A minimal reproducer

$ tree
.
├── meson.build
└── subprojects
    └── unity.wrap

$ cat meson.build 
project('unity-repr', 'c')
dependency('unity', fallback: ['unity', 'unity_dep'])

$ cat subprojects/unity.wrap 
[wrap-git]
url = https://github.com/ThrowTheSwitch/Unity.git
revision = head

Example build and install:

$ meson setup build
The Meson build system
Version: 1.0.0
Source dir: /home/nsoffer/tmp/unity-repr
Build dir: /home/nsoffer/tmp/unity-repr/build
Build type: native build
Project name: unity-repr
Project version: undefined
C compiler for the host machine: ccache cc (gcc 12.2.1 "cc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)")
C linker for the host machine: cc ld.bfd 2.38-25
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.8.0)
Found CMake: /usr/bin/cmake (3.25.2)
Run-time dependency unity found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency unity
Cloning into 'unity'...
remote: Enumerating objects: 6463, done.
remote: Counting objects: 100% (686/686), done.
remote: Compressing objects: 100% (340/340), done.
remote: Total 6463 (delta 421), reused 553 (delta 342), pack-reused 5777
Receiving objects: 100% (6463/6463), 6.79 MiB | 4.98 MiB/s, done.
Resolving deltas: 100% (4005/4005), done.

Executing subproject unity 

unity| Project name: unity
unity| Project version: 2.5.4
unity| C compiler for the host machine: ccache cc (gcc 12.2.1 "cc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)")
unity| C linker for the host machine: cc ld.bfd 2.38-25
unity| Program auto/generate_test_runner.rb found: YES (/home/nsoffer/tmp/unity-repr/subprojects/unity/auto/generate_test_runner.rb)
unity| Build targets in project: 1
unity| Subproject unity finished.

Dependency unity from subproject subprojects/unity found: YES 2.5.4
Build targets in project: 1

unity-repr undefined

  Subprojects
    unity: YES

Found ninja-1.10.2 at /usr/bin/ninja

$ meson compile -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/nsoffer/tmp/unity-repr/build
ninja: Entering directory `/home/nsoffer/tmp/unity-repr/build'
[2/2] Linking static target subprojects/unity/libunity.a

$ meson install --dry-run -C build
ninja: Entering directory `/home/nsoffer/tmp/unity-repr/build'
ninja: no work to do.
Installing subprojects/unity/libunity.a to /usr/local/lib64
Installing /home/nsoffer/tmp/unity-repr/subprojects/unity/src/unity.h to /usr/local/include/unity/
Installing /home/nsoffer/tmp/unity-repr/subprojects/unity/src/unity_internals.h to /usr/local/include/unity/
Installing /home/nsoffer/tmp/unity-repr/build/meson-private/unity.pc to /usr/local/lib64/pkgconfig

Expected behavior

The expected behavior is not installing anything when unity is built as a subproject.

Workaround

There is a workaround, installing with:

meson install --skip-subprojects unity

But this workaround need to be repeated in every distro packaging your project.

See also

nirs added a commit to nirs/Unity that referenced this issue Feb 21, 2023
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: ThrowTheSwitch#661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant