Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add qmake commands from .pri correctly

How to add qmake commands from .pri correctly

Scheduled Pinned Locked Moved Solved General and Desktop
qmakepropri
2 Posts 1 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blanky
    wrote on last edited by
    #1

    Hello, I have a snippet of a .pro here as this:

    QT       += core gui opengl
    
    target.path = $$PWD/Assistant/simpletextviewer
    docs.files += $$PWD/documentation
    docs.path = $$target.path
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = ImportWizard
    #this .pri is shown below
    include(../../../LoadBuildFiles/BuildFunctions.pri)
    #this calls the only function of the .pri
    buildDependencies()
    TEMPLATE = lib
    
    

    And then in the .pri I'm including, this is the function being called:

    defineTest(buildDependencies){
        #This forces a remake of the make file so the build command will always execute qmake and run our script
        qmakeforce.target = dummy
        qmakeforce.commands = rm -f $$PWD/Makefile ##this does the actual re-run of qmake
        qmakeforce.depends = FORCE
        PRE_TARGETDEPS += $$qmakeforce.target
        QMAKE_EXTRA_TARGETS += qmakeforce
    
        message($$PWD)
    
        if(!equals($$makeOptions, "clean")){        
            PRE_TARGETDEPS += ../../../Libraries/"$$TARGET"Library""/lib64
            
            system(. ../../../LoadBuildFiles/./SubMake.sh && HeaderCopy "$$TARGET")
    
            QMAKE_POST_LINK = . ../../../LoadBuildFiles/./SubMake.sh && PostMakeLibCopy "$$TARGET"Library""
            message("Called anything else $$makeOptions")
        }else{
            message("Called clean $$makeOptions")
        }
    }
    

    So, we're trying to automate the load build process by calling a script from the .pro through the system command call. This works fine if you manually run qmake, however we wanted to automate the entire process such that whether you make, qmake, or clean. Someone said the only way for build to call qmake implicitly is if the Makefile or .pro is dirtied is some fashion. My colleague and I assumed that this .pri is just expanded in place when the function is called, but there seems to be some side effects. If we drag the function out where the following is includedin the .pro:

    #this .pri is shown below
    include(../../../LoadBuildFiles/BuildFunctions.pri)
    #this calls the only function of the .pri
    buildDependencies()
    

    Afterwards it looks like this:

    QT       += core gui opengl
    
    target.path = $$PWD/Assistant/simpletextviewer
    docs.files += $$PWD/documentation
    docs.path = $$target.path
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = ImportWizard
    #This forces a remake of the make file so the build command will always execute qmake and run our script
    qmakeforce.target = dummy
    qmakeforce.commands = rm -f $$PWD/Makefile ##this does the actual re-run of qmake
    qmakeforce.depends = FORCE
    PRE_TARGETDEPS += $$qmakeforce.target
    QMAKE_EXTRA_TARGETS += qmakeforce
    
    message($$PWD)
    
    if(!equals($$makeOptions, "clean")){        
        PRE_TARGETDEPS += ../../../Libraries/"$$TARGET"Library""/lib64
            
        system(. ../../../LoadBuildFiles/./SubMake.sh && HeaderCopy "$$TARGET")
    
        QMAKE_POST_LINK = . ../../../LoadBuildFiles/./SubMake.sh && PostMakeLibCopy "$$TARGET"Library""
        message("Called anything else $$makeOptions")
    }else{
        message("Called clean $$makeOptions")
    }
    TEMPLATE = lib
    

    Then everything works just fine. Do the qMake commands not expand in place when including a .pri? Is there a way to achieve what we're doing with in place substitution?

    B 1 Reply Last reply
    0
    • B Blanky

      Hello, I have a snippet of a .pro here as this:

      QT       += core gui opengl
      
      target.path = $$PWD/Assistant/simpletextviewer
      docs.files += $$PWD/documentation
      docs.path = $$target.path
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = ImportWizard
      #this .pri is shown below
      include(../../../LoadBuildFiles/BuildFunctions.pri)
      #this calls the only function of the .pri
      buildDependencies()
      TEMPLATE = lib
      
      

      And then in the .pri I'm including, this is the function being called:

      defineTest(buildDependencies){
          #This forces a remake of the make file so the build command will always execute qmake and run our script
          qmakeforce.target = dummy
          qmakeforce.commands = rm -f $$PWD/Makefile ##this does the actual re-run of qmake
          qmakeforce.depends = FORCE
          PRE_TARGETDEPS += $$qmakeforce.target
          QMAKE_EXTRA_TARGETS += qmakeforce
      
          message($$PWD)
      
          if(!equals($$makeOptions, "clean")){        
              PRE_TARGETDEPS += ../../../Libraries/"$$TARGET"Library""/lib64
              
              system(. ../../../LoadBuildFiles/./SubMake.sh && HeaderCopy "$$TARGET")
      
              QMAKE_POST_LINK = . ../../../LoadBuildFiles/./SubMake.sh && PostMakeLibCopy "$$TARGET"Library""
              message("Called anything else $$makeOptions")
          }else{
              message("Called clean $$makeOptions")
          }
      }
      

      So, we're trying to automate the load build process by calling a script from the .pro through the system command call. This works fine if you manually run qmake, however we wanted to automate the entire process such that whether you make, qmake, or clean. Someone said the only way for build to call qmake implicitly is if the Makefile or .pro is dirtied is some fashion. My colleague and I assumed that this .pri is just expanded in place when the function is called, but there seems to be some side effects. If we drag the function out where the following is includedin the .pro:

      #this .pri is shown below
      include(../../../LoadBuildFiles/BuildFunctions.pri)
      #this calls the only function of the .pri
      buildDependencies()
      

      Afterwards it looks like this:

      QT       += core gui opengl
      
      target.path = $$PWD/Assistant/simpletextviewer
      docs.files += $$PWD/documentation
      docs.path = $$target.path
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = ImportWizard
      #This forces a remake of the make file so the build command will always execute qmake and run our script
      qmakeforce.target = dummy
      qmakeforce.commands = rm -f $$PWD/Makefile ##this does the actual re-run of qmake
      qmakeforce.depends = FORCE
      PRE_TARGETDEPS += $$qmakeforce.target
      QMAKE_EXTRA_TARGETS += qmakeforce
      
      message($$PWD)
      
      if(!equals($$makeOptions, "clean")){        
          PRE_TARGETDEPS += ../../../Libraries/"$$TARGET"Library""/lib64
              
          system(. ../../../LoadBuildFiles/./SubMake.sh && HeaderCopy "$$TARGET")
      
          QMAKE_POST_LINK = . ../../../LoadBuildFiles/./SubMake.sh && PostMakeLibCopy "$$TARGET"Library""
          message("Called anything else $$makeOptions")
      }else{
          message("Called clean $$makeOptions")
      }
      TEMPLATE = lib
      

      Then everything works just fine. Do the qMake commands not expand in place when including a .pri? Is there a way to achieve what we're doing with in place substitution?

      B Offline
      B Offline
      Blanky
      wrote on last edited by
      #2

      Since this is pretty old, the solution is to at the bottom of the .pri file to use the export function. For every QMAKE key word you need an export for it.
      In my above example I should append the following to the bottom:

      export(PRE_TARGETDEPS)
      export(QMAKE_EXTRA_TARGETS)

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved