Search code examples
c++qtqmakeconditional-compilation

Qt pro file conditional libs


I am trying to setup a pro file where I want it to only include a specific library if a variable is defined. I already have this variable passed into qmake via the command line by appending DEFINES+=VARIABLE_NAME.

I can use VARIABLE_NAME to conditionally compile parts of my code but can I have a condition to detect VARIABLE_NAME in the pro file and only include a library if it exists?

Thanks, Alan


Solution

  • Something like that:

    DEFINES += USELIB
    
    contains(DEFINES, USELIB) {
      LIBS += SOMELIB
    }