cmake: refactor cloc invocation

Change method used to pass options to cloc when compiling scheduler and
precompiled kernels. Instead of plain variable use list() which is more
convenient and flexible when generating build system.

Change-Id: Ieb90defc24a66932250dd610691650880ba1be76
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
Artur Harasimiuk 2018-10-11 12:48:43 +02:00 committed by sys_ocldev
parent eb9d720788
commit 97c56b9de0
2 changed files with 12 additions and 11 deletions

View File

@ -16,9 +16,7 @@ else()
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
set(BUILTIN_DEBUG_OPTION "-D DEBUG")
else()
set(BUILTIN_DEBUG_OPTION "")
list(APPEND __cloc__options__ "-D DEBUG")
endif()
set(BUILTINS_INCLUDE_DIR ${TargetDir} PARENT_SCOPE)
@ -61,9 +59,10 @@ function(compile_builtin gen_type platform_type builtin)
set(cloc_cmd_prefix LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc>)
endif()
endif()
list(APPEND __cloc__options__ "-cl-kernel-arg-info")
add_custom_command(
OUTPUT ${OUTPUT_FILES}
COMMAND ${cloc_cmd_prefix} -q -file ${FILENAME} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${BUILTIN_OPTIONS} -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${BUILTIN_DEBUG_OPTION}"
COMMAND ${cloc_cmd_prefix} -q -file ${FILENAME} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${BUILTIN_OPTIONS} -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "$<JOIN:${__cloc__options__}, >"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${builtin} cloc copy_compiler_files
)

View File

@ -9,12 +9,12 @@ set(SCHEDULER_OUTDIR_WITH_ARCH "${TargetDir}/scheduler/${NEO_ARCH}")
set_target_properties(scheduler PROPERTIES FOLDER "scheduler")
set (SCHEDULER_KERNEL scheduler.cl)
set (SCHEDULER_INCLUDE_OPTIONS "-I$<JOIN:${IGDRCL__IGC_INCLUDE_DIR}, -I>")
if(DEFINED IGDRCL__IGC_INCLUDE_DIR)
list(APPEND __cloc__options__ "-I$<JOIN:${IGDRCL__IGC_INCLUDE_DIR}, -I>")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
set(SCHEDULER_DEBUG_OPTION "-D DEBUG")
else()
set(SCHEDULER_DEBUG_OPTION "")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND __cloc__options__ "-D DEBUG")
endif()
set(SCHEDULER_INCLUDE_DIR ${TargetDir})
@ -24,7 +24,7 @@ function(compile_kernel target gen_type platform_type kernel)
string(TOLOWER ${gen_type} gen_type_lower)
# get filename
set(OUTPUTDIR "${SCHEDULER_OUTDIR_WITH_ARCH}/${gen_type_lower}")
set(SCHEDULER_INCLUDE_OPTIONS "${SCHEDULER_INCLUDE_OPTIONS} -I ../${gen_type_lower}")
list(APPEND __cloc__options__ "-I ../${gen_type_lower}")
get_filename_component(BASENAME ${kernel} NAME_WE)
@ -40,9 +40,11 @@ function(compile_kernel target gen_type platform_type kernel)
set(cloc_cmd_prefix LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc>)
endif()
endif()
list(APPEND __cloc__options__ "-cl-kernel-arg-info")
list(APPEND __cloc__options__ "-cl-std=CL2.0")
add_custom_command(
OUTPUT ${OUTPUTPATH}
COMMAND ${cloc_cmd_prefix} -q -file ${kernel} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${SCHEDULER_INCLUDE_OPTIONS} ${SCHEDULER_DEBUG_OPTION} -cl-std=CL2.0"
COMMAND ${cloc_cmd_prefix} -q -file ${kernel} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "$<JOIN:${__cloc__options__}, >"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${kernel} cloc copy_compiler_files
)