Search code examples
c++meson-buildsubproject

how to specify version of dependency in meson build?


I have two projects in C++, both using meson build. One is a subproject of the other:

noise-status is a dependency of noise-service

I'm importing the noise-status subproject with a wrap-file:

[wrap-git]
url = http://eng-server:9090/yxia/noise-status.git
revision = master

And in the noise-service meson build file, I'm specifying the version of this subproject that I want to be used (noise-service has tags up to 0.5.0):

noise_status_dep = dependency('noise-status', required: false, version: '0.2.0')

But this apparently doesn't work, it always pull the latest version of noise-status as a subproject. How should I modify this setup for pulling a specific version of the subproject?


Solution

  • The wrap file specifies the imported version in your case. Currently it will choose master. You must change revision = master to the tag you want to import.

    From the manual:

    revision - name of the revision to checkout. Must be either: a valid value (such as a git tag) for the VCS's checkout command, or (for git) head to track upstream's default branch. Required.

    So, if you want the tag 0.2.0 change your wrap file to:

    [wrap-git]
    url = http://eng-server:9090/yxia/noise-status.git
    revision = 0.2.0
    

    The dependency declaration would still work this way:

    noise_status_dep = dependency('noise-status', required: false)
    

    If you add the provide keyword as well, you can declare an individual name which you can reference in the dependency declaration, such as:

    [wrap-git]
    url = http://eng-server:9090/yxia/noise-status.git
    revision = 0.2.0
    
    [provide]
    dependency_names = noise-status-0.2.0
    

    Then you can declare a dependency with that name:

    noise_status_dep = dependency('noise-status-0.2.0', required: false)