[CMake] Set alias in cmake script

2013-12-18 Thread Stefan
Hi cmake users,

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)

My intention is to use cmake .. and after that I simply want to type 
makefast and my project is going to be compiled.

Of course I could set the alias name in my e.g. .bashrc, but having this in my 
cmake file would be a nice thing to have.


Thanks in advance!


Stefan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Set alias in cmake script

2013-12-18 Thread Matthew Woehlke

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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake