57 lines
1.3 KiB
CMake
57 lines
1.3 KiB
CMake
# Configure a command to compile a single shader
|
|
# add_shader_cmd(
|
|
# FILE file
|
|
# OUTPUT output
|
|
# TYPE type
|
|
#)
|
|
function (add_shader_cmd)
|
|
cmake_parse_arguments(SHADER "" "FILE;OUTPUT;TYPE;LANG" "" ${ARGN})
|
|
message(${SHADER_FILE} ${SHADER_OUTPUT} ${SHADER_TYPE} ${SHADER_LANG})
|
|
|
|
set(BGFX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/vendor/bgfx.cmake/bgfx)
|
|
set(VARYING_DEF "C:/Users/romer/Documents/Projects/weasel/src/gfx/shader/varying.def.sc")
|
|
|
|
message("checking platform")
|
|
if(WIN32)
|
|
set(SHADERC_PLATFORM_ARG WINDOWS)
|
|
message("platform = " ${SHADERC_PLATFORM_ARG})
|
|
elseif(APPLE)
|
|
set(SHADERC_PLATFORM_ARG OSX)
|
|
elseif(UNIX)
|
|
set(SHADERC_PLATFORM_ARG LINUX)
|
|
endif()
|
|
|
|
# shaderc_parse(
|
|
# FILE filename
|
|
# OUTPUT filename
|
|
# FRAGMENT|VERTEX|COMPUTE
|
|
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
|
|
# [PROFILE profile]
|
|
# [O 0|1|2|3]
|
|
# [VARYINGDEF filename]
|
|
# [BIN2C filename]
|
|
# [INCLUDES include;include]
|
|
# [DEFINES include;include]
|
|
# [DEPENDS]
|
|
# [PREPROCESS]
|
|
# [RAW]
|
|
# [VERBOSE]
|
|
# [DEBUG]
|
|
# [DISASM]
|
|
# [WERROR]
|
|
# )
|
|
shaderc_parse(SHADERC_ARGS
|
|
FILE ${SHADER_FILE}
|
|
OUTPUT ${SHADER_OUTPUT}
|
|
${SHADER_TYPE}
|
|
${SHADERC_PLATFORM_ARG}
|
|
PROFILE ${SHADER_LANG}
|
|
VARYINGDEF ${VARYING_DEF}
|
|
INCLUDES ${BGFX_PATH}/src
|
|
)
|
|
|
|
list( APPEND SHADER_COMPILE_CMD shaderc ${SHADERC_ARGS} )
|
|
add_custom_command(
|
|
OUTPUT ${SHADER_OUTPUT}
|
|
COMMAND ${SHADER_COMPILE_CMD})
|
|
endfunction() |