GNU make --jobs option in QMAKE

自作多情 提交于 2019-12-06 02:12:34

问题


I am using qmake to generate MinGW32 Makefiles for a small Qt C++ app we are developing. My problem: all those dual/quad core CPUs are sitting there idly while only one thread is doing the building. In order to parallelize things I tried passing --jobs 4 to make, but the problem is that qmake generates a generic makefile inside of which make gets called again with -f .

Is it possible to force qmake to add options to make when generating the makefile? Or maybe there's another way of setting the option outside of qmake altogether? I can't edit that specific Makefile since it's autogenerated each build.


回答1:


Abusing $MAKE to pass options does not work in all cases. Oftentimes, (e.g. in the configure script of Qt on Unix), it's enclosed in double quotes ("$MAKE") to allow the command to contain spaces. I know because I used the same trick before it stopped working. Qt Support then suggested (rightfully) to use $MAKEFLAGS as in

set MAKEFLAGS=-j4
make



回答2:


This works for me:

set MAKE_COMMAND=mingw32-make -j%NUMBER_OF_PROCESSORS%




回答3:


The generic Makefile uses $(MAKE) when invoking make, so you can overwrite it using environment variables. Something like this should do it:

  qmake
  make MAKE="mingw32-make -j4"

Replace the values of MAKE as required of course :)



来源:https://stackoverflow.com/questions/1247162/gnu-make-jobs-option-in-qmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!