[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / mlir / tools / mlir-vulkan-runner / CMakeLists.txt
blob26d6caacb0a7b17fd7f6f2d4ccab7c22ea2906e8
1 set(LLVM_OPTIONAL_SOURCES
2   mlir-vulkan-runner.cpp
3   vulkan-runtime-wrappers.cpp
4   VulkanRuntime.cpp
5   VulkanRuntime.h
6   )
8 if (MLIR_ENABLE_VULKAN_RUNNER)
9   message(STATUS "Building the Vulkan runner")
11   find_package(Vulkan)
13   # If Vulkan is not found try a path specified by VULKAN_SDK.
14   if (NOT Vulkan_FOUND)
15     if ("$ENV{VULKAN_SDK}" STREQUAL "")
16       message(FATAL_ERROR "Vulkan not found through CMake; please provide "
17                           "VULKAN_SDK path as an environment variable")
18     endif()
20     find_library(Vulkan_LIBRARY vulkan HINTS "$ENV{VULKAN_SDK}/lib" REQUIRED)
21     if (Vulkan_LIBRARY)
22       set(Vulkan_FOUND ON)
23       set(Vulkan_INCLUDE_DIR "$ENV{VULKAN_SDK}/include")
24       message(STATUS "Found Vulkan: " ${Vulkan_LIBRARY})
25     endif()
26   endif()
28   if (NOT Vulkan_FOUND)
29     message(FATAL_ERROR "Cannot find Vulkan library")
30   endif()
32   add_llvm_library(vulkan-runtime-wrappers SHARED
33     vulkan-runtime-wrappers.cpp
34     VulkanRuntime.cpp
35   )
37   target_include_directories(vulkan-runtime-wrappers
38     PUBLIC
39     ${Vulkan_INCLUDE_DIR}
40   )
42   # *IMPORTANT*: This library cannot depend on LLVM libraries. Otherwise,
43   # it may cause LLVM version conflict when used together with other shared
44   # libraries depending on LLVM. Notably, Mesa, who implements Vulkan
45   # drivers on Linux, depends on the system libLLVM.so.
46   target_link_libraries(vulkan-runtime-wrappers
47     PUBLIC
48     ${Vulkan_LIBRARY}
49   )
51   get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
52   set(LIBS
53     ${conversion_libs}
54     MLIRAnalysis
55     MLIRArithDialect
56     MLIRBuiltinToLLVMIRTranslation
57     MLIRExecutionEngine
58     MLIRFuncDialect
59     MLIRGPUDialect
60     MLIRIR
61     MLIRJitRunner
62     MLIRLLVMDialect
63     MLIRLLVMCommonConversion
64     MLIRLLVMToLLVMIRTranslation
65     MLIRMemRefDialect
66     MLIRMemRefToLLVM
67     MLIRParser
68     MLIRSPIRVDialect
69     MLIRSPIRVTransforms
70     MLIRSupport
71     MLIRTargetLLVMIRExport
72     MLIRTransforms
73     MLIRTranslateLib
74     MLIRVectorDialect
75     MLIRVectorToLLVMPass
76     ${Vulkan_LIBRARY}
77   )
79   # Manually expand the target library, since our MLIR libraries
80   # aren't plugged into the LLVM dependency tracking. If we don't
81   # do this then we can't insert the CodeGen library after ourselves
82   llvm_expand_pseudo_components(TARGET_LIBS AllTargetsCodeGens)
83   # Prepend LLVM in front of every target, this is how the library
84   # are named with CMake
85   SET(targets_to_link)
86   FOREACH(t ${TARGET_LIBS})
87     LIST(APPEND targets_to_link "LLVM${t}")
88   ENDFOREACH(t)
90   add_mlir_tool(mlir-vulkan-runner
91     mlir-vulkan-runner.cpp
93     DEPENDS
94     vulkan-runtime-wrappers
95   )
96   llvm_update_compile_flags(mlir-vulkan-runner)
97   target_link_libraries(mlir-vulkan-runner PRIVATE ${LIBS})
99 endif()