convert cl file to headers

CMakeLists.txt

======================================================================================================

cmake_minimum_required(VERSION 3.1) #specify cmake version

set(input_file "a.cl")#specify input cl files name

 

set(output_file "a.hl")#specify output hl files name

# Read the whole input file:

#

file(READ "${input_file}" contents)

# Split it into lines:

#    (insert line-ending 'E' chars to allow lines to be blank or end with

#     semi-colons but still be iterate-able via CMake foreach...)

#

string(REGEX REPLACE ";" "\\\\;" contents "${contents}")

string(REGEX REPLACE "\n" "E;" contents "${contents}")

# Open output file:

#

file(WRITE "${output_file}"

 

  "const char *tms_oclkernel =\n")#specify kernel source string name

# Send each line to output file:

#

foreach(lineE ${contents})

  # Get rid of the trailing 'E':

  #

  string(REGEX REPLACE "^(.*)E$"  "\\1"   line "${lineE}")

  file(APPEND "${output_file}"

    "  \"${line}\ \\n\"\n")

endforeach()

# Close output file:

#

file(APPEND "${output_file}" ";\n")

======================================================================================================

convert .cl file to .hl 

======================================================================================================

open cmake 

Select 1.where is the source code : where cl file and CMakeLists.txt location

      2.where to build the binaries: the same  location as source code

Configure. Specify the generator for this project ,Finish 

Then cl files has been change to hl files

猜你喜欢

转载自blog.csdn.net/chfeilong0202/article/details/41679831
cl
今日推荐