File: CMakeLists.txt

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (99 lines) | stat: -rw-r--r-- 2,733 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
set(LLVM_OPTIONAL_SOURCES
  mlir-vulkan-runner.cpp
  vulkan-runtime-wrappers.cpp
  VulkanRuntime.cpp
  VulkanRuntime.h
  )

if (MLIR_ENABLE_VULKAN_RUNNER)
  message(STATUS "Building the Vulkan runner")

  find_package(Vulkan)

  # If Vulkan is not found try a path specified by VULKAN_SDK.
  if (NOT Vulkan_FOUND)
    if ("$ENV{VULKAN_SDK}" STREQUAL "")
      message(FATAL_ERROR "Vulkan not found through CMake; please provide "
                          "VULKAN_SDK path as an environment variable")
    endif()

    find_library(Vulkan_LIBRARY vulkan HINTS "$ENV{VULKAN_SDK}/lib" REQUIRED)
    if (Vulkan_LIBRARY)
      set(Vulkan_FOUND ON)
      set(Vulkan_INCLUDE_DIR "$ENV{VULKAN_SDK}/include")
      message(STATUS "Found Vulkan: " ${Vulkan_LIBRARY})
    endif()
  endif()

  if (NOT Vulkan_FOUND)
    message(FATAL_ERROR "Cannot find Vulkan library")
  endif()

  add_llvm_library(vulkan-runtime-wrappers SHARED
    vulkan-runtime-wrappers.cpp
    VulkanRuntime.cpp
  )

  target_include_directories(vulkan-runtime-wrappers
    PUBLIC
    ${Vulkan_INCLUDE_DIR}
  )

  # *IMPORTANT*: This library cannot depend on LLVM libraries. Otherwise,
  # it may cause LLVM version conflict when used together with other shared
  # libraries depending on LLVM. Notably, Mesa, who implements Vulkan
  # drivers on Linux, depends on the system libLLVM.so.
  target_link_libraries(vulkan-runtime-wrappers
    PUBLIC
    ${Vulkan_LIBRARY}
  )

  get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
  set(LIBS
    ${conversion_libs}
    MLIRAnalysis
    MLIRArithDialect
    MLIRBuiltinToLLVMIRTranslation
    MLIRExecutionEngine
    MLIRFuncDialect
    MLIRGPUDialect
    MLIRIR
    MLIRJitRunner
    MLIRLLVMDialect
    MLIRLLVMCommonConversion
    MLIRLLVMToLLVMIRTranslation
    MLIRMemRefDialect
    MLIRMemRefToLLVM
    MLIRParser
    MLIRSPIRVDialect
    MLIRSPIRVTransforms
    MLIRSupport
    MLIRTargetLLVMIRExport
    MLIRTransforms
    MLIRTranslateLib
    MLIRVectorDialect
    MLIRVectorToLLVM
    ${Vulkan_LIBRARY}
  )

  # Manually expand the target library, since our MLIR libraries
  # aren't plugged into the LLVM dependency tracking. If we don't
  # do this then we can't insert the CodeGen library after ourselves
  llvm_expand_pseudo_components(TARGET_LIBS AllTargetsCodeGens)
  # Prepend LLVM in front of every target, this is how the library
  # are named with CMake
  SET(targets_to_link)
  FOREACH(t ${TARGET_LIBS})
    LIST(APPEND targets_to_link "LLVM${t}")
  ENDFOREACH(t)

  add_mlir_tool(mlir-vulkan-runner
    mlir-vulkan-runner.cpp

    DEPENDS
    vulkan-runtime-wrappers
  )
  llvm_update_compile_flags(mlir-vulkan-runner)
  target_link_libraries(mlir-vulkan-runner PRIVATE ${LIBS})

endif()