Results 1 to 5 of 5

Thread: Passing variables to subprojects

  1. #1
    Join Date
    Apr 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Passing variables to subprojects

    Hello, everyone!

    I have the following situation:

    ParentProject_1.pro
    TEMPLATE = subdirs
    INCLUDE_SUBSUBPROJECT = 1
    SUBDIRS += Child.pro

    ParentProject_2.pro
    TEMPLATE = subdirs
    INCLUDE_SUBSUBPROJECT = 0
    SUBDIRS += Child.pro

    Child.pro
    TEMPLATE = subdirs
    contains(INCLUDE_SUBSUBPROJECT, 1){
    SUBDIRS += Subsubproject.pro
    }

    This does not work as is because the INCLUDE_SUBSUBPROJECT value is not transfered from parent projects to Child.pro, so Subsubproject.pro will never be included. One way seems to be using command line params for qmake, but it becomes problematic with more complex scenarios and I would really like to avoid it. Is there another way?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing variables to subprojects

    I would approach this with a Child.pri file that contains the common parts and two Child .pro files

    Child.pro
    Qt Code:
    1. include(Child.pri)
    To copy to clipboard, switch view to plain text mode 

    ChildWithSubSub.pro
    Qt Code:
    1. include(Child.pri)
    2.  
    3. # SubSub stuff
    To copy to clipboard, switch view to plain text mode 

    ParentProject1.pro
    Qt Code:
    1. SUBDIRS +=ChildWithSubSub.pro
    To copy to clipboard, switch view to plain text mode 

    ParentProject2.pro
    Qt Code:
    1. SUBDIRS +=Child.pro
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Apr 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Passing variables to subprojects

    Thank you for your answer. Unfortunately, I have a more complex situation, in the sense that Child.pro has multiple subsubprojects that are combined differently when called from diffrent parents. Of course, your aproach remains valid and I will most probably use it. However, I was hoping to be able to have an unique Child.pro, becuase it seemed more ellegant to me.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing variables to subprojects

    Hmm.
    Maybe try adding to the CONFIG variable?

    Cheers,
    _

  5. #5
    Join Date
    Apr 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Passing variables to subprojects

    I changed the approach and used something like you said in the first reply. Thank you!

Similar Threads

  1. Replies: 14
    Last Post: 27th September 2012, 07:12
  2. Passing variables between forms.
    By Splatify in forum Newbie
    Replies: 9
    Last Post: 21st February 2011, 12:12
  3. Replies: 1
    Last Post: 25th November 2010, 17:02
  4. Replies: 2
    Last Post: 25th June 2009, 20:47
  5. Replies: 2
    Last Post: 17th October 2006, 20:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.