Dawn/tools/texturetool/CMakeLists.txt

46 lines
1.2 KiB
CMake

find_package(Python3 REQUIRED COMPONENTS Interpreter)
function(tool_texture target)
# Defaults
set(FILE "" )
set(FILTER_MIN "")
set(FILTER_MAG "")
set(WRAP_X "")
set(WRAP_Y "")
set(SCALE "")
set(CROP_START_X "")
set(CROP_START_Y "")
set(CROP_END_X "")
set(CROP_END_Y "")
# Parse Args
foreach(_PAIR IN LISTS ARGN)
if (_PAIR MATCHES "^([^:]+)=(.*)$")
set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
else()
message(FATAL_ERROR "Invalid pair: ${_PAIR}")
endif()
endforeach()
# Check for missing args
if(NOT DEFINED FILE)
message(FATAL_ERROR "Missing FILE input")
endif()
add_custom_target(${target}_texture
COMMAND ${DAWN_TOOLS_DIR}/texturetool/texturetool.py
--input="${DAWN_ASSETS_SOURCE_DIR}/${FILE}"
--output="${DAWN_ASSETS_BUILD_DIR}/${target}.texture"
--wrap-x="${WRAP_X}"
--wrap-y="${WRAP_Y}"
--filter-min="${FILTER_MIN}"
--filter-mag="${FILTER_MIN}"
--scale="${SCALE}"
--crop-start-x="${CROP_START_X}"
--crop-start-y="${CROP_START_Y}"
--crop-end-x="${CROP_END_X}"
--crop-end-y="${CROP_END_Y}"
COMMENT "Generating texture ${target} from ${FILE}"
)
add_dependencies(dawnassets ${target}_texture)
endfunction()