add_shader.cmake 530 B

123456789101112131415161718
  1. function(add_shader)
  2. cmake_parse_arguments(args
  3. "" "NAME" "SOURCES" ${ARGN}
  4. )
  5. if("${args_NAME}" STREQUAL "")
  6. message( FATAL_ERROR "add_shader misses NAME" )
  7. endif()
  8. set(output ${CMAKE_SOURCE_DIR}/shaders/${args_NAME}.spv)
  9. add_custom_command(
  10. OUTPUT ${output}
  11. COMMAND glslangValidator -V -o ${output} ${args_SOURCES}
  12. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  13. DEPENDS ${args_SOURCES}
  14. )
  15. add_custom_target(${args_NAME} ALL DEPENDS ${output})
  16. endfunction()