File: igc_spirv.cmake

package info (click to toggle)
intel-graphics-compiler 1.0.12504.6-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,912 kB
  • sloc: cpp: 910,147; lisp: 202,655; ansic: 15,197; python: 4,025; yacc: 2,241; lex: 1,570; pascal: 244; sh: 104; makefile: 25
file content (69 lines) | stat: -rw-r--r-- 2,573 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#=========================== begin_copyright_notice ============================
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
#============================ end_copyright_notice =============================

include_guard(DIRECTORY)

# SPIRV translator was added with LLVM (source build or prebuild).

if(NOT TARGET LLVMSPIRVLib OR (WIN32 AND NOT IGC_BUILD__SPIRV_TRANSLATOR_SOURCES))
  message(STATUS "[IGC] Trying to find prebuilt SPIRV library")
  find_package(SPIRVLLVMTranslator ${LLVM_VERSION_MAJOR} REQUIRED)
else()
  message(STATUS "[IGC] Using LLVMSPIRVLib that comes with LLVM")

  # Guess location of header files.
  get_target_property(_is_imported LLVMSPIRVLib IMPORTED)
  if(_is_imported)
    # Imported location property for LLVM can have one of these suffixes.
    set(_prop_types
      ""
      "_RELEASE"
      "_DEBUG"
      "_RELWITHDEBINFO"
      "_MINSIZEREL"
      )
    foreach(t IN LISTS _prop_types)
      get_target_property(_lib_loc LLVMSPIRVLib IMPORTED_LOCATION${t})
      if(_lib_loc)
        break()
      endif()
    endforeach()
    # Installed spirv package has the following directory layout:
    # |-lib/LLVMSPIRVLib.a
    # `-include/LLVMSPIRVLib/<headers>
    # So get include directories based on location of imported library.
    get_filename_component(_inc_dir ${_lib_loc} DIRECTORY)
    get_filename_component(_inc_dir ${_inc_dir}/../include/LLVMSPIRVLib ABSOLUTE)
    unset(_lib_loc)
  else()
    # SPIRV sources has the following directory layout:
    # |-lib/SPIRV/CMakeLists.txt with LLVMSPIRVLib target
    # `-include/<headers>
    # Similarly to the imported target get required include dirs.
    get_target_property(_src_dir LLVMSPIRVLib SOURCE_DIR)
    get_filename_component(_inc_dir ${_src_dir}/../../include ABSOLUTE)
    unset(_srcdir)
  endif()
  unset(_is_imported)

  # Add headers. Since target can be imported, use property.
  # Additionally, for in-tree build, do not set install interface
  # since it can be polluted with build directory artifact.
  set_target_properties(LLVMSPIRVLib PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${_inc_dir}>
    )
  unset(_inc_dir)
endif()

# Set additional compile definition for library. Use property instead of
# target_compile_definitions to unify imported and simple library usage
# because command will fail on imported library (this is cmake deficiency
# that was fixed in later versions).
if(IGC_OPTION__USE_KHRONOS_SPIRV_TRANSLATOR_IN_SC)
    add_compile_definitions(IGC_SCALAR_USE_KHRONOS_SPIRV_TRANSLATOR)
endif()