[CMake] Passing Function Arguments

Johny Johny.Jose at cern.ch
Thu Jul 8 04:35:40 EDT 2010


I am trying to write a cmake function which imitates the functionality 
of wc -l for unix. However i can't seem to be able to figure out how to 
store the result into the variable which is passed  to the function.

function (wcl fileName lines)
   file(READ ${fileName} fileData)
   if(fileData)
     string(REGEX MATCHALL "\n" lines ${fileData})
     list(LENGTH lines lines)
   endif(fileData)
endfunction()

i call the function as

wcl (${fileName} fileLen)

and printing it gives no output

message("${fileLen}")

What am i doing wrong ?

Regards
Johny




More information about the CMake mailing list