Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if(USE_OPENCL)
add_subdirectory(kernels ${DARKTABLE_DATADIR}/kernels)
endif(USE_OPENCL)

if(APPLE)
add_subdirectory(metal ${DARKTABLE_DATADIR}/metal)
endif(APPLE)

FILE(GLOB THEME_FILES "themes/*.css")
FILE(COPY ${THEME_FILES} DESTINATION "${DARKTABLE_DATADIR}/themes")
install(FILES ${THEME_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/darktable/themes COMPONENT DTApplication)
Expand Down
73 changes: 73 additions & 0 deletions data/metal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# compile macOS metal kernel source files
#

FILE(GLOB DT_METAL_KERNEL_SOURCES "*.metal")

set(DT_METALLIB "darktable.metallib")
set(DT_METALLIB_TOUCH "${DT_METALLIB}.touch")

set(KERNELS "")
set(KERNEL_TOUCHES "")

add_custom_target(metal_kernels ALL)
add_custom_target(dt_metallib ALL)

macro (compile_metal_kernel IN)
get_filename_component(KERNAME ${IN} NAME)
get_filename_component(KERNAME_WLE ${IN} NAME_WLE)

set(KERNAME_OUT "${KERNAME_WLE}.air")

set(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/${KERNAME}.touch")

add_custom_command(
OUTPUT ${TOUCH}
COMMAND ${CMAKE_COMMAND} -E touch ${TOUCH} # will be empty!
COMMAND xcrun -sdk macosx metal -c ${IN} -o ${KERNAME_OUT}
DEPENDS ${IN}
COMMENT "Compiling metal kernel ${IN}"
VERBATIM
)

add_custom_target(
${KERNAME_OUT}
DEPENDS ${TOUCH} # will be empty!
DEPENDS ${IN}
)

add_dependencies(metal_kernels ${KERNAME_OUT})
add_dependencies(dt_metallib ${KERNAME_OUT})

list(APPEND KERNELS ${KERNAME_OUT})
list(APPEND KERNEL_TOUCHES ${TOUCH})
endmacro (compile_metal_kernel)

foreach(KERNEL IN ITEMS ${DT_METAL_KERNEL_SOURCES})
compile_metal_kernel(${KERNEL})
endforeach()

add_custom_command(
OUTPUT ${DT_METALLIB_TOUCH}
DEPENDS ${KERNEL_TOUCHES}
COMMAND xcrun -sdk macosx metallib -o ${DT_METALLIB} ${KERNELS}
COMMENT "Building ${DT_METALLIB}"
COMMAND ${CMAKE_COMMAND} -E touch ${DT_METALLIB_TOUCH}
)

add_custom_target(
dt_metallib_touch ALL
DEPENDS ${DT_METALLIB_TOUCH}
DEPENDS metal_kernels
)

add_dependencies(dt_metallib dt_metallib_touch)

set(METAL_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/darktable/metal")
set(METAL_INSTALL_FILES "")
foreach(K IN LISTS KERNELS)
list(APPEND METAL_INSTALL_FILES "${CMAKE_CURRENT_BINARY_DIR}/${K}")
endforeach()
list(APPEND METAL_INSTALL_FILES "${CMAKE_CURRENT_BINARY_DIR}/${DT_METALLIB}")

install(FILES ${METAL_INSTALL_FILES} DESTINATION ${METAL_INSTALL_DIR})
Loading