QMAKE variable not work as expected



  • I'm working on a project with Qt. I'm trying to separate app and lib in different folder by using customized pri files

    But the QMAKE var TEMPLATE changes randomly for the same sub-project. Makes no sense for me.

    part of downloader_tester.pro

    include(../../build_path.pri)
    TARGET = downloader_tester
    TEMPLATE = app
    

    part of build_path.pri

    #envs
    PREFIX = $${TOPDIR}/_build
    
    CONFIG(release, debug|release):DEB_REL = _release
    CONFIG(debug, debug|release):DEB_REL = _debug
    
    INSTALL_DIR_BIN = $${PREFIX}/$${DEB_REL}/bin
    INSTALL_DIR_LIBS = $${PREFIX}/$${DEB_REL}/libs
    
    QMAKE_LIBDIR += $${INSTALL_DIR_LIBS}
    INCLUDEPATH += $${TOPDIR}
    
    win32:CMD_MKDIR = "md"
    unix:CMD_MKDIR = "mkdir -p"
    
    win32:CMD_DEL = "rm" #since I'm using msys2
    unix:CMD_DEL = "rm"
    
    if(eval(TEMPLATE = "app"))
    {
        install_bin.files += $${OUT_PWD}/$${str_member($${DEB_REL},1,-1)}
        #install_libs.extra = $${CMD_DEL} *.o *.cpp *.h
        message("=================================")
        message(TARGET=$${TARGET})
        message(TEMPLATE=$${TEMPLATE})
        message(INSTALL_DIR_BIN=$${INSTALL_DIR_BIN})
        message(DESTDIR=$${DESTDIR})
        message("*********************************")
    }
    
    if(eval(TEMPLATE = "lib"))
    {
        LIBS += -L$${OUT_PWD}/$${str_member($${DEB_REL},1,-1)} -l$${TARGET}
        message("=================================")
        message(TARGET=$${TARGET})
        message(TEMPLATE=$${TEMPLATE})
        message(INSTALL_DIR_LIBS=$${INSTALL_DIR_LIBS})
        message(DESTDIR=$${DESTDIR})
        message("*********************************")
        message($${OUT_PWD}/$${str_member($${DEB_REL},1,-1)})
    }
    

    SINGLE Time QMAKE

    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=app
    Project MESSAGE: INSTALL_DIR_BIN=D:/works/qt/downloader/_build/_release/bin
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=lib
    Project MESSAGE: INSTALL_DIR_LIBS=D:/works/qt/downloader/_build/_release/libs
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=app
    Project MESSAGE: INSTALL_DIR_BIN=D:/works/qt/downloader/_build/_release/bin
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=lib
    Project MESSAGE: INSTALL_DIR_LIBS=D:/works/qt/downloader/_build/_release/libs
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=app
    Project MESSAGE: INSTALL_DIR_BIN=D:/works/qt/downloader/_build/_debug/bin
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    Project MESSAGE: =================================
    Project MESSAGE: TARGET=downloader_tester
    Project MESSAGE: TEMPLATE=lib
    Project MESSAGE: INSTALL_DIR_LIBS=D:/works/qt/downloader/_build/_debug/libs
    Project MESSAGE: DESTDIR=
    Project MESSAGE: *********************************
    

    We can clearly see that TEMPLATE change from app to lib and change back few time for the SAME PROJECT. Even the release change to debug at the end.

    What is happening...???


  • Moderators

    @Adam-BZH Looks correct to me: for app it is storing binary in bin and for lib in lib. What is inside your pri files?



  • @jsulm I provided my pri file in op



  • Solved by make the { at the same line with equals....
    There is no any warning or error from qmake, it just ignore that line but still exec the code inside that { }.
    What the f is this, took me 5 hours to find it out.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.