function(tool_texture target file) find_package(Python3 REQUIRED COMPONENTS Interpreter) # Defaults 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 ${Python3_EXECUTABLE} ${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}" DEPENDS ${DAWN_TOOLS_DIR}/texturetool/texturetool.py ${DAWN_ASSETS_SOURCE_DIR}/${file} ${Python3_EXECUTABLE} USES_TERMINAL ) add_dependencies(dawnassets ${target}_texture) endfunction()