File: Open3DSYCLTargetSources.cmake

package info (click to toggle)
open3d 0.16.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,688 kB
  • sloc: cpp: 193,088; python: 24,973; ansic: 8,356; javascript: 1,869; sh: 1,473; makefile: 236; xml: 69
file content (41 lines) | stat: -rw-r--r-- 1,938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# open3d_sycl_target_sources(name ...)
#
# When BUILD_SYCL_MODULE=ON, set SYCL-specific compile flags for the listed
# source files and call target_sources(). If BUILD_SYCL_MODULE=OFF, this
# function directly calls target_sources().
#
# Note: this is not a perfect forwarding to target_sources(), as it only support
# limited set of arguments. See the example usage below.
#
# Example usage:
#   open3d_sycl_target_sources(core PRIVATE a.cpp b.cpp)
#   open3d_sycl_target_sources(core PUBLIC a.cpp b.cpp)
#   open3d_sycl_target_sources(core VERBOSE PRIVATE a.cpp b.cpp)
#   open3d_sycl_target_sources(core VERBOSE PUBLIC a.cpp b.cpp)
function(open3d_sycl_target_sources target)
    cmake_parse_arguments(arg "PUBLIC;PRIVATE;INTERFACE;VERBOSE" "" "" ${ARGN})
    if(arg_UNPARSED_ARGUMENTS)
        if(arg_PUBLIC)
            target_sources(${target} PUBLIC ${arg_UNPARSED_ARGUMENTS})
            message(STATUS "open3d_sycl_target_sources(${target}): PUBLIC")
        elseif (arg_PRIVATE)
            target_sources(${target} PRIVATE ${arg_UNPARSED_ARGUMENTS})
            message(STATUS "open3d_sycl_target_sources(${target}): PRIVATE")
        elseif (arg_INTERFACE)
            target_sources(${target} INTERFACE ${arg_UNPARSED_ARGUMENTS})
            message(STATUS "open3d_sycl_target_sources(${target}): INTERFACE")
        else()
            message(FATAL_ERROR "Invalid syntax: open3d_sycl_target_sources(${name} ${ARGN})")
        endif()

        if(BUILD_SYCL_MODULE)
            foreach(sycl_file IN LISTS arg_UNPARSED_ARGUMENTS)
                set_source_files_properties(${sycl_file} PROPERTIES
                    COMPILE_OPTIONS -fsycl -fsycl-unnamed-lambda -fsycl-targets=spir64_x86_64)
                if(arg_VERBOSE)
                    message(STATUS "open3d_sycl_target_sources(${target}): marked ${sycl_file} as SYCL code")
                endif()
            endforeach()
        endif()
    endif()
endfunction()