1 file(GLOB cl_list "${CL_DIR}/*.cl" )
4 string(REPLACE ".cpp" ".hpp" OUTPUT_HPP "${OUTPUT}")
5 get_filename_component(OUTPUT_HPP_NAME "${OUTPUT_HPP}" NAME)
7 set(STR_CPP "// This file is auto-generated. Do not edit!
9 #include \"precomp.hpp\"
10 #include \"${OUTPUT_HPP_NAME}\"
18 set(STR_HPP "// This file is auto-generated. Do not edit!
20 #include \"opencv2/ocl/private/util.hpp\"
29 foreach(cl ${cl_list})
30 get_filename_component(cl_filename "${cl}" NAME_WE)
31 #message("${cl_filename}")
33 file(READ "${cl}" lines)
35 string(REPLACE "\r" "" lines "${lines}\n")
36 string(REPLACE "\t" " " lines "${lines}")
38 string(REGEX REPLACE "/\\*([^*]/|\\*[^/]|[^*/])*\\*/" "" lines "${lines}") # multiline comments
39 string(REGEX REPLACE "/\\*([^\n])*\\*/" "" lines "${lines}") # single-line comments
40 string(REGEX REPLACE "[ ]*//[^\n]*\n" "\n" lines "${lines}") # single-line comments
41 string(REGEX REPLACE "\n[ ]*(\n[ ]*)*" "\n" lines "${lines}") # empty lines & leading whitespace
42 string(REGEX REPLACE "^\n" "" lines "${lines}") # leading new line
44 string(REPLACE "\\" "\\\\" lines "${lines}")
45 string(REPLACE "\"" "\\\"" lines "${lines}")
46 string(REPLACE "\n" "\\n\"\n\"" lines "${lines}")
48 string(REGEX REPLACE "\"$" "" lines "${lines}") # unneeded " at the eof
50 string(MD5 hash "${lines}")
52 set(STR_CPP "${STR_CPP}const struct ProgramEntry ${cl_filename}={\"${cl_filename}\",\n\"${lines}, \"${hash}\"};\n")
53 set(STR_HPP "${STR_HPP}extern const struct ProgramEntry ${cl_filename};\n")
56 set(STR_CPP "${STR_CPP}}\n}\n")
57 set(STR_HPP "${STR_HPP}}\n}\n")
59 file(WRITE "${OUTPUT}" "${STR_CPP}")
61 if(EXISTS "${OUTPUT_HPP}")
62 file(READ "${OUTPUT_HPP}" hpp_lines)
64 if("${hpp_lines}" STREQUAL "${STR_HPP}")
65 message(STATUS "${OUTPUT_HPP} contains same content")
67 file(WRITE "${OUTPUT_HPP}" "${STR_HPP}")