<div class="gmail_quote">On Tue, Jun 15, 2010 at 5:13 PM, Daniel Blezek <span dir="ltr"><<a href="mailto:Blezek.Daniel@mayo.edu">Blezek.Daniel@mayo.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>
<font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size: 11pt;">Hi,<br>
<br>
We would like to convert an OpenCL program written in a separate file to a C++ header (essentially a long string).<br>
<br>
For example, if my OpenCL program is in the file Square.cl<br>
<br>
__kernel square( <br>
__global float* input, <br>
__global float* output, <br>
const unsigned int count) <br>
{ <br>
int i = get_global_id(0); <br>
if(i < count) <br>
output[i] = input[i] * input[i]; <br>
} <br>
<br>
I’d like to turn it into something like this in Square.h:<br>
<br>
const char *KernelSource = "\n" \<br>
"__kernel square( \n" \<br>
" __global float* input, \n" \<br>
" __global float* output, \n" \<br>
" const unsigned int count) \n" \<br>
"{ \n" \<br>
" int i = get_global_id(0); \n" \<br>
" if(i < count) \n" \<br>
" output[i] = input[i] * input[i]; \n" \<br>
"} \n" \<br>
"\n";<br>
<br>
So that my OpenCL code can be directly compiled into my executable. This is also useful for OpenGL shaders.<br>
<br>
The question: is this something that CMake could do? If so, any examples where to begin looking?<br></span></font></div></blockquote><div><br><br>It is. CMake can definitely do that. I know I've written code like this somewhere... I have to dash off at the moment, but when I get back to a computer, I'll see if I can look it up and pass along a function that does something similar.<br>
<br>Unless somebody else beats me to it. :-)<br><br>- David<br></div></div><br>