The CMake module doesn't allow for native dependencies when cross compiling
See original GitHub issueI’m not sure whether this counts as a bug or as a feature request.
Describe the bug
When cross compiling (i.e. with --cross-file
), it is not possible to use include('cmake').subproject('foo').dependency('bar')
in a native build target. This is possible when using regular subprojects and with dependency()
. <cmake_subproject>.dependency()
also does not support the native
option.
To Reproduce
-
Create a project with a
meson.build
file like this:# meson.build project('projectname', 'cpp', version : '1.0.0') cmake = import('cmake') vst3_sdk_options = cmake.subproject_options() vst3_sdk_options.add_cmake_defines({ 'SMTG_ADD_VST3_HOSTING_SAMPLES': 'OFF', 'SMTG_ADD_VST3_PLUGINS_SAMPLES': 'OFF', 'SMTG_ADD_VSTGUI': 'OFF', }) vst3_sdk = cmake.subproject('vst3', options : vst3_sdk_options) vst3_pluginterfaces_dep = vst3_sdk.dependency('pluginterfaces') shared_library( 'some-library', ['src/some-library.cpp'], native : true, dependencies : [vst3_pluginterfaces_dep], )
With some arbitrary
cross.conf
file, for instance:# cross.conf [binaries] c = 'gcc' cpp = 'g++' ar = 'ar' strip = 'strip' pkgconfig = 'pkg-config'
And the following wrap file in
subprojects/vst3.wrap
(any CMake project will work, this is just how I ran into this issue):# subprojects/vst3.wrap [wrap-git] url = https://github.com/robbert-vdh/vst3sdk.git revision = 2a1a230d45766532360a2f432083f0795f2b0d93 clone-recursive = true depth = 1
-
Create an empty
src/some-library.cpp
file. -
Now try to initialize the project with
meson setup build --cross-file cross.conf
.
Expected behavior
The project gets created without any errors. Running ninja -C build
should compile the empty file without any issues.
Observed behavior
Meson errors out during meson setup
with the following error:
meson.build:14:3: ERROR: Tried to mix libraries for machines 0 and 1 in target 'some-library' This is not possible in a cross build.
system parameters
- Cross build: yes
- Operating system: Manjaro Linux
- Python version: 3.8.6
- Meson version: 0.56.0
- Ninja version: 1.10.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Ya, its a know deficiency, it’s on my list is things to fix, but it’s non trivial
This should be fairly easy to implement with the
cmake.subproject_options()
to specifically set thenative
kwarg for all/some targets.Assuming the project itself does not specify platform-specific defines/compiler options that mess up the final build…