Qt World Summit: Register Today!

Building apps from command line

  • Hi guys,

    Seems a strange problem, to which I have failed to found a solution yet.
    I need to have certain lines in my pro file to execute only when the app is run from within the Qt Creator and I want them to be ignored if qmake is executed from command line. If that is possible I would certainly welcome a solution. Tried to search if Qt Creator defines something which can be detected from within the pro application file and then those lines of mine would be executed as I want. Currently if I qmake and make the app from command line I need to comment those lines temporarily.

  • Lifetime Qt Champion

    @Emil-Kaczmarek You can use environment variables for that.
    "To obtain the contents of an environment value when qmake is run, use the $$(...) operator:" , see http://doc.qt.io/qt-5/qmake-language.html

  • That was the problem, I used $$ without brackets. However, qmake function equals does not seem to be capable of comparing two environment variables, namely:

    equals($$(OUT_PWD), $$(PWD)) {
    message("PATHS ARE EQUAL")

    Does not work as expected. It should execute when pro file is run from command line.

  • OK,

    finally solved by

    PATH1 = $$OUT_PWD
    PATH2 = $$PWD

    !equals(PATH1, $$PATH2) {

Log in to reply