Skip to content

Commit 06f54e7

Browse files
committed
[libclc] Convert llvm-spirv to imported executable
This tool now behaves like the others, for consistency.
1 parent dbece2b commit 06f54e7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libclc/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ endif()
8181
# llvm-spirv is an optional dependency, used to build spirv-* targets.
8282
find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
8383

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+
8489
# List of all targets. Note that some are added dynamically below.
8590
set( LIBCLC_TARGETS_ALL
8691
amdgcn--
@@ -101,7 +106,7 @@ endif()
101106

102107
# spirv-mesa3d and spirv64-mesa3d targets can only be built with the (optional)
103108
# llvm-spirv external tool.
104-
if( LLVM_SPIRV )
109+
if( TARGET libclc::llvm-spirv )
105110
list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
106111
endif()
107112

@@ -114,7 +119,7 @@ list( SORT LIBCLC_TARGETS_TO_BUILD )
114119
# Verify that the user hasn't requested mesa3d targets without an available
115120
# llvm-spirv tool.
116121
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 )
118123
message( FATAL_ERROR "SPIR-V targets requested, but spirv-tools is not installed" )
119124
endif()
120125
endif()
@@ -363,7 +368,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
363368
if( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
364369
set( spv_suffix ${arch_suffix}.spv )
365370
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}
367372
DEPENDS ${builtins_link_lib}
368373
)
369374
add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" )

0 commit comments

Comments
 (0)