@@ -81,6 +81,11 @@ endif()
81
81
# llvm-spirv is an optional dependency, used to build spirv-* targets.
82
82
find_program ( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
83
83
84
+ if ( LLVM_SPIRV )
85
+ add_executable ( libclc::llvm-spirv IMPORTED GLOBAL )
86
+ set_target_properties ( libclc::llvm-spirv PROPERTIES IMPORTED_LOCATION ${LLVM_SPIRV} )
87
+ endif ()
88
+
84
89
# List of all targets. Note that some are added dynamically below.
85
90
set ( LIBCLC_TARGETS_ALL
86
91
amdgcn--
@@ -101,7 +106,7 @@ endif()
101
106
102
107
# spirv-mesa3d and spirv64-mesa3d targets can only be built with the (optional)
103
108
# llvm-spirv external tool.
104
- if ( LLVM_SPIRV )
109
+ if ( TARGET libclc::llvm-spirv )
105
110
list ( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
106
111
endif ()
107
112
@@ -114,7 +119,7 @@ list( SORT LIBCLC_TARGETS_TO_BUILD )
114
119
# Verify that the user hasn't requested mesa3d targets without an available
115
120
# llvm-spirv tool.
116
121
if ( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD )
117
- if ( NOT LLVM_SPIRV )
122
+ if ( NOT TARGET libclc::llvm-spirv )
118
123
message ( FATAL_ERROR "SPIR-V targets requested, but spirv-tools is not installed" )
119
124
endif ()
120
125
endif ()
@@ -363,7 +368,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
363
368
if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
364
369
set ( spv_suffix ${arch_suffix} .spv )
365
370
add_custom_command ( OUTPUT ${spv_suffix}
366
- COMMAND ${LLVM_SPIRV} ${spvflags} -o ${spv_suffix} ${builtins_link_lib}
371
+ COMMAND libclc::llvm-spirv ${spvflags} -o ${spv_suffix} ${builtins_link_lib}
367
372
DEPENDS ${builtins_link_lib}
368
373
)
369
374
add_custom_target ( "prepare-${spv_suffix} " ALL DEPENDS "${spv_suffix} " )
0 commit comments