Search code examples
meson-buildsubproject

Meson can't find cmake subdirectory


In one of my meson.build files, I have code that I need to generate a dependency for spdlog.

libspd = cmake.subproject('spdlog')
spd_dep = libspd.dependency('spd_dep')

The meson.build in question resides in a directory called vendor, and the spdlog directory also sits in it.

./
  ...
  vendor/
    meson.build
    spdlog/
      CMakeLists.txt
      ...

However, when I configure the project, meson throws this error: Neither a subproject directory nor a spdlog.wrap file was found.. Why is this? Clearly, the spdlog directory is in the same directory as in meson.build in question, right?

Also, I know I should be using wrapfiles, but due to limitations that is impossible. I've also asked on IRC, but no-one responded, and I'm on a deadline.


Solution

  • Meson has predefined location for subprojects - All subprojects must be in subprojects directory. So, you should have structure:

      vendor/
        meson.build
        subprojects/
          spdlog/
            CMakeLists.txt