[CMake] Set "alias" in cmake script

Matthew Woehlke matthew.woehlke at kitware.com
Wed Dec 18 11:48:35 EST 2013


On 2013-12-18 04:19, Stefan wrote:
> I'm not sure if this is possible or not, but I'm trying to set an (environment) alias in my cmake script:
>
> alias makefast="make -j $(cat /proc/cpuinfo | grep -c processor)"

You can't do that as such; the [alias] command would need to run in the 
context of the parent shell process, and that's not possible (not in any 
sane manner, at least). The closest you could get would be to write in 
your .bashrc a function 'cmake' that called 'command cmake "$@"' and 
then sets your alias.

Other comments: I'd multiply this by about 5/4; general experience seems 
to be that you want the number of jobs to be a bit higher than the 
actual number of CPU's in order to keep them busy when jobs are waiting 
on disk I/O.

Also, have you tried ninja¹? IME it's faster than make, and defaults to 
#CPU's + 2 jobs unless you tell it otherwise (so you wouldn't need 
'makefast', just 'ninja').

(¹ http://martine.github.io/ninja/)

-- 
Matthew



More information about the CMake mailing list