1# genchk.cmake.in 2# Generate .chk from .out with awk (generic), based upon the automake logic. 3 4# Copyright (C) 2016 Glenn Randers-Pehrson 5# Written by Roger Leigh, 2016 6 7# This code is released under the libpng license. 8# For conditions of distribution and use, see the disclaimer 9# and license in png.h 10 11# Variables substituted from CMakeLists.txt 12set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@") 13set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@") 14 15set(AWK "@AWK@") 16 17get_filename_component(INPUTEXT "${INPUT}" EXT) 18get_filename_component(OUTPUTEXT "${OUTPUT}" EXT) 19get_filename_component(INPUTBASE "${INPUT}" NAME_WE) 20get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE) 21get_filename_component(INPUTDIR "${INPUT}" PATH) 22get_filename_component(OUTPUTDIR "${OUTPUT}" PATH) 23 24if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk") 25 # Generate .chk from .out with awk (generic) 26 file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new") 27 execute_process(COMMAND "${AWK}" -f "${BINDIR}/scripts/checksym.awk" 28 "${SRCDIR}/scripts/${INPUTBASE}.def" 29 "of=${OUTPUTDIR}/${OUTPUTBASE}.new" 30 "${INPUT}" 31 RESULT_VARIABLE AWK_FAIL) 32 if(AWK_FAIL) 33 message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new") 34 endif() 35 file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}") 36else() 37 message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}") 38endif() 39