Search code examples
qtqmakelibs

How to create distro-specific conditional qmake project


Suppose I write code on 2 computers which runs different linux distros.

How to make qmake differ those two distros and assign specific LIBS for those two.

For instance;

unix: {

   ubuntu*: {
          LIBS += -lcxcore -lhighgui -lm
   }

   gentoo*: {
           LIBS += -lopencv_imgproc -lopencv_highgui -lm
   }

}

Solution

  • I think you can run "uname -a" and use a regular expression to check the return value in your .pro file:

    UNAME = $$system(uname -a)
    
    contains(UNAME, YourRegExpToMatchGentoo): GENTOO = 1
    contains(UNAME, YourRegExpToMatchUbuntu): UBUNTU = 1
    
    contains(GENTOO, 1): {
        LIBS += -lcxcore -lhighgui -lm
    }
    
    contains(UBUNTU, 1): {
        LIBS += -lopencv_imgproc -lopencv_highgui -lm
    }