Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions cmake/Modules/FindComputeCpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cmake_minimum_required(VERSION 3.4.3)
include(FindPackageHandleStandardArgs)

set(COMPUTECPP_USER_FLAGS "" CACHE STRING "User flags for compute++")
separate_arguments(COMPUTECPP_USER_FLAGS)
mark_as_advanced(COMPUTECPP_USER_FLAGS)

set(COMPUTECPP_BITCODE "spir64" CACHE STRING
Expand Down Expand Up @@ -234,15 +235,21 @@ function(__build_ir)
get_filename_component(sourceFileName ${SDK_BUILD_IR_SOURCE} NAME)

# Set the path to the integration header.
set(outputSyclFile ${CMAKE_CURRENT_BINARY_DIR}/${sourceFileName}.sycl)
set(depFileName ${CMAKE_CURRENT_BINARY_DIR}/${sourceFileName}.sycl.d)
# The .sycl filename must depend on the target so that different targets
# using the same source file will be generated with a different rule.
set(baseSyclName ${CMAKE_CURRENT_BINARY_DIR}/${SDK_BUILD_IR_TARGET}_${sourceFileName})
set(outputSyclFile ${baseSyclName}.sycl)
set(depFileName ${baseSyclName}.sycl.d)

set(include_directories "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET},INCLUDE_DIRECTORIES>")
set(compile_definitions "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET},COMPILE_DEFINITIONS>")
set(compile_options "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET},COMPILE_OPTIONS>")
set(generated_include_directories
$<$<BOOL:${include_directories}>:-I\"$<JOIN:${include_directories},\"\t-I\">\">)
set(generated_compile_definitions
$<$<BOOL:${compile_definitions}>:-D$<JOIN:${compile_definitions},\t-D>>)
set(generated_compile_options
$<$<BOOL:${compile_options}>:$<JOIN:${compile_options},\t>>)

# Obtain language standard of the file
set(device_compiler_cxx_standard)
Expand All @@ -263,14 +270,15 @@ function(__build_ir)
SOURCE ${SDK_BUILD_IR_SOURCE}
PROPERTY COMPUTECPP_SOURCE_FLAGS
)
separate_arguments(source_compile_flags)
if(source_compile_flags)
list(APPEND target_compile_flags ${source_compile_flags})
list(APPEND computecpp_source_flags ${source_compile_flags})
endif()

list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS
${device_compiler_cxx_standard}
${COMPUTECPP_USER_FLAGS}
${target_compile_flags}
${computecpp_source_flags}
)

set(ir_dependencies ${SDK_BUILD_IR_SOURCE})
Expand All @@ -295,7 +303,7 @@ function(__build_ir)
OUTPUT ${outputSyclFile}
COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE}
${COMPUTECPP_DEVICE_COMPILER_FLAGS}
${device_compiler_includes}
${generated_compile_options}
${generated_include_directories}
${generated_compile_definitions}
-o ${outputSyclFile}
Expand Down