[QBS] Looking for libraries/include paths

Ruslan Nigmatullin EuroElessar at yandex.ru
Mon Aug 13 18:57:47 CEST 2012


Hi all!

CMake has widely-used functions find_path (looking for headers) and find_library (looking for libraries and frameworks). How should they look in qbs? It's possible to implement both of them in JavaScript, but it looks ugly, as we need to pass to functions a lot of arguments. Otherwise syntax will look like:

>  base.findLibrary({
>      names: [ "SDL", "SDL-1.1" ], // possible names of library, they can be different due to platform
>      paths: [ "/sw", "/opt/local", "/opt/csw", "/opt" ]
>      hints: getenv("SDLDIR")
>  });

But it's not IDE-friendly and it's easy to mistype.

May be there should be created interface like following?

> Module {
>     name: "sdl"
>     property string directory
>     Depends { name: "cpp" }
>     PkgConfigLookup {
>          id: sdlPkg
>          name: "SDL"
>     }
>     LibraryLookup {
>          condition: qbs.targetOS !== "mac" && !sdlPkg.found
>          names: [ "SDL", "SDL-1.1" ], // possible names of library, they can be different due to platform
>          paths: [ "/sw", "/opt/local", "/opt/csw", "/opt" ]
>          hints: module.directory
>      }
>      HeaderPathLookup {
>          condition: qbs.targetOS !== "mac" && !sdlPkg.found
>          file: "SDL/SDL.h"
>          hints: module.directory
>          paths: [ /* several paths */ ]
>      }
>      Properties {
>          condition: qbs.targetOS === "mac" && !sdlPkg.found
>          cpp.frameworks: "SDL"
>      }
>  }

*Lookup classes should populate properties of "cpp" module automatically or manually, but they looks like to be cpp/mm-oriented classes, so I don't know how much they fit in qbs ideology. It's not possible to find libraries like this in other ways, so such mechanism should be existed.

On the other hand this way may fail, so FindQCA.cmake uses both this way and pkg-config results to find library position, so there should be the way to handle pkg-config results (i.e. to provide hints).

Any suggestions?

Ruslan



More information about the Qbs mailing list