Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qmake: how to handle dependencies to parallel but otherwise independent projects?
Forum Updated to NodeBB v4.3 + New Features

qmake: how to handle dependencies to parallel but otherwise independent projects?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.1k Views 3 Watching
  • 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.
  • Y Offline
    Y Offline
    Yves
    wrote on last edited by
    #1

    Info: Qt 5.3.2 with MinGW on Windows

    I've got the following situation:

    I have a stand alone project building a library. In two parallel source trees I've got other projects (very complex and independent from each other) building applications. Both applications depend on the library at some point (usually somewhere deep down in their respective tree). While the code for all projects is always in the same place relative to each other I cannot create a subdirs-project on the source-"root":

    [root]
       |- [mylibrary]
       |      |-mylibrary.pro        // lib project
       |      ...
       | - [application1]
       |      |- application1.pro    // subdirs project
       |      |- [module11]
       |      |- [module12]          // dll, depends on mylibrary 
       |     ...
       | - [application2]
       |      |- application2.pro    // subdirs project
       |      |- [module21]          // dll, depends on mylibrary 
       |      |- [subdir22]
       |      |      |- [submodule221]    // dll, depends on mylibrary 
       |     ...
      ...
    

    Depending on certain factors usually only one of the applications (or sometimes just one of their modules) is built. Is there any way to create a dependency so mylibrary is built, too, if the application otr module depends on it?

    I tried using subdirs-projects that included mylibrary directly or in subdirectories:

    TEMPLATE = subdirs
    SUBDIRS += module_11 module_12 my_library
    
    my_library.subdir = $$PWD/../mylibrary
    my_library.target = mylibrary
    
    module_11.subdir = $$PWD/module11
    module_11.target = module11
    
    module_12.subdir = $$PWD/module12
    module_12.target = module12
    module_12.depends = mylibrary
    

    Unfortunately this results in qnake creating Makefiles, then calling mingw32-make that is then switching to mylibrary-dir and falling into a loop there, creating more and more instances of mingw32-make switching to mylibrary-dir and falling into a loop there, creating more and more instances of mingw32-make switching to ... you get it.

    Is there any way to get such out-of-source-tree-dependencies builtwithout having to create a subdirs project above them?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Hi, welcome to devnet.

      I haven't tried that but something along these lines might work:

      TEMPLATE = subdirs
      SUBDIRS += module_11 module_12 my_library
      
      module_11.subdir = $PWD/module11
      module_11.target = module11
      
      module_12.subdir = $PWD/module12
      module_12.target = module12
      
      my_library.target = mylibrary.a
      my_library.command = make <wherever the library makefile is>
      
      QMAKE_EXTRA_TARGETS += my_library
      PRE_TARGETDEPS += mylibrary.a
      
      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Yves
        wrote on last edited by Yves
        #3

        Hi Chris,

        thank you for your answer. Unfortuantely your suggestion doesn't work. I think it's because subdirs projects don't create targets and thus ignore QMAKE_EXTRA_TARGETS and PRE_TARGETDEPS (though <customtarget>.depends does basically the same as PRE_TARGETDEPS).
        Also <target>.command does not seem to be supported in subdirs projects.

        But your suggestion gave me the idea that I maybe could abuse one of the other TEMPLATE types to create custom targets that copy somestuff and replace some paths using your approach with QMAKE_EXTRA_TARGETS etc.

        1 Reply Last reply
        0

        • Login

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