@@ -318,33 +318,33 @@ function(__build_ir)
318
318
COUNTER
319
319
)
320
320
set (multi_value_args)
321
- cmake_parse_arguments (SDK_BUILD_IR
321
+ cmake_parse_arguments (ARG
322
322
"${options} "
323
323
"${one_value_args} "
324
324
"${multi_value_args} "
325
325
${ARGN}
326
326
)
327
- get_filename_component (sourceFileName ${SDK_BUILD_IR_SOURCE } NAME )
327
+ get_filename_component (sourceFileName ${ARG_SOURCE } NAME )
328
328
329
329
# Set the path to the integration header.
330
330
# The .sycl filename must depend on the target so that different targets
331
331
# using the same source file will be generated with a different rule.
332
- set (baseSyclName ${CMAKE_CURRENT_BINARY_DIR} /${SDK_BUILD_IR_TARGET } _${sourceFileName} )
332
+ set (baseSyclName ${CMAKE_CURRENT_BINARY_DIR} /${ARG_TARGET } _${sourceFileName} )
333
333
set (outputSyclFile ${baseSyclName} .sycl)
334
334
get_sycl_target_extension(targetExtension)
335
335
set (outputDeviceFile ${baseSyclName} .${targetExtension} )
336
336
set (depFileName ${baseSyclName} .sycl.d)
337
337
338
- set (include_directories "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET } ,INCLUDE_DIRECTORIES>" )
339
- set (compile_definitions "$<TARGET_PROPERTY:${SDK_BUILD_IR_TARGET } ,COMPILE_DEFINITIONS>" )
338
+ set (include_directories "$<TARGET_PROPERTY:${ARG_TARGET } ,INCLUDE_DIRECTORIES>" )
339
+ set (compile_definitions "$<TARGET_PROPERTY:${ARG_TARGET } ,COMPILE_DEFINITIONS>" )
340
340
set (generated_include_directories
341
341
$<$<BOOL :${include_directories} >:-I\"$<JOIN:${include_directories} ,\"\t-I\">\">)
342
342
set (generated_compile_definitions
343
343
$<$<BOOL :${compile_definitions} >:-D$<JOIN:${compile_definitions} ,\t-D>>)
344
344
345
345
# Obtain language standard of the file
346
346
set (device_compiler_cxx_standard)
347
- get_target_property (targetCxxStandard ${SDK_BUILD_IR_TARGET } CXX_STANDARD)
347
+ get_target_property (targetCxxStandard ${ARG_TARGET } CXX_STANDARD)
348
348
if (targetCxxStandard MATCHES 17)
349
349
set (device_compiler_cxx_standard "-std=c++1z" )
350
350
elseif (targetCxxStandard MATCHES 14)
@@ -358,7 +358,7 @@ function(__build_ir)
358
358
endif ()
359
359
360
360
get_property (source_compile_flags
361
- SOURCE ${SDK_BUILD_IR_SOURCE }
361
+ SOURCE ${ARG_SOURCE }
362
362
PROPERTY COMPUTECPP_SOURCE_FLAGS
363
363
)
364
364
separate_arguments (source_compile_flags)
@@ -372,8 +372,8 @@ function(__build_ir)
372
372
${computecpp_source_flags}
373
373
)
374
374
375
- set (ir_dependencies ${SDK_BUILD_IR_SOURCE } )
376
- get_target_property (target_libraries ${SDK_BUILD_IR_TARGET } LINK_LIBRARIES )
375
+ set (ir_dependencies ${ARG_SOURCE } )
376
+ get_target_property (target_libraries ${ARG_TARGET } LINK_LIBRARIES )
377
377
if (target_libraries)
378
378
foreach (library ${target_libraries} )
379
379
if (TARGET ${library} )
@@ -400,51 +400,51 @@ function(__build_ir)
400
400
${generated_compile_definitions}
401
401
-sycl-ih ${outputSyclFile}
402
402
-o ${outputDeviceFile}
403
- -c ${SDK_BUILD_IR_SOURCE }
403
+ -c ${ARG_SOURCE }
404
404
${generate_depfile}
405
405
DEPENDS ${ir_dependencies}
406
- IMPLICIT_DEPENDS CXX ${SDK_BUILD_IR_SOURCE }
406
+ IMPLICIT_DEPENDS CXX ${ARG_SOURCE }
407
407
${enable_depfile}
408
408
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
409
409
COMMENT "Building ComputeCpp integration header file ${outputSyclFile} " )
410
410
411
411
# Name: (user-defined name)_(source file)_(counter)_ih
412
412
set (headerTargetName
413
- ${SDK_BUILD_IR_TARGET } _${sourceFileName} _${SDK_BUILD_IR_COUNTER } _ih)
413
+ ${ARG_TARGET } _${sourceFileName} _${ARG_COUNTER } _ih)
414
414
415
415
if (NOT MSVC )
416
416
# Add a custom target for the generated integration header
417
417
add_custom_target (${headerTargetName} DEPENDS ${outputDeviceFile} ${outputSyclFile} )
418
- add_dependencies (${SDK_BUILD_IR_TARGET } ${headerTargetName} )
418
+ add_dependencies (${ARG_TARGET } ${headerTargetName} )
419
419
endif ()
420
420
421
421
# This property can be set on a per-target basis to indicate that the
422
422
# integration header should appear after the main source listing
423
- get_target_property (includeAfter ${SDK_ADD_SYCL_TARGET } COMPUTECPP_INCLUDE_AFTER)
423
+ get_target_property (includeAfter ${ARG_TARGET } COMPUTECPP_INCLUDE_AFTER)
424
424
425
425
if (includeAfter)
426
426
# Change the source file to the integration header - e.g.
427
427
# g++ -c source_file_name.cpp.sycl
428
- get_target_property (current_sources ${SDK_BUILD_IR_TARGET } SOURCES )
428
+ get_target_property (current_sources ${ARG_TARGET } SOURCES )
429
429
# Remove absolute path to source file
430
- list (REMOVE_ITEM current_sources ${SDK_BUILD_IR_SOURCE } )
430
+ list (REMOVE_ITEM current_sources ${ARG_SOURCE } )
431
431
# Remove relative path to source file
432
432
string (REPLACE "${CMAKE_CURRENT_SOURCE_DIR} /" ""
433
- rel_source_file ${SDK_BUILD_IR_SOURCE }
433
+ rel_source_file ${ARG_SOURCE }
434
434
)
435
435
list (REMOVE_ITEM current_sources ${rel_source_file} )
436
436
# Add SYCL header to source list
437
437
list (APPEND current_sources ${outputSyclFile} )
438
- set_property (TARGET ${SDK_BUILD_IR_TARGET }
438
+ set_property (TARGET ${ARG_TARGET }
439
439
PROPERTY SOURCES ${current_sources} )
440
440
# CMake/gcc don't know what language a .sycl file is, so tell them
441
441
set_property (SOURCE ${outputSyclFile} PROPERTY LANGUAGE CXX)
442
- set (includedFile ${SDK_BUILD_IR_SOURCE } )
442
+ set (includedFile ${ARG_SOURCE } )
443
443
set (cppFile ${outputSyclFile} )
444
444
else ()
445
445
set_property (SOURCE ${outputSyclFile} PROPERTY HEADER_FILE_ONLY ON )
446
446
set (includedFile ${outputSyclFile} )
447
- set (cppFile ${SDK_BUILD_IR_SOURCE } )
447
+ set (cppFile ${ARG_SOURCE } )
448
448
endif ()
449
449
450
450
# Force inclusion of the integration header for the host compiler
@@ -455,11 +455,11 @@ function(__build_ir)
455
455
if (includeAfter)
456
456
# Allow the source file to be edited using Visual Studio.
457
457
# It will be added as a header file so it won't be compiled.
458
- set_property (SOURCE ${SDK_BUILD_IR_SOURCE } PROPERTY HEADER_FILE_ONLY true )
458
+ set_property (SOURCE ${ARG_SOURCE } PROPERTY HEADER_FILE_ONLY true )
459
459
endif ()
460
460
461
461
# Add both source and the sycl files to the VS solution.
462
- target_sources (${SDK_BUILD_IR_TARGET } PUBLIC ${SDK_BUILD_IR_SOURCE } ${outputSyclFile} )
462
+ target_sources (${ARG_TARGET } PUBLIC ${ARG_SOURCE } ${outputSyclFile} )
463
463
464
464
set (forceIncludeFlags "/FI${includedFile} /TP" )
465
465
else ()
@@ -491,17 +491,17 @@ function(add_sycl_to_target)
491
491
set (multi_value_args
492
492
SOURCES
493
493
)
494
- cmake_parse_arguments (SDK_ADD_SYCL
494
+ cmake_parse_arguments (ARG
495
495
"${options} "
496
496
"${one_value_args} "
497
497
"${multi_value_args} "
498
498
${ARGN}
499
499
)
500
- if ("${SDK_ADD_SYCL_SOURCES } " STREQUAL "" )
500
+ if ("${ARG_SOURCES } " STREQUAL "" )
501
501
message (WARNING "No source files provided to add_sycl_to_target. "
502
502
"SYCL integration headers may not be generated." )
503
503
endif ()
504
- set_target_properties (${SDK_ADD_SYCL_TARGET } PROPERTIES LINKER_LANGUAGE CXX)
504
+ set_target_properties (${ARG_TARGET } PROPERTIES LINKER_LANGUAGE CXX)
505
505
506
506
# If the CXX compiler is set to compute++ enable the driver.
507
507
get_filename_component (cmakeCxxCompilerFileName "${CMAKE_CXX_COMPILER} " NAME )
@@ -511,19 +511,19 @@ function(add_sycl_to_target)
511
511
revert the CXX compiler to your default host compiler." )
512
512
endif ()
513
513
514
- get_target_property (includeAfter ${SDK_ADD_SYCL_TARGET } COMPUTECPP_INCLUDE_AFTER)
514
+ get_target_property (includeAfter ${ARG_TARGET } COMPUTECPP_INCLUDE_AFTER)
515
515
if (includeAfter)
516
516
list (APPEND COMPUTECPP_USER_FLAGS -fsycl-ih-last)
517
517
endif ()
518
518
list (INSERT COMPUTECPP_DEVICE_COMPILER_FLAGS 0 -sycl-driver)
519
519
# Prepend COMPUTECPP_DEVICE_COMPILER_FLAGS and append COMPUTECPP_USER_FLAGS
520
520
foreach (prop COMPILE_OPTIONS INTERFACE_COMPILE_OPTIONS)
521
- get_target_property (target_compile_options ${SDK_ADD_SYCL_TARGET } ${prop} )
521
+ get_target_property (target_compile_options ${ARG_TARGET } ${prop} )
522
522
if (NOT target_compile_options)
523
523
set (target_compile_options "" )
524
524
endif ()
525
525
set_property (
526
- TARGET ${SDK_ADD_SYCL_TARGET }
526
+ TARGET ${ARG_TARGET }
527
527
PROPERTY ${prop}
528
528
${COMPUTECPP_DEVICE_COMPILER_FLAGS}
529
529
${target_compile_options}
@@ -534,23 +534,23 @@ function(add_sycl_to_target)
534
534
set (fileCounter 0)
535
535
list (INSERT COMPUTECPP_DEVICE_COMPILER_FLAGS 0 -sycl)
536
536
# Add custom target to run compute++ and generate the integration header
537
- foreach (sourceFile ${SDK_ADD_SYCL_SOURCES } )
537
+ foreach (sourceFile ${ARG_SOURCES } )
538
538
if (NOT IS_ABSOLUTE ${sourceFile} )
539
539
set (sourceFile "${CMAKE_CURRENT_SOURCE_DIR} /${sourceFile} " )
540
540
endif ()
541
541
__build_ir(
542
- TARGET ${SDK_ADD_SYCL_TARGET }
542
+ TARGET ${ARG_TARGET }
543
543
SOURCE ${sourceFile}
544
544
COUNTER ${fileCounter}
545
545
)
546
546
MATH (EXPR fileCounter "${fileCounter} + 1" )
547
547
endforeach ()
548
548
endif ()
549
549
550
- set_property (TARGET ${SDK_ADD_SYCL_TARGET }
550
+ set_property (TARGET ${ARG_TARGET }
551
551
APPEND PROPERTY LINK_LIBRARIES ComputeCpp::ComputeCpp)
552
- set_property (TARGET ${SDK_ADD_SYCL_TARGET }
552
+ set_property (TARGET ${ARG_TARGET }
553
553
APPEND PROPERTY INTERFACE_LINK_LIBRARIES ComputeCpp::ComputeCpp)
554
- target_compile_definitions (${SDK_ADD_SYCL_TARGET } INTERFACE
554
+ target_compile_definitions (${ARG_TARGET } INTERFACE
555
555
SYCL_LANGUAGE_VERSION=${SYCL_LANGUAGE_VERSION} )
556
556
endfunction (add_sycl_to_target)
0 commit comments