Download Meson and Mesa to local repo and build

Good afternoon,

I am trying to create a repository that will build and install Mesa 3D in a local directory. I have read that Mesa 3D needs to be configured using Meson but I would like both of these downloaded and built in the local directory of my repository. I am using CMake 3.22 and ninja instead of make.

I think the way to accomplish this would be to use CPMAddPackage or ExternalProject_Add (I am not picky) ?

I have been going around with this for a few days and am hoping one of you CMake experts has some direction to point me to. I am hoping there is a single CMakeLists.txt file that I could create that could do this so that all I would need to do is run something like the following in the current directory of the local directory I am building:

$ mkdir build && cd build
$ cmake -GNinja ../

Thank you in advance for any help.

In general that command sequence isn’t necessary for CMake projects. Just

cmake -GNinja -Bbuild

Is equivalent.

You could define external project using meson for mesa. First using find_package(Python) and execute_command to pip install meson.

It’s not trivial to extract, but Mesa and Meson are part of the common-superbuild which relies on ExternalProject_Add under the hood. The quick thing to do would be to just take the logic around superbuild_add_project, replace that call with ExternalProject_Add and include the relevant bits from versions.cmake then tweak from there. Other bits may break, but maybe you don’t need them (the superbuild does…other things to do some package management stuff).

Thank you @scivision and @ben.boeckel for the replys.

It sounds like common-superbuild might be what I am looking for.

Please excuse an ignorant question, @ben.boeckel , but can you tell me where the superbuild_add_project call is located?

Look under the projects/ directory for meson.cmake and *mesa*.cmake.

Thank you.