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
|
---|
12 | set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
---|
13 |
|
---|
14 | set(AWK "@AWK@")
|
---|
15 |
|
---|
16 | get_filename_component(INPUTEXT "${INPUT}" EXT)
|
---|
17 | get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
|
---|
18 | get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
|
---|
19 | get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
|
---|
20 | get_filename_component(INPUTDIR "${INPUT}" PATH)
|
---|
21 | get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
|
---|
22 |
|
---|
23 | if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk")
|
---|
24 | # Generate .chk from .out with awk (generic)
|
---|
25 | file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
|
---|
26 | execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/checksym.awk"
|
---|
27 | "${SRCDIR}/scripts/${INPUTBASE}.def"
|
---|
28 | "of=${OUTPUTDIR}/${OUTPUTBASE}.new"
|
---|
29 | "${INPUT}"
|
---|
30 | RESULT_VARIABLE AWK_FAIL)
|
---|
31 | if(AWK_FAIL)
|
---|
32 | message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new")
|
---|
33 | endif()
|
---|
34 | file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}")
|
---|
35 | else()
|
---|
36 | message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
|
---|
37 | endif()
|
---|