Added shaders to build process
This commit is contained in:
@@ -27,6 +27,29 @@ FetchContent_Declare(
|
||||
|
||||
FetchContent_MakeAvailable(glfw)
|
||||
|
||||
# Compiles the shaders #
|
||||
set(SHADER_DIR "${CMAKE_SOURCE_DIR}/shaders")
|
||||
file(GLOB SHADERS
|
||||
"${SHADER_DIR}/*.frag"
|
||||
"${SHADER_DIR}/*.vert"
|
||||
)
|
||||
|
||||
foreach (SHADER ${SHADERS})
|
||||
get_filename_component(FILENAME_WE ${SHADER} NAME_WE)
|
||||
set(SPIRV_FILE "${SHADER_DIR}/${FILENAME_WE}.spv")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${SPIRV_FILE}
|
||||
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V ${SHADER} -o ${SPIRV_FILE}
|
||||
DEPENDS ${SHADER}
|
||||
COMMENT "Compiling shader ${FILENAME}"
|
||||
)
|
||||
|
||||
list(APPEND SPIRV_BINARY_FILES ${SPIRV_FILE})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(CompileShaders ALL DEPENDS ${SPIRV_BINARY_FILES})
|
||||
|
||||
# Creates the output binary
|
||||
project(VulkanRenderer LANGUAGES CXX)
|
||||
add_executable(VulkanRenderer
|
||||
@@ -39,6 +62,8 @@ add_executable(VulkanRenderer
|
||||
src/VulkanRenderer.h
|
||||
)
|
||||
|
||||
add_dependencies(VulkanRenderer CompileShaders)
|
||||
|
||||
target_precompile_headers(VulkanRenderer PRIVATE src/VulkanRenderer.h)
|
||||
|
||||
# Links the libraries to the binary #
|
||||
|
||||
Reference in New Issue
Block a user