[CMake] Getting the number of processor

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri May 30 12:33:48 EDT 2008


regex are driving me nuts... could someone please let me know what is
wrong with my 'REPLACE' expression.

Thanks !

FILE(READ /proc/cpuinfo cpuinfo)
STRING(REGEX REPLACE "\r?\n" ";" cpuinfo "${cpuinfo}")
SET(myoutput "")

FOREACH(line ${cpuinfo})
  STRING(REGEX MATCH "processor" proc_line ${line})
  STRING(REGEX REPLACE
    "^processor[ ]+:[ ]+([0-9]+)$"
    " \\1 " nline "${line}")
  IF(proc_line)
  MESSAGE(${nline})
    SET(myoutput "${myoutput}\n${nline}")
  ENDIF(proc_line)
ENDFOREACH(line)

MESSAGE("${myoutput}")

-- 
Mathieu


More information about the CMake mailing list