Is there a good way to display "clean" text on stdout in CMake -


cmake version 2.8.10.2, os centos 6.3

we're trying "clean" display of text on stdout within our cmake files. is, text intend, without prefix. far i've tried these variations

this goes stderr (surprised me):

message("my text") 

this goes stdout prefixes each line '-- ':

message(status "my text") 

this sort of works, side effects weird , make undesirable us:

file(write /dev/stdout "my text") 

the above goes stdout, breaks if output cmake redirected file (cmake > file), although ok if you pipe stdout first (cmake | cat > file) that's hacky , means have tell workaround isn't going happen.

you provide following function:

function(cleanmessage)   execute_process(command ${cmake_command} -e echo "${argn}") endfunction() 

and use this:

cleanmessage("clean text") 


if want push boat out, extend built-in message options include clean one:

function(message messagetype)   if(${argv0} strequal "clean")     execute_process(command ${cmake_command} -e echo "${argn}")   else()     _message(${messagetype} "${argn}")   endif() endfunction() 

and use this:

message(status "incidental information") message(clean "clean incidental information") message(warning "cmake warning, continue processing") 

this safe define in top-level cmakelists.txt once. however, if it's defined in e.g. utilities file included more once, lead infinite recursion. avoid this, @ start of utility file in function defined, add:

if(overloadmessageincluded)   return() endif() set(overloadmessageincluded true) 

this cmake version of header guard.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -