Dawn/tools/texturetool/CMakeLists.txt
2023-10-31 21:15:03 -05:00

50 lines
1.3 KiB
CMake

# Copyright (c) 2021 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Tool Function
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}
COMMAND ${DAWN_TOOLS_DIR}/texturetool/texturetool.py
--input="${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})
endfunction()