Search code examples
qtqmakeqbs

Passing build option to qbs project


I have a qbs project with some external library dependency. As soon as I don't want to specify this dependency inside project source files, I would rather add it as an argument to console build command.

For example: when using qmake, I can specify additional qmake console arguments, like qmake.exe MyProject.pro MYDEFINE="random text", and in the project file I can use this argument inside .pro files as $$MYDEFINE

How to achieve similar functionality with qbs?


Solution

  • Define a property in the project, for example:

    Project {
         property path myCustomLibPath: "unknown-path"
    
         Product {
              name: "Awesome Program 3000"
    
              Depends { name: "cpp" }
              cpp.libraryPaths: [project.myCustomLibPath]
    
         }
    }
    

    Then set it in the command line args:

    qbs build -f /path/to/project.qbs debug project.myCustomLibPath:/path/to/my/lib

    This even works through qt creator.