forked from lijiext/lammps
CMake: Rebuild OpenCL kernel headers when code changes
This commit is contained in:
parent
6029445ab5
commit
d8220e2773
|
@ -0,0 +1,3 @@
|
|||
# utility script to call GenerateOpenCLHeader function
|
||||
include(${SOURCE_DIR}/Modules/OpenCLUtils.cmake)
|
||||
WriteOpenCLHeader(${VARNAME} ${HEADER_FILE} ${SOURCE_FILES})
|
|
@ -1,10 +1,8 @@
|
|||
function(GenerateOpenCLHeader varname outfile files)
|
||||
message("Creating ${outfile}...")
|
||||
function(WriteOpenCLHeader varname outfile files)
|
||||
file(WRITE ${outfile} "const char * ${varname} = \n")
|
||||
math(EXPR ARG_END "${ARGC}-1")
|
||||
separate_arguments(files)
|
||||
|
||||
foreach(IDX RANGE 2 ${ARG_END})
|
||||
list(GET ARGV ${IDX} filename)
|
||||
foreach(filename ${files})
|
||||
file(READ ${filename} content)
|
||||
string(REGEX REPLACE "\\s*//[^\n]*\n" "\n" content "${content}")
|
||||
string(REGEX REPLACE "\\\\" "\\\\\\\\" content "${content}")
|
||||
|
@ -15,4 +13,16 @@ function(GenerateOpenCLHeader varname outfile files)
|
|||
endforeach()
|
||||
|
||||
file(APPEND ${outfile} ";\n")
|
||||
endfunction(WriteOpenCLHeader)
|
||||
|
||||
function(GenerateOpenCLHeader varname outfile files)
|
||||
list(REMOVE_AT ARGV 0 1)
|
||||
add_custom_command(OUTPUT ${outfile}
|
||||
COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-D VARNAME=${varname}
|
||||
-D HEADER_FILE=${outfile}
|
||||
-D SOURCE_FILES="${ARGV}"
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/GenerateOpenCLHeader.cmake
|
||||
DEPENDS ${ARGV}
|
||||
COMMENT "Generating ${outfile}...")
|
||||
endfunction(GenerateOpenCLHeader)
|
||||
|
|
Loading…
Reference in New Issue