Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake : how to use bash command in CMakeLists.txt

Tags:

I'm wondering how I can use bash command in CMakeLists.txt. What I want is to get the number of processor retrieved using :

export variable=`getconf _NPROCESSORS_ONLN` 

and set NB_PROCESSOR to variable using something like :

SET (NB_PROCESSOR variable) 

So my question is how can I use the getconf command in CMakeLists.txt and how can I use the result (stored in variable) in CMake SET command?

like image 638
claf Avatar asked Mar 18 '09 11:03

claf


1 Answers

This seems to do the trick, and saves the "set" too.

execute_process(COMMAND getconf  _NPROCESSORS_ONLN                 OUTPUT_VARIABLE NB_PROCESSOR) 
like image 147
richq Avatar answered Sep 18 '22 18:09

richq