opencv/cmake/cl2cpp.cmake

36 lines
1.2 KiB
CMake
Raw Normal View History

file(GLOB cl_list "${CL_DIR}/*.cl" )
file(WRITE ${OUTPUT} "// This file is auto-generated. Do not edit!
namespace cv
{
namespace ocl
{
")
foreach(cl ${cl_list})
get_filename_component(cl_filename "${cl}" NAME_WE)
#message("${cl_filename}")
file(READ "${cl}" lines)
string(REPLACE "\r" "" lines "${lines}\n")
string(REPLACE "\t" " " lines "${lines}")
string(REGEX REPLACE "/\\*([^*]/|\\*[^/]|[^*/])*\\*/" "" lines "${lines}") # multiline comments
2013-03-26 12:01:01 +08:00
string(REGEX REPLACE "/\\*([^\n])*\\*/" "" lines "${lines}") # single-line comments
string(REGEX REPLACE "[ ]*//[^\n]*\n" "\n" lines "${lines}") # single-line comments
string(REGEX REPLACE "\n[ ]*(\n[ ]*)*" "\n" lines "${lines}") # empty lines & leading whitespace
string(REGEX REPLACE "^\n" "" lines "${lines}") # leading new line
string(REPLACE "\\" "\\\\" lines "${lines}")
string(REPLACE "\"" "\\\"" lines "${lines}")
string(REPLACE "\n" "\\n\"\n\"" lines "${lines}")
string(REGEX REPLACE "\"$" "" lines "${lines}") # unneeded " at the eof
file(APPEND ${OUTPUT} "const char* ${cl_filename}=\"${lines};\n")
endforeach()
2013-08-21 21:26:54 +08:00
file(APPEND ${OUTPUT} "}\n}\n")