question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The CMake module doesn't allow for native dependencies when cross compiling

See original GitHub issue

I’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

  1. 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
    
  2. Create an empty src/some-library.cpp file.

  3. 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:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dcbakercommented, Nov 29, 2020

Ya, its a know deficiency, it’s on my list is things to fix, but it’s non trivial

1reaction
mensindacommented, Nov 28, 2020

This should be fairly easy to implement with the cmake.subproject_options() to specifically set the native kwarg for all/some targets.

Assuming the project itself does not specify platform-specific defines/compiler options that mess up the final build…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross Compiling With CMake
Cross -compiling support doesn't mean that all CMake-based projects can be magically cross-compiled out-of-the-box (some are), but that CMake separates between ...
Read more >
cmake cross-compilation with sysroot returns wrong include ...
But if find_package(pack1) is run in CONFIG mode and uses pack1Config.cmake script for locate settings of pack1 package, then that pack1Config.
Read more >
MXE (M cross environment)
is designed to run on any Unix system · is easy to adapt and to extend · builds many free libraries in addition...
Read more >
Cross compilation - The Meson Build system
Since cross compiling is more complicated than native building, let's first go ... the others but chosen at runtime, so target_machine still doesn't...
Read more >
Chapter 2 Configuring and Building ITK - Insight Toolkit
An ITK build requires only CMake and a C++ compiler. ITK ships with all the third party library dependencies required, and these dependencies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found