build: hacer Vulkan SDK opcional usando SPIR-V pre-compilados
Si glslc no está disponible, CMake usa los headers en shaders/precompiled/ en lugar de fallar. Los SPIR-V son portátiles entre Windows y Linux, por lo que el build funciona sin instalar Vulkan SDK. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,9 +28,9 @@ endif()
|
||||
if(NOT APPLE)
|
||||
find_program(GLSLC glslc HINTS "$ENV{VULKAN_SDK}/bin" "$ENV{VULKAN_SDK}/Bin")
|
||||
if(NOT GLSLC)
|
||||
message(FATAL_ERROR "glslc not found. Install the Vulkan SDK and ensure glslc is on PATH.")
|
||||
endif()
|
||||
|
||||
message(STATUS "glslc not found — using precompiled SPIR-V headers from shaders/precompiled/")
|
||||
set(SHADER_GEN_DIR "${CMAKE_SOURCE_DIR}/shaders/precompiled")
|
||||
else()
|
||||
set(SHADER_SRC_DIR "${CMAKE_SOURCE_DIR}/shaders")
|
||||
set(SHADER_GEN_DIR "${CMAKE_BINARY_DIR}/generated_shaders")
|
||||
file(MAKE_DIRECTORY "${SHADER_GEN_DIR}")
|
||||
@@ -64,6 +64,7 @@ if(NOT APPLE)
|
||||
endforeach()
|
||||
|
||||
add_custom_target(shaders ALL DEPENDS ${SPIRV_HEADERS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Archivos fuente (excluir main_old.cpp)
|
||||
@@ -103,7 +104,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAK
|
||||
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
|
||||
|
||||
if(NOT APPLE)
|
||||
if(GLSLC)
|
||||
add_dependencies(${PROJECT_NAME} shaders)
|
||||
endif()
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE "${SHADER_GEN_DIR}")
|
||||
endif()
|
||||
|
||||
|
||||
5
shaders/precompiled/ball_vert_spv.h
Normal file
5
shaders/precompiled/ball_vert_spv.h
Normal file
File diff suppressed because one or more lines are too long
5
shaders/precompiled/postfx_frag_spv.h
Normal file
5
shaders/precompiled/postfx_frag_spv.h
Normal file
File diff suppressed because one or more lines are too long
5
shaders/precompiled/postfx_vert_spv.h
Normal file
5
shaders/precompiled/postfx_vert_spv.h
Normal file
File diff suppressed because one or more lines are too long
5
shaders/precompiled/sprite_frag_spv.h
Normal file
5
shaders/precompiled/sprite_frag_spv.h
Normal file
File diff suppressed because one or more lines are too long
5
shaders/precompiled/sprite_vert_spv.h
Normal file
5
shaders/precompiled/sprite_vert_spv.h
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user