<div class="gmail_quote">On Tue, Jun 15, 2010 at 5:13 PM, Daniel Blezek <span dir="ltr">&lt;<a href="mailto:Blezek.Daniel@mayo.edu">Blezek.Daniel@mayo.edu</a>&gt;</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 &lt; 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 = &quot;\n&quot; \<br>
&quot;__kernel square(                                                       \n&quot; \<br>
&quot;   __global float* input,                                              \n&quot; \<br>
&quot;   __global float* output,                                             \n&quot; \<br>
&quot;   const unsigned int count)                                           \n&quot; \<br>
&quot;{                                                                      \n&quot; \<br>
&quot;   int i = get_global_id(0);                                           \n&quot; \<br>
&quot;   if(i &lt; count)                                                       \n&quot; \<br>
&quot;       output[i] = input[i] * input[i];                                \n&quot; \<br>
&quot;}                                                                      \n&quot; \<br>
&quot;\n&quot;;<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&#39;ve written code like this somewhere... I have to dash off at the moment, but when I get back to a computer, I&#39;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>