meson: [CMake] Missing a way to define CMake args from the meson call

To make meson work correctly within vcpkg using cmake dependencies, meson needs to pass two things to CMake via meson:

  • a cmake toolchain file
  • a variable called VCPKG_TARGET_TRIPLET set to the correct value to use.

As such having the option to globally pass cmake_args is requiered.

Furthermore using --find-package mode is deprecated. https://cmake.org/cmake/help/latest/manual/cmake.1.html#run-the-find-package-tool

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 22 (18 by maintainers)

Most upvoted comments

Both native and cross concepts seem to fail to catch my use case, which actually should be very easy and common.

  • Native files: are positioned in global locations and will influence all builds, with no granularity;
  • Cross files: will configure the build for cross building creating other issues.

In both case you are missing a common use case: you are in Windows, you don’t have pkg-config and libraries are located who knows where. Even if you are not on Windows, you may just want some granularity and decide that this meson build depends on some CMake defines, and another meson build depends on others, and this is semantically not an environment configuration, nor it is a cross build. For my understanding, meson is basically unable to cover these scenarios. For open source projects using meson, the only solution is patching meson.build for your needs.

I currently don’t see how the current setup is a major hurdle/annoyance

So far my experience with meson has been a completely disaster because of this. It’s the third open source project that uses meson that I tried to build in Windows and I was never able to build it without having to heavily edit meson.build. Why? Because I have my (tweaked and controlled) compilations of the deps of that project using meason and I want to use those in the exact locations I supply. I have a script that performs both cross and non cross builds using the very common cmake ExternalProject_Add directive. In most cases I’m able to do it composing command line commands, in other cases it influence externally CMake variables, which is very well supported in CMake. So far, any attempt to insert a meson project using ExternalProject_Add has been a failure.

quick changes than changing the command line[…] when we actively try to keep the amount of Meson options minimal

I ask you (meson devs) to reconsider this position and introduce a command line switch to add CMake defines as required by the issue creator. CMake dependency resolution and projects heavily depend on the ability to externally configure defines. Restricting this freedom just harms the ability to use CMake for dependency resolution or for subprojects.