mirror of
				https://git.code.sf.net/p/libpng/code.git
				synced 2025-07-10 18:04:09 +02:00 
			
		
		
		
	 840af2eda6
			
		
	
	
		840af2eda6
		
	
	
	
	
		
			
			The issue is that, by default, Git for Windows checks out text files with CRLF line endings. This is a problem for awk, which is expecting Unix-style LF line endings. When cloning on Windows and attempting to compile on WSL, Mingw or Cygwin, there may be an error from awk. The fix is to leverage CMake's ability to configure a file and perform EOL conversions. We copy the awk scripts from the source directory to the build directory. This portable method ensures they have LF endings, and the build logic is updated to use the build directory version. Intentionally avoiding .gitattributes to avoid setting precedent. Co-authored-by: Christopher Sean Morrison <brlcad@gmail.com> Co-authored-by: Cosmin Truta <ctruta@gmail.com> Signed-off-by: Cosmin Truta <ctruta@gmail.com>
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			CMake
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			CMake
		
	
	
	
	
	
| # genchk.cmake.in
 | |
| # Generate .chk from .out with awk (generic), based upon the automake logic.
 | |
| 
 | |
| # Copyright (C) 2016 Glenn Randers-Pehrson
 | |
| # Written by Roger Leigh, 2016
 | |
| 
 | |
| # This code is released under the libpng license.
 | |
| # For conditions of distribution and use, see the disclaimer
 | |
| # and license in png.h
 | |
| 
 | |
| # Variables substituted from CMakeLists.txt
 | |
| set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
 | |
| set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
 | |
| 
 | |
| set(AWK "@AWK@")
 | |
| 
 | |
| get_filename_component(INPUTEXT "${INPUT}" EXT)
 | |
| get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
 | |
| get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
 | |
| get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
 | |
| get_filename_component(INPUTDIR "${INPUT}" PATH)
 | |
| get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
 | |
| 
 | |
| if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk")
 | |
|   # Generate .chk from .out with awk (generic)
 | |
|   file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
 | |
|   execute_process(COMMAND "${AWK}" -f "${BINDIR}/scripts/checksym.awk"
 | |
|                           "${SRCDIR}/scripts/${INPUTBASE}.def"
 | |
|                           "of=${OUTPUTDIR}/${OUTPUTBASE}.new"
 | |
|                           "${INPUT}"
 | |
|                   RESULT_VARIABLE AWK_FAIL)
 | |
|   if(AWK_FAIL)
 | |
|     message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new")
 | |
|   endif()
 | |
|   file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}")
 | |
| else()
 | |
|   message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
 | |
| endif()
 |