<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Am 15.06.2010 23:13, schrieb Daniel Blezek:
<blockquote cite="mid:C83D570D.14657%25Blezek.Daniel@mayo.edu"
type="cite">
<title>Converting a OpenCL program into a C++ header?</title>
<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></blockquote>
You could write a little application that reads in the source file and
generates the header file just as in your example. Then you could use
CMake to execute that application e.g. using add_custom_command()
before building your executables that include the generated header
files. You could even build the tool itself as a dependency first.<br>
<br>
Hope that helps...<br>
<br>
Stefan<br>
<br>
</body>
</html>