Skip to content

Commit 92ebf24

Browse files
Aaron BoxerAaron Boxer
authored andcommitted
CMake: copy grok_kernels.metallib to bin/ for Metal GPU plugin
When building with GRK_BUILD_PLUGIN_LOADER=ON on macOS, the Metal shader library is compiled to extern/grok-gpu-plugin/ but the plugin looks for it next to its own dylib in bin/. Add a copy_metallib target that automatically copies the .metallib to CMAKE_LIBRARY_OUTPUT_DIRECTORY after the Metal shaders are linked.
1 parent e366f55 commit 92ebf24

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ if(GRK_BUILD_PLUGIN_LOADER)
272272
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
273273
${GROK_LIBRARY_PROPERTIES}
274274
)
275+
# Copy .metallib to the binary output directory so the plugin can find it at runtime
276+
if(APPLE)
277+
set(_metallib_src "${CMAKE_CURRENT_BINARY_DIR}/extern/grok-gpu-plugin/grok_kernels.metallib")
278+
set(_metallib_dst "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/grok_kernels.metallib")
279+
add_custom_command(
280+
OUTPUT "${_metallib_dst}"
281+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_metallib_src}" "${_metallib_dst}"
282+
DEPENDS "${_metallib_src}"
283+
COMMENT "Copying grok_kernels.metallib to output directory"
284+
)
285+
add_custom_target(copy_metallib ALL DEPENDS "${_metallib_dst}")
286+
add_dependencies(copy_metallib grok_metallib)
287+
endif()
275288
endif()
276289

277290
# Build codec library before SWIG bindings (codec bindings link against it)

0 commit comments

Comments
 (0)