Results 1 to 3 of 3

Thread: Tell QMake to add a literal string to the Makefile

  1. #1
    Join Date
    Aug 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Tell QMake to add a literal string to the Makefile

    I need to find a way to pass a string from QMake into the generated Makefile. I want to do this so I can control Parallel builds. I use Make from the command line, not QtCreator (don't ask why).

    I have a top level project that I want to be not parallel. then have the the subdirs as parallel. I can easily do this now by using all the normal conventions for setting up the subdirs in the .pro file:

    Qt Code:
    1. SUBDIRS = aproj bproj cproj
    To copy to clipboard, switch view to plain text mode 

    then after the make file is created I add the NOTPARALLEL: entry to it:

    Qt Code:
    1. SUBTARGETS = \
    2. aproj
    3. bproj
    4. cproj
    5.  
    6. NOTPARALLEL:
    7.  
    8. aproj/($MAKEFILE):
    9. ........
    To copy to clipboard, switch view to plain text mode 

    Thus the main project is serial and the subdirs build in parallel. The down side is that I have to add the NOTPARALLEL command each time I recreate the Makefile.

    According to the gcc/make docs the NOTPARALLEL can be anywhere in the Makefile: "If .NOTPARALLEL is mentioned as a target, then this invocation of make will be run serially, even if the ‘-j’ option is given." So I just need to stuff it in someplace.

    Any ideas?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tell QMake to add a literal string to the Makefile

    The example you have given us would serialise (i.e. .NOTPARALLEL) building of aproj, bproj, and cproj. (I have assumed the missing dots are typos)
    If you are trying to ensure they build in a particular order then you should look at "CONFIG += ordered" in your PRO file.

  3. #3
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tell QMake to add a literal string to the Makefile

    I know this is an old thread but because it's one of the first things that came up on Google on this topic I wanted to provide an answer.

    For SUBDIRS projects the given answer is partially correct. To prevent the subprojects building in parallel to each other at all, just use CONFIG+=ordered. To prevent only some subprojects from building in parallel, use "depends" like so:
    Qt Code:
    1. bproj.depends = aproj
    To copy to clipboard, switch view to plain text mode 
    Still, sometimes you need to prevent a given subproject from building its files in parallel. For example, I have some template heavy code where compiling each file takes all the system memory. I want to make just that subproject build serially. This is where GNU Make's "NOTPARALLEL" is useful. This gets qmake to add it to the Makefile:
    Qt Code:
    1. unix {
    2. notparalleltarget.target = .NOTPARALLEL
    3. QMAKE_EXTRA_TARGETS += notparalleltarget
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 31st March 2011, 18:38
  2. makefile without using QMake
    By Rayven in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2010, 22:04
  3. qmake outputting wrong kind of makefile...
    By andy.fillebrown in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2009, 16:37
  4. Qmake for subdirs w/ custom makefile name
    By Frank J. Lhota in forum Qt Tools
    Replies: 1
    Last Post: 10th June 2009, 00:59
  5. qmake creat Makefile.Debug has error
    By freegnu in forum Qt Programming
    Replies: 4
    Last Post: 12th June 2006, 07:31

Tags for this Thread

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.