mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 13:02:33 +01:00
Improvments on the shader compiler utility
The custom command didn't recognize bgfx::shaderc and the generator expression seems bettter. I also added an include option since it might be important to be able to define those. Added changes to each of the cmake files to make sure bgfx:: is defined Also add an output variable name parameter. Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -105,7 +105,7 @@ function(add_bgfx_shader FILE FOLDER)
|
||||
|
||||
foreach(OUT ${OUTPUTS})
|
||||
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}})
|
||||
list(APPEND COMMANDS COMMAND "bgfx::shaderc" ${${OUT}})
|
||||
get_filename_component(OUT_DIR ${${OUT}_OUTPUT} DIRECTORY)
|
||||
file(MAKE_DIRECTORY ${OUT_DIR})
|
||||
endforeach()
|
||||
|
||||
@@ -31,6 +31,12 @@ if(BGFX_BUILD_TOOLS_GEOMETRY AND BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools geometryc)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS_GEOMETRY)
|
||||
if(TARGET geometryc AND NOT TARGET bgfx::geometryc)
|
||||
add_executable(bgfx::geometryc ALIAS geometryc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(IOS)
|
||||
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
|
||||
endif()
|
||||
|
||||
@@ -54,6 +54,12 @@ if(BGFX_BUILD_TOOLS_SHADER AND BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools shaderc)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS_SHADER)
|
||||
if(TARGET shaderc AND NOT TARGET bgfx::shaderc)
|
||||
add_executable(bgfx::shaderc ALIAS shaderc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(shaderc PRIVATE log)
|
||||
elseif(IOS)
|
||||
|
||||
@@ -535,12 +535,14 @@ endfunction()
|
||||
# SHADERS filenames
|
||||
# VARYING_DEF filename
|
||||
# OUTPUT_DIR directory
|
||||
# OUT_FILES_VAR variable name
|
||||
# INCLUDE_DIRS directories
|
||||
# )
|
||||
#
|
||||
function(bgfx_compile_shader_to_header)
|
||||
set(options "")
|
||||
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR)
|
||||
set(multiValueArgs SHADERS)
|
||||
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR)
|
||||
set(multiValueArgs SHADERS INCLUDE_DIRS)
|
||||
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
|
||||
set(PROFILES 120 300_es spirv) # pssl
|
||||
@@ -596,12 +598,15 @@ function(bgfx_compile_shader_to_header)
|
||||
PROFILE ${PROFILE}
|
||||
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
|
||||
VARYINGDEF ${ARGS_VARYING_DEF}
|
||||
INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
|
||||
INCLUDES ${BGFX_SHADER_INCLUDE_PATH} ${ARGS_INCLUDE_DIRS}
|
||||
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
|
||||
)
|
||||
list(APPEND OUTPUTS ${OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
|
||||
endforeach()
|
||||
if(DEFINED ARGS_OUT_FILES_VAR)
|
||||
set(${ARGS_OUT_FILES_VAR} ${OUTPUTS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUTS}
|
||||
|
||||
@@ -26,6 +26,12 @@ if(BGFX_BUILD_TOOLS_TEXTURE AND BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools texturec)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||
if(TARGET texturec AND NOT TARGET bgfx::texturec)
|
||||
add_executable(bgfx::texturec ALIAS texturec)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(texturec PRIVATE log)
|
||||
elseif(IOS)
|
||||
|
||||
@@ -26,6 +26,12 @@ if(BGFX_BUILD_TOOLS_BIN2C AND BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools bin2c)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS_BIN2C)
|
||||
if(TARGET bin2c AND NOT TARGET bgfx::bin2c)
|
||||
add_executable(bgfx::bin2c ALIAS bin2c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(bin2c PRIVATE log)
|
||||
elseif(IOS)
|
||||
|
||||
Reference in New Issue
Block a user